Пример #1
0
        /// <summary>
        /// Verifies the integrity of the subscription request.  Code adapted from SprightlySoft SNSAutoConfirm sample.  License is:
        /// SprightlySoft SNS Auto Confirm.  License is reproduced above in SNSUtility
        /// </summary>
        /// <returns>True if the subscription matches</returns>
        public Boolean VerifySignature()
        {
            StringBuilder sbGenerated = new StringBuilder();

            sbGenerated.Append("Message\n").Append(Message).Append("\n");
            sbGenerated.Append("MessageId\n").Append(MessageId).Append("\n");

            if (!String.IsNullOrEmpty(Subject))
            {
                sbGenerated.Append("Subject\n").Append(Subject).Append("\n");
            }

            sbGenerated.Append("Timestamp\n").Append(Timestamp).Append("\n");
            sbGenerated.Append("TopicArn\n").Append(TopicArn).Append("\n");
            sbGenerated.Append("Type\n").Append(Type).Append("\n");

            return(SNSUtility.ValidateSignature(sbGenerated.ToString(), SigningCertLink, Signature));
        }
Пример #2
0
        /// <summary>
        /// Verifies the integrity of the subscription request.  Code adapted from SprightlySoft SNSAutoConfirm sample.  License is:
        /// SprightlySoft SNS Auto Confirm.  License is reproduced above in SNSUtility
        /// </summary>
        /// <returns>True if the subscription matches</returns>
        public Boolean VerifySignature()
        {
            // we can bypass the signature if the subscribe URL we are being asked to hit doesn't belong to AmazonAWS.
            Uri uri = new Uri(SubscribeLink);

            if (!uri.Host.EndsWith("amazonaws.com", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            StringBuilder sbGenerated = new StringBuilder();

            sbGenerated.Append("Message\n").Append(Message).Append("\n");
            sbGenerated.Append("MessageId\n").Append(MessageId).Append("\n");
            sbGenerated.Append("SubscribeURL\n").Append(SubscribeLink).Append("\n");
            sbGenerated.Append("Timestamp\n").Append(Timestamp).Append("\n");
            sbGenerated.Append("Token\n").Append(Token).Append("\n");
            sbGenerated.Append("TopicArn\n").Append(TopicArn).Append("\n");
            sbGenerated.Append("Type\n").Append(Type).Append("\n");

            return(SNSUtility.ValidateSignature(sbGenerated.ToString(), SigningCertLink, Signature));
        }