public AccessControlList getBucketAcl(String bucket) { return amazonS3.getBucketAcl(bucket); }
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); } }
public static void getBucketAcl(String bucket_name) { System.out.println("Retrieving ACL for bucket: " + bucket_name); final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient(); try { AccessControlList acl = s3.getBucketAcl(bucket_name); List<Grant> grants = acl.getGrantsAsList(); for (Grant grant : grants) { System.out.format(" %s: %s\n", grant.getGrantee().getIdentifier(), grant.getPermission().toString()); } } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } }
public AccessControlList getBucketAcl(String bucket) { return amazonS3.getBucketAcl(bucket); }
@Override public void open(String uId) throws IOException { // connect to s3 s3_client = S3Connection.createClient(properties); //Test whether the bucket exist and authorized to current user. s3_client.getBucketAcl(properties.getDatasetProperties().bucket.getValue()); // prepare the local target, will upload it to s3 and clear it in the close method data_file = File.createTempFile("s3-", ".csv"); OutputStream outputStream = new FileOutputStream(data_file); writer = new CsvWriter(new OutputStreamWriter(outputStream), ';'); }
@Override public AccessControlList getBucketAcl(String bucketName) throws SdkClientException, AmazonServiceException { return call(() -> getDelegate().getBucketAcl(bucketName)); }
@Override public void open(String uId) throws IOException { // connect to s3 s3_client = S3Connection.createClient(properties); //Test whether the bucket exist and authorized to current user. s3_client.getBucketAcl(properties.getDatasetProperties().bucket.getValue()); // prepare the local target, will upload it to s3 and clear it in the close method data_file = File.createTempFile("s3-", ".csv"); OutputStream outputStream = new FileOutputStream(data_file); writer = new CsvWriter(new OutputStreamWriter(outputStream), ';'); }
@Override public AccessControlList getBucketAcl(GetBucketAclRequest getBucketAclRequest) throws SdkClientException, AmazonServiceException { return call(() -> getDelegate().getBucketAcl(getBucketAclRequest)); }
@Override public boolean backupExistingConfigForResource(final String resourceId, final String resourceType, Map<String, Object> clientMap, Map<String, String> ruleParams,Map<String, String> issue) throws AutoFixException { LOGGER.debug(String.format("backing up the config for %s" , resourceId)); AmazonS3 client = (AmazonS3) clientMap.get("client"); Gson gson = new Gson(); AccessControlList bucketAcl = client.getBucketAcl(resourceId); List<Grant> grants = bucketAcl.getGrantsAsList(); String oldConfig = gson.toJson(grants); backupOldConfig(resourceId, BUCKET_ACL, oldConfig); BucketPolicy bucketPolicy = client.getBucketPolicy(resourceId); if (!Strings.isNullOrEmpty(bucketPolicy.getPolicyText())) { backupOldConfig(resourceId, BUCKET_POLICY, bucketPolicy.getPolicyText()); } LOGGER.debug("backup complete for " + resourceId); return true; }
acl = s3.getBucketAcl(bucketName); } catch (AmazonS3Exception e) { if ("AccessDenied".equals(e.getErrorCode())) {