JCLOUDS-732: S3 portable object ACLs

This commit is contained in:
Andrew Gaul 2015-02-18 15:29:43 -08:00
parent d8aea21f72
commit 6c8be12703
1 changed files with 26 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import javax.inject.Singleton;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.ContainerNotFoundException;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobAccess;
import org.jclouds.blobstore.domain.BlobMetadata;
import org.jclouds.blobstore.domain.ContainerAccess;
import org.jclouds.blobstore.domain.PageSet;
@ -292,6 +293,31 @@ public class S3BlobStore extends BaseBlobStore {
}
}
@Override
public BlobAccess getBlobAccess(String container, String name) {
AccessControlList acl = sync.getObjectACL(container, name);
if (acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ)) {
return BlobAccess.PUBLIC_READ;
} else {
return BlobAccess.PRIVATE;
}
}
@Override
public void setBlobAccess(String container, String name, BlobAccess access) {
AccessControlList acl = sync.getObjectACL(container, name);
if (access == BlobAccess.PUBLIC_READ) {
acl.revokePermission(GroupGranteeURI.ALL_USERS, Permission.FULL_CONTROL)
.revokePermission(GroupGranteeURI.ALL_USERS, Permission.WRITE)
.addPermission(GroupGranteeURI.ALL_USERS, Permission.READ);
} else if (access == BlobAccess.PRIVATE) {
acl.revokePermission(GroupGranteeURI.ALL_USERS, Permission.FULL_CONTROL)
.revokePermission(GroupGranteeURI.ALL_USERS, Permission.READ)
.revokePermission(GroupGranteeURI.ALL_USERS, Permission.WRITE);
}
sync.putObjectACL(container, name, acl);
}
/**
* This implementation invokes {@link S3Utils#deleteAndVerifyContainerGone}
*/