public TokenRequestValidator(
     IdentityServerOptions options,
     IIssuerNameService issuerNameService,
     IAuthorizationCodeStore authorizationCodeStore,
     IResourceOwnerPasswordValidator resourceOwnerValidator,
     IProfileService profile,
     IDeviceCodeValidator deviceCodeValidator,
     IBackchannelAuthenticationRequestIdValidator backchannelAuthenticationRequestIdValidator,
     ExtensionGrantValidator extensionGrantValidator,
     ICustomTokenRequestValidator customRequestValidator,
     IResourceValidator resourceValidator,
     IResourceStore resourceStore,
     IRefreshTokenService refreshTokenService,
     IEventService events,
     ISystemClock clock,
     ILogger <TokenRequestValidator> logger)
 {
     _logger                 = logger;
     _options                = options;
     _issuerNameService      = issuerNameService;
     _clock                  = clock;
     _authorizationCodeStore = authorizationCodeStore;
     _resourceOwnerValidator = resourceOwnerValidator;
     _profile                = profile;
     _deviceCodeValidator    = deviceCodeValidator;
     _backchannelAuthenticationRequestIdValidator = backchannelAuthenticationRequestIdValidator;
     _extensionGrantValidator = extensionGrantValidator;
     _customRequestValidator  = customRequestValidator;
     _resourceValidator       = resourceValidator;
     _resourceStore           = resourceStore;
     _refreshTokenService     = refreshTokenService;
     _events = events;
 }
예제 #2
0
    public static TokenRequestValidator CreateTokenRequestValidator(
        IdentityServerOptions options                          = null,
        IIssuerNameService issuerNameService                   = null,
        IResourceStore resourceStore                           = null,
        IAuthorizationCodeStore authorizationCodeStore         = null,
        IRefreshTokenStore refreshTokenStore                   = null,
        IResourceOwnerPasswordValidator resourceOwnerValidator = null,
        IProfileService profile = null,
        IDeviceCodeValidator deviceCodeValidator = null,
        IBackchannelAuthenticationRequestIdValidator backchannelAuthenticationRequestIdValidator = null,
        IEnumerable <IExtensionGrantValidator> extensionGrantValidators = null,
        ICustomTokenRequestValidator customRequestValidator             = null,
        IRefreshTokenService refreshTokenService = null,
        IResourceValidator resourceValidator     = null)
    {
        if (options == null)
        {
            options = TestIdentityServerOptions.Create();
        }

        if (issuerNameService == null)
        {
            issuerNameService = new TestIssuerNameService(options.IssuerUri);
        }

        if (resourceStore == null)
        {
            resourceStore = new InMemoryResourcesStore(TestScopes.GetIdentity(), TestScopes.GetApis(), TestScopes.GetScopes());
        }

        if (resourceOwnerValidator == null)
        {
            resourceOwnerValidator = new TestResourceOwnerPasswordValidator();
        }

        if (profile == null)
        {
            profile = new TestProfileService();
        }

        if (deviceCodeValidator == null)
        {
            deviceCodeValidator = new TestDeviceCodeValidator();
        }

        if (backchannelAuthenticationRequestIdValidator == null)
        {
            backchannelAuthenticationRequestIdValidator = new TestBackchannelAuthenticationRequestIdValidator();
        }

        if (customRequestValidator == null)
        {
            customRequestValidator = new DefaultCustomTokenRequestValidator();
        }

        ExtensionGrantValidator aggregateExtensionGrantValidator;

        if (extensionGrantValidators == null)
        {
            aggregateExtensionGrantValidator = new ExtensionGrantValidator(new[] { new TestGrantValidator() }, TestLogger.Create <ExtensionGrantValidator>());
        }
        else
        {
            aggregateExtensionGrantValidator = new ExtensionGrantValidator(extensionGrantValidators, TestLogger.Create <ExtensionGrantValidator>());
        }

        if (authorizationCodeStore == null)
        {
            authorizationCodeStore = CreateAuthorizationCodeStore();
        }

        if (refreshTokenStore == null)
        {
            refreshTokenStore = CreateRefreshTokenStore();
        }

        if (resourceValidator == null)
        {
            resourceValidator = CreateResourceValidator(resourceStore);
        }

        if (refreshTokenService == null)
        {
            refreshTokenService = CreateRefreshTokenService(
                refreshTokenStore,
                profile);
        }

        return(new TokenRequestValidator(
                   options,
                   issuerNameService,
                   authorizationCodeStore,
                   resourceOwnerValidator,
                   profile,
                   deviceCodeValidator,
                   backchannelAuthenticationRequestIdValidator,
                   aggregateExtensionGrantValidator,
                   customRequestValidator,
                   resourceValidator,
                   resourceStore,
                   refreshTokenService,
                   new TestEventService(),
                   new StubClock(),
                   TestLogger.Create <TokenRequestValidator>()));
    }