Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 3
0
        internal ErrorResponse(AcquirerErrorRes errRes)
        {
            ErrorCode       = errRes.Error.errorCode;
            ErrorMessage    = errRes.Error.errorMessage;
            ErrorDetails    = errRes.Error.errorDetail;
            SuggestedAction = errRes.Error.suggestedAction;
            ConsumerMessage = errRes.Error.consumerMessage;
            Exception       = null;


            var samlXml = errRes.Error.container?.Any[0].OuterXml;

            if (string.IsNullOrWhiteSpace(samlXml))
            {
                return;
            }

            var responseType = ResponseType.Deserialize(samlXml);

            if (responseType.Status != null)
            {
                AdditionalInformation = new SamlStatus(responseType.Status.StatusMessage, responseType.Status?.StatusCode?.Value, responseType.Status?.StatusCode?.StatusCode?.Value);
            }
        }