private FederationProviderInfo ParseFederationProviderInfo(XDocument xdoc, string fpDomainName) { foreach (XElement item in xdoc.Root.Elements("FP")) { if (item.Attribute("DomainName") != null && string.Equals(item.Attribute("DomainName").Value, fpDomainName, StringComparison.OrdinalIgnoreCase)) { XElement elementAtPath = IdcrlUtility.GetElementAtPath(item, IdcrlMessageConstants.URL, IdcrlMessageConstants.GETUSERREALM); XElement elementAtPath2 = IdcrlUtility.GetElementAtPath(item, IdcrlMessageConstants.URL, IdcrlMessageConstants.RST2); XElement elementAtPath3 = IdcrlUtility.GetElementAtPath(item, IdcrlMessageConstants.URL, IdcrlMessageConstants.ENTITYID); if (elementAtPath != null && elementAtPath2 != null && elementAtPath3 != null) { this._Logger?.LogError("Find federation provider information for federation provider domain name {0}. UserRealmServiceUrl={1}, SecurityTokenServiceUrl={2}, FederationTokenIssuer={3}", fpDomainName, elementAtPath.Value, elementAtPath2.Value, elementAtPath3.Value); var federationProviderInfo = new FederationProviderInfo { UserRealmServiceUrl = elementAtPath.Value, SecurityTokenServiceUrl = elementAtPath2.Value, FederationTokenIssuer = elementAtPath3.Value }; return(federationProviderInfo); } this._Logger?.LogError("Cannot get the user realm service url or security token service url for federation provider {0}", fpDomainName); throw IdcrlAuth.CreateIdcrlException(-2147186646); } } this._Logger?.LogError("Cannot find federation provider information for federation domain {0}", fpDomainName); throw IdcrlAuth.CreateIdcrlException(-2147186646); }
public void Put(string domainname, FederationProviderInfo value) { lock (this.m_lock) { this.m_cache[domainname] = new FederationProviderInfoCacheEntry { Value = value, Expires = DateTime.UtcNow.AddMinutes(30.0) }; } }
public bool TryGetValue(string domainname, out FederationProviderInfo value) { lock (this.m_lock) { if (this.m_cache.TryGetValue(domainname, out var federationProviderInfoCacheEntry) && federationProviderInfoCacheEntry.Expires > DateTime.UtcNow) { value = federationProviderInfoCacheEntry.Value; return(true); } } value = null; return(false); }
private async Task InitFederationProviderInfoForUserAsync(string username) { int pos = username.IndexOf('@'); if (pos >= 0 && pos != username.Length - 1) { string domainname = username.Substring(pos + 1); FederationProviderInfo federationProviderInfo = await this.GetFederationProviderInfoAsync(domainname); if (federationProviderInfo != null) { this.m_userRealmServiceUrl = federationProviderInfo.UserRealmServiceUrl; this.m_securityTokenServiceUrl = federationProviderInfo.SecurityTokenServiceUrl; this.m_federationTokenIssuer = federationProviderInfo.FederationTokenIssuer; } this._Logger?.LogDebug("UserName={0}, UserRealmServiceUrl={1}, SecurityTokenServiceUrl={1}, FederationTokenIssuer={2}", username, this.m_userRealmServiceUrl, this.m_securityTokenServiceUrl, this.m_federationTokenIssuer); return; } throw new ArgumentException(nameof(username)); }