コード例 #1
0
        private async static Task UpdateAuthorityWithPreferredNetworkHostAsync(AuthenticationRequestParameters requestParameters)
        {
            InstanceDiscoveryMetadataEntry metadata = await
                                                      requestParameters.RequestContext.ServiceBundle.InstanceDiscoveryManager.GetMetadataEntryAsync(
                requestParameters.AuthorityInfo.CanonicalAuthority,
                requestParameters.RequestContext)
                                                      .ConfigureAwait(false);

            requestParameters.Authority = Authority.CreateAuthorityWithEnvironment(
                requestParameters.AuthorityInfo,
                metadata.PreferredNetwork);
        }
        public async Task RunInstanceDiscoveryAndValidationAsync()
        {
            if (!_instanceDiscoveryAndValidationExecuted)
            {
                // This will make a network call unless instance discovery is cached, but this OK
                // GetAccounts and AcquireTokenSilent do not need this
                _metadata = await
                            _requestContext.ServiceBundle.InstanceDiscoveryManager.GetMetadataEntryAsync(
                    _initialAuthority.AuthorityInfo,
                    _requestContext)
                            .ConfigureAwait(false);

                _currentAuthority = Authority.CreateAuthorityWithEnvironment(
                    _initialAuthority.AuthorityInfo,
                    _metadata.PreferredNetwork);

                // We can only validate the initial environment, not regional environments
                await ValidateAuthorityAsync(_initialAuthority).ConfigureAwait(false);

                _instanceDiscoveryAndValidationExecuted = true;
            }
        }
コード例 #3
0
 public bool TryAddValue(string host, InstanceDiscoveryMetadataEntry instanceDiscoveryMetadataEntry)
 {
     return(s_cache.TryAdd(host, instanceDiscoveryMetadataEntry));
 }
コード例 #4
0
 public bool TryGetValue(string host, out InstanceDiscoveryMetadataEntry instanceDiscoveryMetadataEntry)
 {
     return(s_cache.TryGetValue(host, out instanceDiscoveryMetadataEntry));
 }