예제 #1
0
        public static string GetAssertion(
            string issuer, string subject, string certLocation, string certPassword,
            Dictionary <string, string> attributes)
        {
            // Create certificate from file. It must contain private key!
            X509Certificate2 cert = new X509Certificate2(certLocation, certPassword);

            // The private key contained in the certificate will be used to sign the token.
            X509AsymmetricSecurityKey signingKey = new X509AsymmetricSecurityKey(cert);

            SecurityKeyIdentifier ski = new SecurityKeyIdentifier(new
                                                                  X509ThumbprintKeyIdentifierClause(cert));

            SamlAssertion assertion =
                SamlHelper.CreateSamlAssertion(issuer, subject, subject, attributes);

            assertion.SigningCredentials = new
                                           SigningCredentials(signingKey, SecurityAlgorithms.RsaSha1Signature,
                                                              SecurityAlgorithms.Sha1Digest, ski);
            return(SamlHelper.SerializeToken(assertion));
        }
예제 #2
0
 public static string GetAssertion(
     string issuer, string subject, Dictionary <string, string> attributes)
 {
     return(SamlHelper.SerializeToken(
                SamlHelper.CreateSamlAssertion(issuer, subject, subject, attributes)));
 }