Пример #1
0
        public void AddPermission(SnsTopicBase snsTopic)
        {
            Client.SetQueueAttributes(
                new SetQueueAttributesRequest{
                    QueueUrl = Url,
                    Attributes = new Dictionary<string,string>{ {"Policy", GetQueueSubscriptionPilocy(snsTopic) } }
                });

            Log.Info(string.Format("Added Queue permission for SNS topic to publish to Queue: {0}, Topic: {1}", Arn, snsTopic.Arn));
        }
Пример #2
0
        public void AddPermission(SnsTopicBase snsTopic)
        {
            Client.SetQueueAttributes(
                new SetQueueAttributesRequest {
                QueueUrl   = Url,
                Attributes = new Dictionary <string, string> {
                    { "Policy", GetQueueSubscriptionPolicy(snsTopic) }
                }
            });

            Log.Info(string.Format("Added Queue permission for SNS topic to publish to Queue: {0}, Topic: {1}", Arn, snsTopic.Arn));
        }
Пример #3
0
        public bool HasPermission(SnsTopicBase snsTopic)
        {
            var policyResponse = Client.GetQueueAttributes(
                new GetQueueAttributesRequest {
                QueueUrl       = Url,
                AttributeNames = new List <string> {
                    "Policy"
                }
            });

            if (string.IsNullOrEmpty(policyResponse.Policy))
            {
                return(false);
            }

            return(policyResponse.Policy.Contains(snsTopic.Arn));
        }
Пример #4
0
        protected string GetQueueSubscriptionPolicy(SnsTopicBase topic)
        {
            return(@"{
                                                      ""Version"": ""2012-10-17"",
                                                      ""Id"": ""Sns_Subsciption_Policy"",
                                                      ""Statement"": 
                                                        {
                                                           ""Sid"":""Send_Message"",
                                                           ""Effect"": ""Allow"",
                                                           ""Principal"": {
                                                                ""AWS"": ""*""
                                                             },
                                                            ""Action"": ""SQS:SendMessage"",
                                                            ""Resource"": """ + Arn + @""",
                                                            ""Condition"" : {
															   ""ArnEquals"" : {
																  ""aws:SourceArn"":"""                                                                 + topic.Arn + @"""
															   }
															}
                                                         }
                                                    }");
        }
Пример #5
0
 protected string GetQueueSubscriptionPilocy(SnsTopicBase topic)
 {
     return @"{
                                               ""Version"": ""2012-10-17"",
                                               ""Id"": ""Sns_Subsciption_Policy"",
                                               ""Statement"":
                                                 {
                                                    ""Sid"":""Send_Message"",
                                                    ""Effect"": ""Allow"",
                                                    ""Principal"": {
                                                         ""AWS"": ""*""
                                                      },
                                                     ""Action"": ""SQS:SendMessage"",
                                                     ""Resource"": """ + Arn + @""",
                                                     ""Condition"" : {
                                                        ""ArnEquals"" : {
                                                           ""aws:SourceArn"":""" + topic.Arn + @"""
                                                        }
                                                     }
                                                  }
                                             }";
 }
Пример #6
0
        public bool HasPermission(SnsTopicBase snsTopic)
        {
            var policyResponse = Client.GetQueueAttributes(
                new GetQueueAttributesRequest{
                 QueueUrl = Url,
                 AttributeNames = new List<string> { "Policy" }});

            if (string.IsNullOrEmpty(policyResponse.Policy))
                return false;

            return policyResponse.Policy.Contains(snsTopic.Arn);
        }