owner.setId(ownerId); if (acl == null) { acl = new AccessControlList(); acl = new AccessControlList(); acl = new AccessControlList(); acl = new AccessControlList(); acl = new AccessControlList(); acl = new AccessControlList();
@Test public void testSetACL() { AccessControlList acl = new AccessControlList(); EasyMock.reset(mockS3); EasyMock.expect(mockS3.getRegion()).andReturn(Region.US_Standard); mockS3.setObjectAcl(anyObject(String.class), anyObject(String.class), anyObject(String.class), eq(acl), eq((RequestMetricCollector) null)); EasyMock.expectLastCall().once(); EasyMock.replay(mockS3); mapper.getS3ClientCache().useClient(mockS3); S3Link link = mapper.createS3Link(bucket, key); link.setAcl(acl); EasyMock.verify(mockS3); }
AccessControlList acl = new AccessControlList(); acl.grantPermission(GroupGrantee.AllUsers, Permission.Read);
protected AccessControlList getAccessControlList(MirrorOptions options, String key) throws Exception { Exception ex = null; for (int tries=0; tries<=options.getMaxRetries(); tries++) { try { context.getStats().s3getCount.incrementAndGet(); return client.getObjectAcl(options.getSourceBucket(), key); } catch (Exception e) { ex = e; if (tries >= options.getMaxRetries()) { // Annoyingly there can be two reasons for this to fail. It will fail if the IAM account // permissions are wrong, but it will also fail if we are copying an item that we don't // own ourselves. This may seem unusual, but it occurs when copying AWS Detailed Billing // objects since although they live in your bucket, the object owner is AWS. getLog().warn("Unable to obtain object ACL, copying item without ACL data."); return new AccessControlList(); } if (options.isVerbose()) { if (tries >= options.getMaxRetries()) { getLog().warn("getObjectAcl(" + key + ") failed (try #" + tries + "), giving up."); break; } else { getLog().warn("getObjectAcl("+key+") failed (try #"+tries+"), retrying..."); } } } } throw ex; }
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; }
owner.setId(ownerId); if (acl == null) { acl = new AccessControlList(); acl = new AccessControlList(); acl = new AccessControlList(); acl = new AccessControlList(); acl = new AccessControlList(); acl = new AccessControlList();
from.setRequestMetricCollector(collector); final AccessControlList accessControlList = new AccessControlList(); final ObjectMetadata metadata = new ObjectMetadata(); metadata.addUserMetadata("um_k1", "um_v1");
@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()); } } }
AccessControlList largeAcl = new AccessControlList(); largeAcl.setOwner(new Owner(accessKey, accessKey)); largeAcl.grantPermission(new CanonicalGrantee(accessKey), Permission.FullControl); largeAcl.grantPermission(GroupGrantee.AllUsers, Permission.Read); AccessControlList midAcl = new AccessControlList(); midAcl.setOwner(new Owner(accessKey, accessKey)); midAcl.grantPermission(new CanonicalGrantee(accessKey), Permission.FullControl); midAcl.grantPermission(GroupGrantee.AuthenticatedUsers, Permission.Read); AccessControlList defaultAcl = new AccessControlList(); defaultAcl.setOwner(new Owner(accessKey, accessKey)); defaultAcl.grantPermission(new CanonicalGrantee(accessKey), Permission.FullControl);