public async Task <IHttpActionResult> ProcessAsync(NameValueCollection parameters)
        {
            if (!_options.Endpoints.TokenEndpoint.IsEnabled)
            {
                Logger.Warn("Endpoint is disabled. Aborting");
                return(NotFound());
            }

            // validate client credentials and client
            var client = await _clientValidator.ValidateClientAsync(parameters, Request.Headers.Authorization);

            if (client == null)
            {
                return(this.TokenErrorResponse(Constants.TokenErrors.InvalidClient));
            }

            // validate the token request
            var result = await _requestValidator.ValidateRequestAsync(parameters, client);

            if (result.IsError)
            {
                return(this.TokenErrorResponse(result.Error));
            }

            // return response
            var response = await _generator.ProcessAsync(_requestValidator.ValidatedRequest);

            return(this.TokenResponse(response));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Processes the token request
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>Token response</returns>
        public async Task <IHttpActionResult> ProcessAsync(NameValueCollection parameters)
        {
            // validate client credentials and client
            var client = await _clientValidator.ValidateClientAsync(parameters, Request.Headers.Authorization);

            if (client == null)
            {
                return(this.TokenErrorResponse(Constants.TokenErrors.InvalidClient));
            }

            var appidvalidation = await _comoRequestValidator.Validate(parameters, client);

            if (appidvalidation.IsError)
            {
                return(this.TokenErrorResponse(appidvalidation.Error));
            }
            // validate the token request
            var result = await _requestValidator.ValidateRequestAsync(parameters, client);

            if (result.IsError)
            {
                return(this.TokenErrorResponse(result.Error));
            }

            // return response
            var response = await _generator.ProcessAsync(_requestValidator.ValidatedRequest);

            return(this.TokenResponse(response));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Processes the token request
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>Token response</returns>
        public async Task <IHttpActionResult> ProcessAsync(NameValueCollection parameters)
        {
            // validate client credentials and client
            var clientResult = await _clientValidator.ValidateAsync();

            if (clientResult.IsError)
            {
                return(this.TokenErrorResponse(Constants.TokenErrors.InvalidClient));
            }

            // validate the token request
            var requestResult = await _requestValidator.ValidateRequestAsync(parameters, clientResult.Client);

            if (requestResult.IsError)
            {
                return(this.TokenErrorResponse(requestResult.Error, requestResult.ErrorDescription));
            }

            // return response
            var response = await _generator.ProcessAsync(_requestValidator.ValidatedRequest);

            return(this.TokenResponse(response));
        }