Пример #1
0
        internal static SamlResponse Parse(string xml, IConfiguration configuration)
        {
            var samlXml = new XmlDocument();

            samlXml.LoadXml(xml);

            try
            {
                XmlEncryption.DecryptXml(
                    (RSACng)configuration.SamlCertificate.GetRSAPrivateKey(),
                    samlXml,
                    new[] { "//*[local-name() = 'EncryptedID']", "//*[local-name() = 'EncryptedAttribute']" });
            }
            catch (Exception e)
            {
                throw new CommunicatorException("Error decrypting data. See inner exception for more details.", e);
            }

            var doc = ResponseType.Deserialize(samlXml.InnerXml);

            return(new SamlResponse(doc));
        }
Пример #2
0
        internal static SamlResponse Parse(string xml, IConfiguration configuration)
        {
            var samlXml = new XmlDocument();

            samlXml.LoadXml(xml);
            ICollection <SamlAttributesEncryptionKey> encryptedAttributesEncryptionKeys = new Collection <SamlAttributesEncryptionKey>();

            try
            {
                encryptedAttributesEncryptionKeys = XmlEncryption.DecryptXml(
                    configuration.SamlCertificate.PrivateKey as RSACryptoServiceProvider,
                    samlXml,
                    new[] { "//*[local-name() = 'EncryptedID']", "//*[local-name() = 'EncryptedAttribute']" });
            }
            catch (Exception e)
            {
                throw new CommunicatorException("Error decrypting data. See inner exception for more details.", e);
            }

            var doc = ResponseType.Deserialize(samlXml.InnerXml);

            return(new SamlResponse(doc, encryptedAttributesEncryptionKeys));
        }