Ejemplo n.º 1
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomAuthorizeRequestSerializer">A delegate to serialize custom authorize requests.</param>
        /// <param name="CustomIdTokenResponseSerializer">A delegate to serialize custom IdTokens.</param>
        /// <param name="CustomAdditionalInfoResponseSerializer">A delegate to serialize custom AdditionalInfo objects.</param>
        /// <param name="CustomOCSPRequestDataResponseSerializer">A delegate to serialize custom OCSPRequestDatas.</param>
        /// <param name="CustomCustomDataResponseSerializer">A delegate to serialize CustomData objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <AuthorizeRequest> CustomAuthorizeRequestSerializer       = null,
                              CustomJObjectSerializerDelegate <IdToken> CustomIdTokenResponseSerializer                 = null,
                              CustomJObjectSerializerDelegate <AdditionalInfo> CustomAdditionalInfoResponseSerializer   = null,
                              CustomJObjectSerializerDelegate <OCSPRequestData> CustomOCSPRequestDataResponseSerializer = null,
                              CustomJObjectSerializerDelegate <CustomData> CustomCustomDataResponseSerializer           = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("idToken", IdToken.ToJSON(CustomIdTokenResponseSerializer,
                                                        CustomAdditionalInfoResponseSerializer,
                                                        CustomCustomDataResponseSerializer)),

                Certificate.IsNotNullOrEmpty()
                               ? new JProperty("certificate", Certificate)
                               : null,

                ISO15118CertificateHashData.SafeAny()
                               ? new JProperty("iso15118CertificateHashData", new JArray(ISO15118CertificateHashData.SafeSelect(hashData => hashData.ToJSON(CustomOCSPRequestDataResponseSerializer,
                                                                                                                                                            CustomCustomDataResponseSerializer))))
                               : null,

                CustomData != null
                               ? new JProperty("customData", CustomData.ToJSON(CustomCustomDataResponseSerializer))
                               : null

                );

            return(CustomAuthorizeRequestSerializer != null
                       ? CustomAuthorizeRequestSerializer(this, JSON)
                       : JSON);
        }