Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient.GetNewPolicyAndStatementForTopicAttributes C# (CSharp) Méthode

GetNewPolicyAndStatementForTopicAttributes() private static méthode

Helper method for AuthorizeS3ToPublishAsync()
private static GetNewPolicyAndStatementForTopicAttributes ( string>.Dictionary attributes, string topicArn, string bucket, Amazon.Auth.AccessControlPolicy.Policy &policy, Amazon.Auth.AccessControlPolicy.Statement &statement ) : void
attributes string>.Dictionary
topicArn string
bucket string
policy Amazon.Auth.AccessControlPolicy.Policy
statement Amazon.Auth.AccessControlPolicy.Statement
Résultat void
        private static void GetNewPolicyAndStatementForTopicAttributes(Dictionary<string, string> attributes, string topicArn, string bucket, out Policy policy, out Statement statement)
        {
            if(attributes.ContainsKey("Policy") && !string.IsNullOrEmpty(attributes["Policy"]))
            {
                policy = Policy.FromJson(attributes["Policy"]);
            }
            else
            {
                policy = new Policy();
            }

            var sourceArn = string.Format(CultureInfo.InvariantCulture, "arn:aws:s3:*:*:{0}", bucket);

            statement = new Statement(Statement.StatementEffect.Allow);
            statement.Actions.Add(SNSActionIdentifiers.Publish);
            statement.Resources.Add(new Resource(topicArn));
            statement.Conditions.Add(ConditionFactory.NewSourceArnCondition(sourceArn));
            statement.Principals.Add(new Principal("*"));
        }
    }
AmazonSimpleNotificationServiceClient