List of usage examples for com.amazonaws.services.s3.model Grant Grant
public Grant(Grantee grantee, Permission permission)
From source file:cloudExplorer.Acl.java
License:Open Source License
void setAccess(String id, int what, String access_key, String secret_key, String endpoint, String bucket) { try {//ww w.ja va 2 s.co m Collection<Grant> grantCollection = new ArrayList<Grant>(); AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key); AmazonS3 s3Client = new AmazonS3Client(credentials, new ClientConfiguration().withSignerOverride("S3SignerType")); s3Client.setEndpoint(endpoint); AccessControlList bucketAcl = s3Client.getBucketAcl(bucket); Grant grant = null; if (what == 0) { grant = new Grant(new CanonicalGrantee(id), Permission.Read); grantCollection.add(grant); } if (what == 1) { grant = new Grant(new CanonicalGrantee(id), Permission.FullControl); grantCollection.add(grant); } if (what == 3) { bucketAcl.getGrants().clear(); } bucketAcl.getGrants().addAll(grantCollection); s3Client.setBucketAcl(bucket, bucketAcl); } catch (AmazonServiceException ase) { NewJFrame.jTextArea1.append("\n\nError: " + ase.getErrorMessage()); } }
From source file:com.easarrive.aws.plugins.common.service.impl.S3Service.java
License:Open Source License
/** * {@inheritDoc}/*from w ww . ja va 2 s .com*/ */ @Override public PutObjectResult putObjectAllRW(AmazonS3 client, String bucketName, String key, File file) { Grant readGrant = new Grant(GroupGrantee.AllUsers, Permission.Read); Grant writeGrant = new Grant(GroupGrantee.AllUsers, Permission.Write); return this.putObject(client, bucketName, key, file, readGrant, writeGrant); }
From source file:com.easarrive.aws.plugins.common.service.impl.S3Service.java
License:Open Source License
/** * {@inheritDoc}//ww w . j ava2 s .co m */ @Override public PutObjectResult putObjectAllRW(AmazonS3 client, String bucketName, String key, InputStream input, ObjectMetadata metadata) { Grant readGrant = new Grant(GroupGrantee.AllUsers, Permission.Read); Grant writeGrant = new Grant(GroupGrantee.AllUsers, Permission.Write); return this.putObject(client, bucketName, key, input, metadata, readGrant, writeGrant); }
From source file:io.druid.storage.s3.S3Utils.java
License:Apache License
static AccessControlList grantFullControlToBucketOwner(AmazonS3 s3Client, String bucket) { final AccessControlList acl = s3Client.getBucketAcl(bucket); acl.grantAllPermissions(new Grant(new CanonicalGrantee(acl.getOwner().getId()), Permission.FullControl)); return acl;/* w w w. j a v a 2 s. c om*/ }
From source file:org.apache.druid.storage.s3.S3Utils.java
License:Apache License
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;//w ww. j av a 2s . com }