Java 类com.amazonaws.auth.policy.conditions.ArnCondition 实例源码

项目:NBS3Sync    文件:S3Receiver.java   
/**
 * Generate a policy that will allow messages published to an SNS topic
 * to be sent to all queues subscribed to that topic
 * @param topicArn the topic to create policy for
 * @return The policy
 */
private Policy makePolicy(String topicArn) {
    //SQSActions.SendMessage does not work!!
    Action sendMessageAction = new Action() {
        @Override
        public String getActionName() {
            return "SQS:SendMessage";
        }
    };
    return new Policy().withId("sns2sqs").withStatements(
            new Statement(Statement.Effect.Allow)
                    .withPrincipals(Principal.AllUsers)
                    .withActions(sendMessageAction)
                    .withResources(new Resource(queueArn))
                    .withConditions(new ArnCondition(ArnCondition.ArnComparisonType.ArnEquals, ConditionFactory.SOURCE_ARN_CONDITION_KEY, topicArn)));
}