/** * Adds a set of grantee/permission pairs to the access control list (ACL), where each item in the * set is a {@link Grant} object. * * @param grantsVarArg * A collection of {@link Grant} objects */ public void grantAllPermissions(Grant... grantsVarArg) { for (Grant gap : grantsVarArg) { grantPermission(gap.getGrantee(), gap.getPermission()); } }
public static void setObjectAcl(String bucket_name, String object_key, String email, String access) { System.out.format("Setting %s access for %s\n", access, email); System.out.println("for object: " + object_key); System.out.println(" in bucket: " + bucket_name); final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient(); try { // get the current ACL AccessControlList acl = s3.getObjectAcl(bucket_name, object_key); // set access for the grantee EmailAddressGrantee grantee = new EmailAddressGrantee(email); Permission permission = Permission.valueOf(access); acl.grantPermission(grantee, permission); s3.setObjectAcl(bucket_name, object_key, acl); } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } }
public static void setBucketAcl(String bucket_name, String email, String access) { System.out.format("Setting %s access for %s\n", access, email); System.out.println("on bucket: " + bucket_name); final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient(); try { // get the current ACL AccessControlList acl = s3.getBucketAcl(bucket_name); // set access for the grantee EmailAddressGrantee grantee = new EmailAddressGrantee(email); Permission permission = Permission.valueOf(access); acl.grantPermission(grantee, permission); s3.setBucketAcl(bucket_name, acl); } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } }
accessControlList.grantPermission( currentGrantee, currentPermission);
acl = new AccessControlList(); acl.grantPermission(grantee, Permission.FullControl); acl = new AccessControlList(); acl.grantPermission(grantee, Permission.Read); acl = new AccessControlList(); acl.grantPermission(grantee, Permission.Write); acl = new AccessControlList(); acl.grantPermission(grantee, Permission.ReadAcp); acl = new AccessControlList(); acl.grantPermission(grantee, Permission.WriteAcp);
/** * Adds a set of grantee/permission pairs to the access control list (ACL), * where each item in the set is a {@link Grant} object. * * @param grants A collection of {@link Grant} objects */ public void grantAllPermissions(Grant... grantsVarArg) { for (final Grant gap : grantsVarArg) { grantPermission(gap.getGrantee(), gap.getPermission()); } }
accessControlList.grantPermission( currentGrantee, currentPermission);
/** * Adds a set of grantee/permission pairs to the access control list (ACL), * where each item in the set is a {@link Grant} object. * * @param grants A collection of {@link Grant} objects */ public void grantAllPermissions(Grant... grantsVarArg) { for (final Grant gap : grantsVarArg) { grantPermission(gap.getGrantee(), gap.getPermission()); } }
/** * Adds a set of grantee/permission pairs to the access control list (ACL), where each item in the * set is a {@link Grant} object. * * @param grantsVarArg * A collection of {@link Grant} objects */ public void grantAllPermissions(Grant... grantsVarArg) { for (Grant gap : grantsVarArg) { grantPermission(gap.getGrantee(), gap.getPermission()); } }
acl.grantPermission(GroupGrantee.AllUsers, Permission.Read);
private AccessControlList s3AclFromSyncAcl(ObjectAcl syncAcl, boolean ignoreInvalid) { AccessControlList s3Acl = new AccessControlList(); s3Acl.setOwner(new Owner(syncAcl.getOwner(), syncAcl.getOwner())); for (String user : syncAcl.getUserGrants().keySet()) { Grantee grantee = new CanonicalGrantee(user); for (String permission : syncAcl.getUserGrants().get(user)) { Permission perm = getS3Permission(permission, ignoreInvalid); if (perm != null) s3Acl.grantPermission(grantee, perm); } } for (String group : syncAcl.getGroupGrants().keySet()) { Grantee grantee = GroupGrantee.parseGroupGrantee(group); if (grantee == null) { if (ignoreInvalid) log.warn("{} is not a valid S3 group", group); else throw new RuntimeException(group + " is not a valid S3 group"); } for (String permission : syncAcl.getGroupGrants().get(group)) { Permission perm = getS3Permission(permission, ignoreInvalid); if (perm != null) s3Acl.grantPermission(grantee, perm); } } return s3Acl; }
accessControlList.grantPermission( currentGrantee, currentPermission);
accessControlList.grantPermission( currentGrantee, currentPermission);
@Test public void testSetAcl() throws Exception { String bucket = "ecs-sync-s3-test-acl"; String key = "test-object"; createBucket(bucket, true); try { String content = "hello ACLs"; s3.putObject(bucket, key, new ByteArrayInputStream(content.getBytes()), null); // 1st version AccessControlList acl = new AccessControlList(); acl.setOwner(new Owner(accessKey, accessKey)); acl.grantPermission(new CanonicalGrantee(accessKey), Permission.FullControl); acl.grantPermission(GroupGrantee.AuthenticatedUsers, Permission.Read); acl.grantPermission(GroupGrantee.AuthenticatedUsers, Permission.Write); acl.grantPermission(GroupGrantee.AllUsers, Permission.Read); PutObjectRequest putRequest = new PutObjectRequest(bucket, key, new ByteArrayInputStream(content.getBytes()), null); putRequest.setAccessControlList(acl); s3.putObject(putRequest); // 2nd version AccessControlList remoteAcl = s3.getObjectAcl(bucket, key); verifyAcls(acl, remoteAcl); } finally { try { deleteVersionedBucket(bucket); } catch (Throwable t) { log.warn("could not delete bucket: " + t.getMessage()); } } }
acl = new AccessControlList(); acl.grantPermission(grantee, Permission.FullControl); acl = new AccessControlList(); acl.grantPermission(grantee, Permission.Read); acl = new AccessControlList(); acl.grantPermission(grantee, Permission.Write); acl = new AccessControlList(); acl.grantPermission(grantee, Permission.ReadAcp); acl = new AccessControlList(); acl.grantPermission(grantee, Permission.WriteAcp);
largeAcl.grantPermission(new CanonicalGrantee(accessKey), Permission.FullControl); largeAcl.grantPermission(GroupGrantee.AuthenticatedUsers, Permission.Read); largeAcl.grantPermission(GroupGrantee.AuthenticatedUsers, Permission.Write); largeAcl.grantPermission(GroupGrantee.AllUsers, Permission.Read); midAcl.grantPermission(new CanonicalGrantee(accessKey), Permission.FullControl); midAcl.grantPermission(GroupGrantee.AuthenticatedUsers, Permission.Read); defaultAcl.grantPermission(new CanonicalGrantee(accessKey), Permission.FullControl);