public async Task <TokenExchangeValidation> ValidateAsync(ValidatedTokenRequest request)
        {
            var tokenExchangeValidation = new TokenExchangeValidation();

            var subjectTokenValidation = await this.ValidateTokenAsync(request, RequestParameters.SubjectTokenType, RequestParameters.SubjectToken).ConfigureAwait(false);

            tokenExchangeValidation.SubjectTokenValidationResult = subjectTokenValidation;

            if (subjectTokenValidation.IsError)
            {
                tokenExchangeValidation.SetErrors(subjectTokenValidation);
                return(tokenExchangeValidation);
            }

            var actorTokenValidation = await this.ValidateActorTokenAsync(request).ConfigureAwait(false);

            tokenExchangeValidation.ActorTokenValidationResult = actorTokenValidation;

            if (actorTokenValidation.IsError)
            {
                tokenExchangeValidation.SetErrors(actorTokenValidation);
                return(tokenExchangeValidation);
            }

            if (request.Client.ClientId != actorTokenValidation.Client.ClientId)
            {
                tokenExchangeValidation.SetErrors("Request client_id and actor_token client_id must match.");
                return(tokenExchangeValidation);
            }

            return(tokenExchangeValidation);
        }
Exemplo n.º 2
0
        private static TokenExchangeValidation CreateErrorValidation()
        {
            var errorResult = new TokenValidationResult
            {
                IsError          = true,
                Error            = "invalid request",
                ErrorDescription = "dummy description",
            };

            var validation = new TokenExchangeValidation
            {
                SubjectTokenValidationResult = new TokenValidationResult {
                    IsError = true
                },
                ActorTokenValidationResult = new TokenValidationResult {
                    IsError = false
                },
            };

            validation.SetErrors(errorResult);

            return(validation);
        }