static AccessControlList grantFullControlToBucketOwner(ServerSideEncryptingAmazonS3 s3Client, String bucket) { final AccessControlList acl = s3Client.getBucketAcl(bucket); acl.grantAllPermissions(new Grant(new CanonicalGrantee(acl.getOwner().getId()), Permission.FullControl)); return acl; }
Owner owner = acl.getOwner(); if (owner == null) { throw new SdkClientException("Invalid AccessControlList: missing an S3Owner");
Owner owner = acl.getOwner(); if (owner == null) { throw new AmazonClientException("Invalid AccessControlList: missing an S3Owner");
private void verifyAcls(AccessControlList acl1, AccessControlList acl2) { Assert.assertEquals(acl1.getOwner(), acl2.getOwner()); for (Grant grant : acl1.getGrantsAsList()) { Assert.assertTrue(acl2.getGrantsAsList().contains(grant)); } for (Grant grant : acl2.getGrantsAsList()) { Assert.assertTrue(acl1.getGrantsAsList().contains(grant)); } }
static AccessControlList grantFullControlToBucketOwner(ServerSideEncryptingAmazonS3 s3Client, String bucket) { final AccessControlList acl = s3Client.getBucketAcl(bucket); acl.grantAllPermissions(new Grant(new CanonicalGrantee(acl.getOwner().getId()), Permission.FullControl)); return acl; }
private ObjectAcl syncAclFromS3Acl(AccessControlList s3Acl) { ObjectAcl syncAcl = new ObjectAcl(); syncAcl.setOwner(s3Acl.getOwner().getId()); for (Grant grant : s3Acl.getGrantsAsList()) { Grantee grantee = grant.getGrantee(); if (grantee instanceof GroupGrantee || grantee.getTypeIdentifier().equals(ACL_GROUP_TYPE)) syncAcl.addGroupGrant(grantee.getIdentifier(), grant.getPermission().toString()); else if (grantee instanceof CanonicalGrantee || grantee.getTypeIdentifier().equals(ACL_CANONICAL_USER_TYPE)) syncAcl.addUserGrant(grantee.getIdentifier(), grant.getPermission().toString()); } return syncAcl; }
result.setSize(metadata.getContentLength()); AccessControlList objectAcl = client.getObjectAcl(bucketName, key); result.setOwner(objectAcl.getOwner()); return result; } catch (AmazonS3Exception e) {
/** * get the S3PosixFileAttributes for a S3Path * @param s3Path Path mandatory not null * @return S3PosixFileAttributes never null * @throws NoSuchFileException if the Path doesnt exists */ public S3PosixFileAttributes getS3PosixFileAttributes(S3Path s3Path) throws NoSuchFileException { S3ObjectSummary objectSummary = getS3ObjectSummary(s3Path); String key = s3Path.getKey(); String bucketName = s3Path.getFileStore().name(); S3BasicFileAttributes attrs = toS3FileAttributes(objectSummary, key); S3UserPrincipal userPrincipal = null; Set<PosixFilePermission> permissions = null; if (!attrs.isDirectory()) { AmazonS3 client = s3Path.getFileSystem().getClient(); AccessControlList acl = client.getObjectAcl(bucketName, key); Owner owner = acl.getOwner(); userPrincipal = new S3UserPrincipal(owner.getId() + ":" + owner.getDisplayName()); permissions = toPosixFilePermissions(acl.getGrantsAsList()); } return new S3PosixFileAttributes((String)attrs.fileKey(), attrs.lastModifiedTime(), attrs.size(), attrs.isDirectory(), attrs.isRegularFile(), userPrincipal, null, permissions); }
Owner owner = acl.getOwner(); if (owner == null) { throw new SdkClientException("Invalid AccessControlList: missing an S3Owner");
Owner owner = acl.getOwner(); if (owner == null) { throw new AmazonClientException("Invalid AccessControlList: missing an S3Owner");