/// <summary> /// Initializes a new instance of the <see cref="Symplified.Auth.Saml20Authenticator"/> class. /// </summary> /// <param name="spName">Service Provider name.</param> /// <param name="idpMetadata">Identity Provider metadata.</param> public Saml20Authenticator (string spName, Saml20MetadataDocument idpMetadata) : base (PLACEHOLDER_URI, PLACEHOLDER_URI) { _spName = (string.IsNullOrEmpty (spName)) ? "symplified-mobile-sp" : spName; _idpMetadata = idpMetadata; Saml20AuthnRequest authnRequest = Saml20AuthnRequest.GetDefault (_spName); byte[] xmlBytes = UTF8Encoding.Default.GetBytes (authnRequest.GetXml ().OuterXml); string base64XmlString = SamlAccount.ToBase64ForUrlString (xmlBytes); initialUrl = new Uri ( String.Format ( "{0}&SAMLRequest={1}", _idpMetadata.SSOEndpoint (SAMLBinding.POST).Url, base64XmlString ) ); }
/// <summary> /// Initializes a new instance of the <see cref="Symplified.Auth.Saml20Authenticator"/> class. /// </summary> /// <param name="spName">Service Provider name.</param> /// <param name="idpMetadata">Identity Provider metadata.</param> public Saml20Authenticator (string spName, Saml20MetadataDocument idpMetadata) : base (PLACEHOLDER_URI, PLACEHOLDER_URI) { _spName = (string.IsNullOrEmpty (spName)) ? "symplified-mobile-sp" : spName; _idpMetadata = idpMetadata; var url = _idpMetadata.SSOEndpoint (SAMLBinding.POST).Url; var separator = url.Contains ("?") ? "&" : "?"; var authnRequest = Saml20AuthnRequest.GetDefault (_spName); var builder = new HttpRedirectBindingBuilder (); builder.Request = authnRequest.GetXml ().OuterXml; initialUrl = new Uri ( String.Format ( "{0}{1}{2}", url, separator, builder.ToQuery() ) ); }