Beispiel #1
0
        /// <summary>
        /// Gets the bearer assertion authorization grant parameters. This is typically
        /// used to request an OAuth access token.
        /// </summary>
        /// <returns>The URL-encoded assertion parameters.</returns>
        public string GetBearerAssertionAuthorizationGrantParams()
        {
            StringBuilder args = new StringBuilder();

            args.AppendFormat("grant_type={0}", HttpUtility.UrlEncode(AUTHORIZATION_GRANT_TYPE));

            string base64Assertion = SamlAccount.ToBase64ForUrlString(
                Encoding.UTF8.GetBytes(_saml20Assertion.XmlAssertion.OuterXml)
                );

            args.AppendFormat("&assertion={0}", base64Assertion);
            return(args.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// Gets the bearer assertion client authentication parameters.
        /// </summary>
        /// <returns>The URL-encoded client assertion parameters.</returns>
        public string GetBearerAssertionClientAuthenticationParams()
        {
            StringBuilder args = new StringBuilder();

            args.AppendFormat("client_assertion_type={0}", HttpUtility.UrlEncode(CLIENT_ASSERTION_TYPE));

            string base64Assertion = SamlAccount.ToBase64ForUrlString(
                Encoding.UTF8.GetBytes(_saml20Assertion.XmlAssertion.OuterXml)
                );

            args.AppendFormat("&client_assertion={0}", base64Assertion);

            return(args.ToString());
        }
        /// <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
                    )
                );
        }