public static AuthServer GetLinkedInAuthServer() { AuthServer[] authServerByType = OAuthConfigHelper.GetAuthServerByType(AuthServerType.LinkedIn); if (authServerByType.Length == 0) { throw new AuthServerNotFoundException(DirectoryStrings.ErrorAuthServerTypeNotFound(AuthServerType.LinkedIn.ToString())); } return(authServerByType[0]); }
public static OrganizationId ResolveOrganizationByRealm(string realm) { if (string.IsNullOrEmpty(realm)) { throw new ArgumentNullException("realm"); } OrganizationId result = null; if (OAuthConfigHelper.isMultiTenancyEnabled) { try { Guid externalDirectoryOrganizationId; ADSessionSettings adsessionSettings; if (Guid.TryParse(realm, out externalDirectoryOrganizationId)) { adsessionSettings = ADSessionSettings.FromExternalDirectoryOrganizationId(externalDirectoryOrganizationId); } else { SmtpDomain smtpDomain; if (!SmtpDomain.TryParse(realm, out smtpDomain)) { throw new RealmFormatInvalidException(DirectoryStrings.ErrorRealmFormatInvalid(realm)); } adsessionSettings = ADSessionSettings.FromTenantAcceptedDomain(realm); } return(adsessionSettings.CurrentOrganizationId); } catch (CannotResolveExternalDirectoryOrganizationIdException innerException) { throw new RealmNotFoundException(DirectoryStrings.ErrorRealmNotFound(realm), innerException); } catch (CannotResolveTenantNameException innerException2) { throw new RealmNotFoundException(DirectoryStrings.ErrorRealmNotFound(realm), innerException2); } } result = OrganizationId.ForestWideOrgId; IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 306, "ResolveOrganizationByRealm", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\OAuth\\OAuthConfigHelper.cs"); if (tenantOrTopologyConfigurationSession.GetAcceptedDomainByDomainName(realm) == null) { AuthConfig authConfig = AuthConfig.Read(tenantOrTopologyConfigurationSession); if (!realm.Equals(authConfig.Realm)) { if (OAuthConfigHelper.GetAuthServers().FirstOrDefault((AuthServer server) => realm.Equals(server.Realm, StringComparison.OrdinalIgnoreCase)) == null) { throw new RealmNotFoundException(DirectoryStrings.ErrorRealmNotFound(realm)); } } } return(result); }
public static PartnerApplication GetPartnerApplication(OrganizationId organizationId, string applicationIdentifier) { if (string.IsNullOrEmpty(applicationIdentifier)) { throw new ArgumentNullException("applicationIdentifier"); } if (organizationId == null) { throw new ArgumentNullException("organizationId"); } ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId); PartnerApplication partnerApplication = OAuthConfigHelper.GetPartnerApplication(sessionSettings, applicationIdentifier); if (partnerApplication == null && !organizationId.Equals(OrganizationId.ForestWideOrgId)) { ADSessionSettings.FromRootOrgScopeSet(); partnerApplication = OAuthConfigHelper.GetPartnerApplication(sessionSettings, applicationIdentifier); } if (partnerApplication == null) { throw new PartnerApplicationNotFoundException(DirectoryStrings.ErrorPartnerApplicationNotFound(applicationIdentifier)); } return(partnerApplication); }
public static X509Certificate2 GetNextSigningKey() { return(OAuthConfigHelper.GetSigningKey(AuthConfigSchema.NextCertificateThumbprint)); }
public static AuthServer[] GetAuthServers() { return(OAuthConfigHelper.GetAuthServerByType(AuthServerType.MicrosoftACS)); }