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);
        }
Ejemplo n.º 2
0
 public void Setup()
 {
     this.loggerMock           = new Mock <ILogger <TokenExchangeResultBuilder> >();
     this.resultBuilder        = new TokenExchangeResultBuilder(this.loggerMock.Object, new TokenExchangeOptions());
     this.requestValidatorMock = new Mock <ITokenExchangeRequestValidator>();
     this.errorResult          = CreateErrorValidation();
     this.successResult        = CreateSuccessValidation();
 }
Ejemplo n.º 3
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);
        }