Search in sources :

Example 26 with AccessControlList

use of com.amazonaws.services.s3.model.AccessControlList in project druid by druid-io.

the class S3TaskLogsTest method testPushInternal.

private List<Grant> testPushInternal(boolean disableAcl, String ownerId, String ownerDisplayName) throws Exception {
    EasyMock.expect(s3Client.putObject(EasyMock.anyObject())).andReturn(new PutObjectResult()).once();
    AccessControlList aclExpected = new AccessControlList();
    aclExpected.setOwner(new Owner(ownerId, ownerDisplayName));
    EasyMock.expect(s3Client.getBucketAcl(TEST_BUCKET)).andReturn(aclExpected).once();
    EasyMock.expect(s3Client.putObject(EasyMock.anyObject(PutObjectRequest.class))).andReturn(new PutObjectResult()).once();
    EasyMock.replay(s3Client);
    S3TaskLogsConfig config = new S3TaskLogsConfig();
    config.setDisableAcl(disableAcl);
    config.setS3Bucket(TEST_BUCKET);
    CurrentTimeMillisSupplier timeSupplier = new CurrentTimeMillisSupplier();
    S3InputDataConfig inputDataConfig = new S3InputDataConfig();
    S3TaskLogs s3TaskLogs = new S3TaskLogs(s3Client, config, inputDataConfig, timeSupplier);
    String taskId = "index_test-datasource_2019-06-18T13:30:28.887Z";
    File logFile = tempFolder.newFile("test_log_file");
    s3TaskLogs.pushTaskLog(taskId, logFile);
    return aclExpected.getGrantsAsList();
}
Also used : AccessControlList(com.amazonaws.services.s3.model.AccessControlList) Owner(com.amazonaws.services.s3.model.Owner) PutObjectResult(com.amazonaws.services.s3.model.PutObjectResult) CurrentTimeMillisSupplier(org.apache.druid.common.utils.CurrentTimeMillisSupplier) File(java.io.File)

Example 27 with AccessControlList

use of com.amazonaws.services.s3.model.AccessControlList in project druid by druid-io.

the class S3Utils method grantFullControlToBucketOwner.

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;
}
Also used : AccessControlList(com.amazonaws.services.s3.model.AccessControlList) Grant(com.amazonaws.services.s3.model.Grant) CanonicalGrantee(com.amazonaws.services.s3.model.CanonicalGrantee)

Aggregations

AccessControlList (com.amazonaws.services.s3.model.AccessControlList)25 Owner (com.amazonaws.services.s3.model.Owner)8 AmazonServiceException (com.amazonaws.AmazonServiceException)6 AmazonS3 (com.amazonaws.services.s3.AmazonS3)6 CannedAccessControlList (com.amazonaws.services.s3.model.CannedAccessControlList)5 CanonicalGrantee (com.amazonaws.services.s3.model.CanonicalGrantee)5 Grant (com.amazonaws.services.s3.model.Grant)5 File (java.io.File)5 Test (org.junit.Test)5 EmailAddressGrantee (com.amazonaws.services.s3.model.EmailAddressGrantee)4 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)4 PutObjectResult (com.amazonaws.services.s3.model.PutObjectResult)4 Permission (com.amazonaws.services.s3.model.Permission)3 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)3 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 AlluxioURI (alluxio.AlluxioURI)2 ConfigurationRule (alluxio.ConfigurationRule)2 PropertyKey (alluxio.conf.PropertyKey)2 ObjectUnderFileSystem (alluxio.underfs.ObjectUnderFileSystem)2