Esempio n. 1
0
        public OIDCClientInformation RegisterClient(string RegistrationEndpoint, OIDCClientInformation clientMetadata, string TokenEndpointAuthMethod = "client_secret_basic")
        {
            // Make registration request
            OIDCClientRegistrationRequest registrationRequest = new OIDCClientRegistrationRequest();

            registrationRequest.ApplicationType         = clientMetadata.ApplicationType;
            registrationRequest.RedirectUris            = clientMetadata.RedirectUris;
            registrationRequest.ResponseTypes           = clientMetadata.ResponseTypes;
            registrationRequest.TokenEndpointAuthMethod = TokenEndpointAuthMethod;

            // Check error and store client information from OP
            WebRequest request = WebRequest.Create(RegistrationEndpoint);
            Dictionary <string, object> returnedJson = PostUrlContent(request, registrationRequest, true);

            if (returnedJson.Keys.Contains("error"))
            {
                OIDCResponseError error = new OIDCResponseError();
                throw new OIDCException("Error while registering client: " + error.Error + "\n" + error.ErrorDescription);
            }

            OIDCClientInformation clientInformation = new OIDCClientInformation();

            clientInformation.deserializeFromDynamic(returnedJson);
            return(clientInformation);
        }
        /// <summary>
        /// Method that performs a dynamic client registration with the OP server.
        /// </summary>
        /// <param name="RegistrationEndpoint">The URL of the OP describing the registration endpoint.</param>
        /// <param name="clientMetadata">The OIDCClientInformation object describing the client information to
        /// be submitted to the OP for registration.</param>
        /// <param name="TokenEndpointAuthMethod">(optional) the endpoint authentication method used to
        /// authenticate the client with the OP sever (if not specified using "client_secret_basic".</param>
        /// <returns>An oject describing all client information as returned by the OP server after
        /// registration.</returns>
        /// <exception cref="OpenIDClient.OIDCException">Thrown when an error occurs while registering
        /// the client with the OP.</exception>
        public OIDCClientInformation RegisterClient(string RegistrationEndpoint, OIDCClientInformation clientMetadata, string TokenEndpointAuthMethod = "client_secret_basic")
        {
            // Make registration request
            Dictionary <string, object>   data = clientMetadata.SerializeToDictionary();
            OIDCClientRegistrationRequest registrationRequest = new OIDCClientRegistrationRequest();

            registrationRequest.DeserializeFromDictionary(data);

            // Check error and store client information from OP
            WebRequest request        = WebRequest.Create(RegistrationEndpoint);
            string     returnedString = WebOperations.PostUrlContent(request, registrationRequest, true);
            Dictionary <string, object> returnedJson = Deserializer.DeserializeFromJson <Dictionary <string, object> >(returnedString);

            if (returnedJson.Keys.Contains("error"))
            {
                OIDCResponseError error = new OIDCResponseError();
                throw new OIDCException("Error while registering client: " + error.Error + "\n" + error.ErrorDescription);
            }

            OIDCClientInformation clientInformation = new OIDCClientInformation();

            clientInformation.DeserializeFromDictionary(returnedJson);
            return(clientInformation);
        }