/// <summary> /// Construct the options from the given configuration section /// </summary> /// <param name="configSection"></param> public SPOptions(KentorAuthServicesSection configSection) { if (configSection == null) { throw new ArgumentNullException(nameof(configSection)); } systemIdentityModelIdentityConfiguration = new IdentityConfiguration(true); ReturnUrl = configSection.ReturnUrl; MetadataCacheDuration = configSection.Metadata.CacheDuration; MetadataValidDuration = configSection.Metadata.ValidUntil; WantAssertionsSigned = configSection.Metadata.WantAssertionsSigned; ValidateCertificates = configSection.ValidateCertificates; DiscoveryServiceUrl = configSection.DiscoveryServiceUrl; EntityId = configSection.EntityId; ModulePath = configSection.ModulePath; PublicOrigin = configSection.PublicOrigin; Organization = configSection.Organization; AuthenticateRequestSigningBehavior = configSection.AuthenticateRequestSigningBehavior; NameIdPolicy = new Saml2NameIdPolicy( configSection.NameIdPolicyElement.AllowCreate, configSection.NameIdPolicyElement.Format); RequestedAuthnContext = new Saml2RequestedAuthnContext(configSection.RequestedAuthnContext); configSection.ServiceCertificates.RegisterServiceCertificates(this); foreach (var acs in configSection.AttributeConsumingServices) { AttributeConsumingServices.Add(acs); } foreach (var contact in configSection.Contacts) { Contacts.Add(contact); } }
public Saml2AuthenticationRequest(XmlElement xml, string relayState) { ReadBaseProperties(xml); RelayState = relayState; var AssertionConsumerServiceUriString = xml.Attributes["AssertionConsumerServiceURL"].GetValueIfNotNull(); if (AssertionConsumerServiceUriString != null) { AssertionConsumerServiceUrl = new Uri(AssertionConsumerServiceUriString); } var node = xml["NameIDPolicy", Saml2Namespaces.Saml2PName]; if (node != null) { var fullFormat = node.Attributes["Format"].GetValueIfNotNull(); var format = fullFormat?.Split(':').LastOrDefault(); NameIdFormat nameIdFormat = NameIdFormat.NotConfigured; if (format != null) { Enum.TryParse(format, true, out nameIdFormat); } bool?allowCreate = null; var allowCreateStr = node.Attributes["AllowCreate"].GetValueIfNotNull(); if (allowCreateStr != null) { allowCreate = bool.Parse(allowCreateStr); } NameIdPolicy = new Saml2NameIdPolicy(allowCreate, nameIdFormat); } }
public Saml2AuthenticationRequest(XmlElement xml, string relayState) { ReadBaseProperties(xml); RelayState = relayState; var AssertionConsumerServiceUriString = xml.Attributes["AssertionConsumerServiceURL"].GetValueIfNotNull(); if (AssertionConsumerServiceUriString != null) { AssertionConsumerServiceUrl = new Uri(AssertionConsumerServiceUriString); } var node = xml["NameIDPolicy", Saml2Namespaces.Saml2PName]; if (node != null) { var fullFormat = node.Attributes["Format"].GetValueIfNotNull(); var format = fullFormat?.Split(':').LastOrDefault(); NameIdFormat nameIdFormat = NameIdFormat.NotConfigured; if (format != null) { Enum.TryParse(format, true, out nameIdFormat); } bool? allowCreate = null; var allowCreateStr = node.Attributes["AllowCreate"].GetValueIfNotNull(); if (allowCreateStr != null) { allowCreate = bool.Parse(allowCreateStr); } NameIdPolicy = new Saml2NameIdPolicy(allowCreate, nameIdFormat); } }