コード例 #1
0
ファイル: Factory.cs プロジェクト: haoas/IdentityServer4
        public static TokenValidator CreateTokenValidator(ITokenHandleStore tokenStore = null, IUserService users = null)
        {
            if (users == null)
            {
                users = new TestUserService();
            }

            var clients = CreateClientStore();
            var options = TestIdentityServerOptions.Create();

            var accessor = new HttpContextAccessor();

            accessor.HttpContext = new DefaultHttpContext();
            var idsrvContext = new IdentityServerContext(accessor, options);

            var logger = new Logger <TokenValidator>(new LoggerFactory());

            var validator = new TokenValidator(
                options: options,
                clients: clients,
                tokenHandles: tokenStore,
                customValidator: new DefaultCustomTokenValidator(
                    users: users,
                    clients: clients,
                    logger: new Logger <DefaultCustomTokenValidator>(new LoggerFactory())),
                keyService: new DefaultSigningKeyService(options),
                logger: logger,
                context: idsrvContext);

            return(validator);
        }
コード例 #2
0
ファイル: Factory.cs プロジェクト: haoas/IdentityServer4
        public static TokenRequestValidator CreateTokenRequestValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes            = null,
            IAuthorizationCodeStore authorizationCodeStore = null,
            IRefreshTokenStore refreshTokens = null,
            IUserService userService         = null,
            IEnumerable <ICustomGrantValidator> customGrantValidators = null,
            ICustomRequestValidator customRequestValidator            = null,
            ScopeValidator scopeValidator = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (scopes == null)
            {
                scopes = new InMemoryScopeStore(TestScopes.Get());
            }

            if (userService == null)
            {
                userService = new TestUserService();
            }

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

            CustomGrantValidator aggregateCustomValidator;

            if (customGrantValidators == null)
            {
                aggregateCustomValidator = new CustomGrantValidator(new [] { new TestGrantValidator() }, new Logger <CustomGrantValidator>(new LoggerFactory()));
            }
            else
            {
                aggregateCustomValidator = new CustomGrantValidator(customGrantValidators, new Logger <CustomGrantValidator>(new LoggerFactory()));
            }

            if (refreshTokens == null)
            {
                refreshTokens = new InMemoryRefreshTokenStore();
            }

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(scopes, new LoggerFactory());
            }

            return(new TokenRequestValidator(
                       options,
                       authorizationCodeStore,
                       refreshTokens,
                       userService,
                       aggregateCustomValidator,
                       customRequestValidator,
                       scopeValidator,
                       new DefaultEventService(new LoggerFactory()),
                       new LoggerFactory()));
        }
コード例 #3
0
ファイル: Factory.cs プロジェクト: haoas/IdentityServer4
        public static TokenRequestValidator CreateTokenRequestValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes = null,
            IAuthorizationCodeStore authorizationCodeStore = null,
            IRefreshTokenStore refreshTokens = null,
            IUserService userService = null,
            IEnumerable<ICustomGrantValidator> customGrantValidators = null,
            ICustomRequestValidator customRequestValidator = null,
            ScopeValidator scopeValidator = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (scopes == null)
            {
                scopes = new InMemoryScopeStore(TestScopes.Get());
            }

            if (userService == null)
            {
                userService = new TestUserService();
            }

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

            CustomGrantValidator aggregateCustomValidator;
            if (customGrantValidators == null)
            {
                aggregateCustomValidator = new CustomGrantValidator(new [] { new TestGrantValidator() }, new Logger<CustomGrantValidator>(new LoggerFactory()));
            }
            else
            {
                aggregateCustomValidator = new CustomGrantValidator(customGrantValidators, new Logger<CustomGrantValidator>(new LoggerFactory()));
            }
                
            if (refreshTokens == null)
            {
                refreshTokens = new InMemoryRefreshTokenStore();
            }

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(scopes, new LoggerFactory());
            }

            return new TokenRequestValidator(
                options, 
                authorizationCodeStore, 
                refreshTokens, 
                userService, 
                aggregateCustomValidator, 
                customRequestValidator, 
                scopeValidator, 
                new DefaultEventService(new LoggerFactory()),
                new LoggerFactory());
        }
コード例 #4
0
ファイル: Factory.cs プロジェクト: haoas/IdentityServer4
        public static TokenValidator CreateTokenValidator(ITokenHandleStore tokenStore = null, IUserService users = null)
        {
            if (users == null)
            {
                users = new TestUserService();
            }

            var clients = CreateClientStore();
            var options = TestIdentityServerOptions.Create();

            var accessor = new HttpContextAccessor();
            accessor.HttpContext = new DefaultHttpContext();
            var idsrvContext = new IdentityServerContext(accessor, options);

            var logger = new Logger<TokenValidator>(new LoggerFactory());

            var validator = new TokenValidator(
                options: options,
                clients: clients,
                tokenHandles: tokenStore,
                customValidator: new DefaultCustomTokenValidator(
                    users: users,
                    clients: clients,
                    logger: new Logger<DefaultCustomTokenValidator>(new LoggerFactory())),
                keyService: new DefaultSigningKeyService(options),
                logger: logger,
                context: idsrvContext);

            return validator;
        }