public OpenIDProviderData(OpenIDProviderElement opEntry, IRPOptions options) { EntityId = opEntry.EntityId; LoadOPInformation(opEntry); LoadClientInformation(opEntry, options); }
public static OpenIDProviderData GetOpenIDProviderData(string entityId, OpenIDProviderElement opEntry, IRPOptions options) { lock (providers) { if (providers.ContainsKey(entityId)) { return providers[entityId]; } OpenIDProviderData op = new OpenIDProviderData(opEntry, options); providers.Add(entityId, op); return op; } }
private void LoadClientInformation(OpenIDProviderElement opEntry, IRPOptions options) { SelfRegistered = opEntry.SelfRegistration; if (!SelfRegistered) { foreach (string value in new List<string>() { opEntry.ClientId, opEntry.ClientSecret }) { if (string.IsNullOrEmpty(value)) { throw new ArgumentException("Missign one requred value for configuration. When configuring client without dynamic registration both clientid and clientsecred must be specified."); } } ClientInformation = new OIDCClientInformation() { ClientId = opEntry.ClientId, ClientSecret = opEntry.ClientSecret, TokenEndpointAuthMethod = "client_secret_basic" }; } }
private void LoadOPInformation(OpenIDProviderElement opEntry) { Sign = opEntry.Sign; Encrypt = opEntry.Encrypt; if (!String.IsNullOrEmpty(opEntry.OPIssuer)) { OpenIdRelyingParty rp = new OpenIdRelyingParty(); ProviderMatadata = rp.ObtainProviderInformation(opEntry.OPIssuer, opEntry.OPIssuer); } else { foreach (string value in new List<string>() { opEntry.AuthorizationEndpoint, opEntry.TokenEndpoint, opEntry.UserinfoEndpoint }) { if (string.IsNullOrEmpty(value)) { throw new ArgumentException("Missign one requred value for configuration. When configuring rp without isser discovery, all these fields must be specified: authorizationEndpoint, tokenEndpoint, userinfoEndpoint."); } } ProviderMatadata = new OIDCProviderMetadata() { AuthorizationEndpoint = opEntry.AuthorizationEndpoint, TokenEndpoint = opEntry.TokenEndpoint, UserinfoEndpoint = opEntry.UserinfoEndpoint, }; if (!string.IsNullOrEmpty(opEntry.RegistrationEndpoint)) { ProviderMatadata.RegistrationEndpoint = opEntry.RegistrationEndpoint; } } }