当前位置: 首页>>代码示例>>C#>>正文


C# ConfigurationManager.GetConfigurationAsync方法代码示例

本文整理汇总了C#中ConfigurationManager.GetConfigurationAsync方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationManager.GetConfigurationAsync方法的具体用法?C# ConfigurationManager.GetConfigurationAsync怎么用?C# ConfigurationManager.GetConfigurationAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigurationManager的用法示例。


在下文中一共展示了ConfigurationManager.GetConfigurationAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadOpenIdConnectConfigurationAsync

        private async Task LoadOpenIdConnectConfigurationAsync()
        {
            var discoAddress = _settings.Authority + "/.well-known/openid-configuration";

            var manager = new ConfigurationManager<OpenIdConnectConfiguration>(discoAddress);
            _config = await manager.GetConfigurationAsync();
        }
开发者ID:RobGibbens,项目名称:IdentityServer3.Samples,代码行数:7,代码来源:LoginWebView.xaml.cs

示例2: IdentityServerWrappedJwtHandler

        public IdentityServerWrappedJwtHandler(string authority, params string[] requiredScopes)
        {
            JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();

            var discoveryEndpoint = authority.EnsureTrailingSlash() + ".well-known/openid-configuration";
            var configurationManager = new ConfigurationManager<OpenIdConnectConfiguration>(discoveryEndpoint);

            var config = configurationManager.GetConfigurationAsync().Result;
            _signingCert = new X509Certificate2(Convert.FromBase64String(config.JsonWebKeySet.Keys.First().X5c.First()));
            _issuerName = config.Issuer;
            _requiredScopes = requiredScopes;
        }
开发者ID:ryanmar,项目名称:IdentityServer3.Samples,代码行数:12,代码来源:IdentityServerWrappedJwtHandler.cs

示例3: JsonWebTokenAuthProvider

        /// <summary>
        /// Creates a new JsonWebToken Auth Provider
        /// </summary>
        /// <param name="discoveryEndpoint">aThe url to get the configuration informaion from.. (er "http://localhost:22530/" + ".well-known/openid-configuration")</param>
        /// <param name="audience">The client for openID (eg js_oidc)</param>

        public JsonWebTokenAuthProvider(string discoveryEndpoint, string audience = null)
        {
            Provider = Name;
            AuthRealm = Realm;
            Audience = audience;
            
            var configurationManager = new ConfigurationManager<OpenIdConnectConfiguration>(discoveryEndpoint);

            var config =  configurationManager.GetConfigurationAsync().Result;

            Certificate = new X509Certificate2(Convert.FromBase64String(config.JsonWebKeySet.Keys.First().X5c.First()));
            Issuer = config.Issuer;
        }
开发者ID:Estyn,项目名称:ServiceStackJWT,代码行数:19,代码来源:JsonWebTokenAuthProvider.cs

示例4: UseDiscovery

        private static IAppBuilder UseDiscovery(this IAppBuilder app, JwtTokenValidationOptions options)
        {
            var authority = options.Authority;

            if (!authority.EndsWith("/"))
            {
                authority += "/";
            }

            authority += ".well-known/openid-configuration";
            var configuration = new ConfigurationManager<OpenIdConnectConfiguration>(authority);

            var result = configuration.GetConfigurationAsync().Result;
            var x5c = result.JsonWebKeySet.Keys.First().X5c.First();

            return app.ConfigureMiddleware(result.Issuer, new X509Certificate2(Convert.FromBase64String(x5c)), options.AuthenticationType);
        }
开发者ID:eugv86,项目名称:Thinktecture.IdentityServer.v3.Samples,代码行数:17,代码来源:SelfContainedTokenValidationExtensions.cs

示例5: ConfigurationManager_GetSets

        public void ConfigurationManager_GetSets()
        {
            ConfigurationManager<OpenIdConnectConfiguration> configManager = new ConfigurationManager<OpenIdConnectConfiguration>("OpenIdConnectMetadata.json");
            Type type = typeof(ConfigurationManager<OpenIdConnectConfiguration>);
            PropertyInfo[] properties = type.GetProperties();
            if (properties.Length != 2)
                Assert.Fail("Number of properties has changed from 2 to: " + properties.Length + ", adjust tests");

            TimeSpan defaultAutomaticRefreshInterval = ConfigurationManager<OpenIdConnectConfiguration>.DefaultAutomaticRefreshInterval;
            TimeSpan defaultRefreshInterval = ConfigurationManager<OpenIdConnectConfiguration>.DefaultRefreshInterval;

            GetSetContext context =
                new GetSetContext
                {
                    PropertyNamesAndSetGetValue = new List<KeyValuePair<string, List<object>>> 
                    { 
                        new KeyValuePair<string, List<object>>("AutomaticRefreshInterval", new List<object>{defaultAutomaticRefreshInterval, TimeSpan.FromHours(1), TimeSpan.FromHours(10)}),
                        new KeyValuePair<string, List<object>>("RefreshInterval", new List<object>{defaultRefreshInterval, TimeSpan.FromHours(1), TimeSpan.FromHours(10)}),
                    },
                    Object = configManager,
                };

            TestUtilities.GetSet(context);
            TestUtilities.AssertFailIfErrors(MethodInfo.GetCurrentMethod().Name, context.Errors);

            TestUtilities.SetGet(configManager, "AutomaticRefreshInterval", TimeSpan.FromMilliseconds(1), ExpectedException.ArgumentOutOfRangeException(substringExpected: "IDX10107:"));
            TestUtilities.SetGet(configManager, "RefreshInterval", TimeSpan.FromMilliseconds(1), ExpectedException.ArgumentOutOfRangeException(substringExpected: "IDX10106:"));
            TestUtilities.SetGet(configManager, "RefreshInterval", Timeout.InfiniteTimeSpan, ExpectedException.ArgumentOutOfRangeException(substringExpected: "IDX10106:"));

            // AutomaticRefreshInterval interval should return same config.
            OpenIdConnectConfiguration configuration = configManager.GetConfigurationAsync().Result;
            TestUtilities.SetField(configManager, "_metadataAddress", "OpenIdConnectMetadata2.json");
            OpenIdConnectConfiguration configuration2 = configManager.GetConfigurationAsync().Result;
            Assert.IsTrue(IdentityComparer.AreEqual<OpenIdConnectConfiguration>(configuration, configuration2));
            Assert.IsTrue(object.ReferenceEquals(configuration, configuration2));

            // AutomaticRefreshInterval should pick up new bits.
            configManager = new ConfigurationManager<OpenIdConnectConfiguration>("OpenIdConnectMetadata.json");
            TestUtilities.SetField(configManager, "_automaticRefreshInterval", TimeSpan.FromMilliseconds(1));
            configuration = configManager.GetConfigurationAsync().Result;
            Thread.Sleep(1);
            TestUtilities.SetField(configManager, "_metadataAddress", "OpenIdConnectMetadata2.json");
            configuration2 = configManager.GetConfigurationAsync().Result;
            Assert.IsFalse(IdentityComparer.AreEqual<OpenIdConnectConfiguration>(configuration, configuration2));
            Assert.IsFalse(object.ReferenceEquals(configuration, configuration2));

            // RefreshInterval is set to MaxValue
            configManager = new ConfigurationManager<OpenIdConnectConfiguration>("OpenIdConnectMetadata.json");
            configuration = configManager.GetConfigurationAsync().Result;
            configManager.RefreshInterval = TimeSpan.MaxValue;
            TestUtilities.SetField(configManager, "_metadataAddress", "OpenIdConnectMetadata2.json");
            configuration2 = configManager.GetConfigurationAsync().Result;
            Assert.IsTrue(IdentityComparer.AreEqual<OpenIdConnectConfiguration>(configuration, configuration2));
            Assert.IsTrue(object.ReferenceEquals(configuration, configuration2));

            // Refresh should have no effect
            configManager = new ConfigurationManager<OpenIdConnectConfiguration>("OpenIdConnectMetadata.json");
            configuration = configManager.GetConfigurationAsync().Result;
            configManager.RefreshInterval = TimeSpan.FromHours(10);
            configManager.RequestRefresh();
            configuration2 = configManager.GetConfigurationAsync().Result;
            Assert.IsTrue(IdentityComparer.AreEqual<OpenIdConnectConfiguration>(configuration, configuration2));
            Assert.IsTrue(object.ReferenceEquals(configuration, configuration2));

            // Refresh should force pickup of new config
            configManager = new ConfigurationManager<OpenIdConnectConfiguration>("OpenIdConnectMetadata.json");
            configuration = configManager.GetConfigurationAsync().Result;
            TestUtilities.SetField(configManager, "_refreshInterval", TimeSpan.FromMilliseconds(1));
            Thread.Sleep(1);
            configManager.RequestRefresh();
            TestUtilities.SetField(configManager, "_metadataAddress", "OpenIdConnectMetadata2.json");
            configuration2 = configManager.GetConfigurationAsync().Result;
            Assert.IsFalse(object.ReferenceEquals(configuration, configuration2));
            Assert.IsFalse(IdentityComparer.AreEqual<OpenIdConnectConfiguration>(configuration, configuration2));

            // Refresh set to MaxValue
            configManager.RefreshInterval = TimeSpan.MaxValue;
            configuration = configManager.GetConfigurationAsync().Result;
            Assert.IsTrue(object.ReferenceEquals(configuration, configuration2));
            Assert.IsTrue(IdentityComparer.AreEqual<OpenIdConnectConfiguration>(configuration, configuration2));
        }
开发者ID:vebin,项目名称:azure-activedirectory-identitymodel-extensions-for-dotnet,代码行数:81,代码来源:ConfigurationManagerTests.cs

示例6: ConfigurationManager_Publics

 public void ConfigurationManager_Publics()
 {
     ConfigurationManager<OpenIdConnectConfiguration> configManager = new ConfigurationManager<OpenIdConnectConfiguration>("OpenIdConnectMetadata.json");
     OpenIdConnectConfiguration config = configManager.GetConfigurationAsync(CancellationToken.None).Result;
 }
开发者ID:vebin,项目名称:azure-activedirectory-identitymodel-extensions-for-dotnet,代码行数:5,代码来源:ConfigurationManagerTests.cs


注:本文中的ConfigurationManager.GetConfigurationAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。