示例#1
0
        public static AuthorizeRequestValidator CreateAuthorizeRequestValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes = null,
            IClientStore clients = null,
            IProfileService profile = null,
            ICustomRequestValidator customValidator = null,
            IRedirectUriValidator uriValidator = null,
            ScopeValidator scopeValidator = null,
            IDictionary<string, object> environment = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

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

            if (clients == null)
            {
                clients = new InMemoryClientStore(TestClients.Get());
            }

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

            if (uriValidator == null)
            {
                uriValidator = new StrictRedirectUriValidator();
            }

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

            var sessionCookie = new SessionCookie(IdentityServerContextHelper.Create(null, options));

            return new AuthorizeRequestValidator(
                options,
                clients,
                customValidator,
                uriValidator,
                scopeValidator,
                sessionCookie,
                new Logger<AuthorizeRequestValidator>(new LoggerFactory())
            );
        }
        public void CanSerializeAndDeserializeAClient()
        {
            var client = new Client
            {
                ClientId = "123",
                Enabled = true,
                AbsoluteRefreshTokenLifetime = 5,
                AccessTokenLifetime = 10,
                AccessTokenType = AccessTokenType.Jwt,
                AllowRememberConsent = true,
                RedirectUris = new List<string> { "http://foo.com" }
            };
            var clientStore = new InMemoryClientStore(new Client[] { client });
            var converter = new ClientConverter(clientStore);

            var settings = new JsonSerializerSettings();
            settings.Converters.Add(converter);
            var json = JsonConvert.SerializeObject(client, settings);

            var result = JsonConvert.DeserializeObject<Client>(json, settings);
            Assert.Same(client, result);
        }