ObjectListing objectListing = conn.listObjects(cid);
AccessControlList aclKeys = null;
for(S3ObjectSummary elem: objectListing.getObjectSummaries()) {
aclKeys = conn.getObjectAcl(cid, elem.getKey());
aclKeys.grantPermission(new CanonicalGrantee(canonicalId), Permission.Read);
aclKeys.grantPermission(new CanonicalGrantee(canonicalId), Permission.ReadAcp);
conn.setObjectAcl(cid, elem.getKey(), aclKeys);
}
}
conn.setBucketAcl(cid, acl);