mirror of https://github.com/apache/jclouds.git
JCLOUDS-732: S3 portable object ACLs
This commit is contained in:
parent
d8aea21f72
commit
6c8be12703
|
@ -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}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue