Exemplo n.º 1
0
        public Saml2AuthnResponse(Saml2Configuration config) : base(config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            Destination = config.SingleSignOnDestination;

            if (config.DecryptionCertificate != null)
            {
                DecryptionCertificate = config.DecryptionCertificate;
                if (config.DecryptionCertificate.GetSamlRSAPrivateKey() == null)
                {
                    throw new ArgumentException("No RSA Private Key present in Decryption Certificate or missing private key read credentials.");
                }
            }
            if (config.EncryptionCertificate != null)
            {
                EncryptionCertificate = config.EncryptionCertificate;
                if (config.EncryptionCertificate.GetRSAPublicKey() == null)
                {
                    throw new ArgumentException("No RSA Public Key present in Encryption Certificate.");
                }
            }
            Saml2SecurityTokenHandler = Saml2ResponseSecurityTokenHandler.GetSaml2SecurityTokenHandler(IdentityConfiguration);
        }
Exemplo n.º 2
0
 public Saml2AuthnResponse(X509Certificate2 decryptionCertificate = null)
 {
     if (decryptionCertificate != null)
     {
         DecryptionCertificate = decryptionCertificate;
         if (decryptionCertificate.PrivateKey == null)
         {
             throw new ArgumentException("No Private Key present in Decryption Certificate or missing private key read credentials.");
         }
         if (!(decryptionCertificate.PrivateKey is RSA))
         {
             throw new ArgumentException("The Private Key present in Decryption Certificate must be RSA.");
         }
     }
     Saml2SecurityTokenHandler = Saml2ResponseSecurityTokenHandler.GetSaml2SecurityTokenHandler();
 }
        private static Saml2AuthnResponse GetSaml2AuthnResponse(Saml2AuthenticationOptions options)
        {
            var handler = new Saml2ResponseSecurityTokenHandler
            {
                Configuration = new SecurityTokenHandlerConfiguration
                {
                    SaveBootstrapContext      = false,
                    AudienceRestriction       = GetAudienceRestriction(options),
                    IssuerNameRegistry        = new Saml2ResponseIssuerNameRegistry(),
                    CertificateValidationMode = X509CertificateValidationMode.None,
                    RevocationMode            = X509RevocationMode.NoCheck,
                    CertificateValidator      = options.TokenValidationParameters.CertificateValidator ?? X509CertificateValidator.None,
                    DetectReplayedTokens      = false,
                },
                SamlSecurityTokenRequirement = { NameClaimType = ClaimTypes.NameIdentifier }
            };

            return(new InternalSaml2AuthnResponse(handler));
        }
Exemplo n.º 4
0
 public Saml2IdPInitiatedAuthnResponse()
 {
     Saml2SecurityTokenHandler = Saml2ResponseSecurityTokenHandler.GetSaml2SecurityTokenHandler();
 }