Ejemplo n.º 1
0
        internal Saml2FormBinding(IdentityHttpRequest request, BindingDirection bindingDirection)
        {
            this.BindingDirection = bindingDirection;
            string samlEncoded = this.BindingDirection switch
            {
                BindingDirection.Request => request.Form[Saml2Names.RequestParameterName],
                BindingDirection.Response => request.Form[Saml2Names.ResponseParameterName],
                _ => throw new NotImplementedException(),
            };
            var samlRequestDecoded = DecodeSaml(samlEncoded);

            this.Document = new XmlDocument();
            this.Document.LoadXml(samlRequestDecoded);

            this.HasSignature = X509XmlSigner.HasSignature(this.Document.DocumentElement);
            if (this.HasSignature)
            {
                this.SignatureAlgorithm = X509XmlSigner.GetSignatureAlgorithm(this.Document.DocumentElement);
                this.DigestAlgorithm    = X509XmlSigner.GetDigestAlgorithm(this.Document.DocumentElement);
            }

            this.HasEncryption = X509XmlEncryptor.HasEncryptedDataElements(this.Document.DocumentElement);
            if (this.HasEncryption)
            {
                this.EncryptionAlgorithm = X509XmlEncryptor.GetEncryptionAlgorithm(this.Document.DocumentElement);
            }
        }
Ejemplo n.º 2
0
        internal Saml2FormBinding(Saml2Document document, XmlSignatureAlgorithmType?signatureAlgorithm, XmlDigestAlgorithmType?digestAlgorithm, XmlEncryptionAlgorithmType?encryptionAlgorithm)
        {
            this.BindingDirection    = document.BindingDirection;
            this.SignatureAlgorithm  = signatureAlgorithm;
            this.DigestAlgorithm     = digestAlgorithm;
            this.EncryptionAlgorithm = encryptionAlgorithm;

            this.Document = document.GetSaml();

            this.HasSignature = X509XmlSigner.HasSignature(this.Document.DocumentElement);
            if (this.HasSignature)
            {
                this.SignatureAlgorithm = X509XmlSigner.GetSignatureAlgorithm(this.Document.DocumentElement);
                this.DigestAlgorithm    = X509XmlSigner.GetDigestAlgorithm(this.Document.DocumentElement);
            }

            this.HasEncryption = X509XmlEncryptor.HasEncryptedDataElements(this.Document.DocumentElement);
            if (this.HasEncryption)
            {
                this.EncryptionAlgorithm = X509XmlEncryptor.GetEncryptionAlgorithm(this.Document.DocumentElement);
            }
        }