Java Code Examples for com.amazonaws.auth.policy.Statement#setActions()
The following examples show how to use
com.amazonaws.auth.policy.Statement#setActions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntegrationTest.java From amazon-sqs-java-temporary-queues-client with Apache License 2.0 | 5 votes |
protected Policy allowSendMessagePolicy(String roleARN) { Policy policy = new Policy(); Statement statement = new Statement(Statement.Effect.Allow); statement.setActions(Collections.singletonList(SQSActions.SendMessage)); statement.setPrincipals(new Principal(roleARN)); statement.setResources(Collections.singletonList(new Resource("arn:aws:sqs:*:*:*"))); policy.setStatements(Collections.singletonList(statement)); return policy; }
Example 2
Source File: CommonTestUtils.java From pacbot with Apache License 2.0 | 5 votes |
public static Policy getPolicy() { Policy policy = new Policy(); List<Statement> statements = new ArrayList<Statement>(); Statement statement = new Statement(Effect.Allow); List<Action> actions = new ArrayList<>(); actions.add(IdentityManagementActions.AllIdentityManagementActions); actions.add(EC2Actions.RunInstances); statement.setActions(actions); statements.add(statement); policy.setStatements(statements); policy.setId("123"); policy.setStatements(statements); return policy; }
Example 3
Source File: AwsPolicyBuilder.java From herd with Apache License 2.0 | 5 votes |
/** * Adds a permission to allow the specified actions to the given KMS key id. * * @param kmsKeyId Full ARN to the kms key * @param actions List of actions * * @return This builder */ @SuppressWarnings("PMD.CloseResource") public AwsPolicyBuilder withKms(String kmsKeyId, KmsActions... actions) { Statement statement = new Statement(Effect.Allow); statement.setActions(Arrays.asList(actions)); statement.setResources(Arrays.asList(new Resource(kmsKeyId))); policy.getStatements().add(statement); return this; }
Example 4
Source File: AwsPolicyBuilder.java From herd with Apache License 2.0 | 5 votes |
/** * Adds a permission to allow the specified actions to the given bucket and s3 object key. The permission will allow the given actions only to the specified * object key. If object key is null, the permission is applied to the bucket itself. * * @param bucketName S3 bucket name * @param objectKey S3 object key * @param actions List of actions to allow * * @return This builder */ @SuppressWarnings("PMD.CloseResource") public AwsPolicyBuilder withS3(String bucketName, String objectKey, S3Actions... actions) { Statement statement = new Statement(Effect.Allow); statement.setActions(Arrays.asList(actions)); String resource = "arn:aws:s3:::" + bucketName; if (objectKey != null) { resource += "/" + objectKey; } statement.setResources(Arrays.asList(new Resource(resource))); policy.getStatements().add(statement); return this; }