Package org.jets3t.service.acl
Class AccessControlList
- java.lang.Object
-
- org.jets3t.service.acl.AccessControlList
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
GSAccessControlList
public class AccessControlList extends Object implements Serializable
Represents an Amazon S3 Access Control List (ACL), including the ACL's set of grantees and the permissions assigned to each grantee.- Author:
- James Murty
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static AccessControlListREST_CANNED_AUTHENTICATED_READA pre-canned REST ACL to set an object's permissions to Authenticated Read (authenticated Amazon users can read, only owner can write)static AccessControlListREST_CANNED_PRIVATEA pre-canned REST ACL to set an object's permissions to Private (only owner can read/write)static AccessControlListREST_CANNED_PUBLIC_READA pre-canned REST ACL to set an object's permissions to Public Read (anyone can read, only owner can write)static AccessControlListREST_CANNED_PUBLIC_READ_WRITEA pre-canned REST ACL to set an object's permissions to Public Read and Write (anyone can read/write)
-
Constructor Summary
Constructors Constructor Description AccessControlList()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description GrantAndPermission[]getGrantAndPermissions()List<GranteeInterface>getGranteesWithPermission(Permission permission)StorageOwnergetOwner()List<Permission>getPermissionsForGrantee(GranteeInterface grantee)StringgetValueForRESTHeaderACL()voidgrantAllPermissions(GrantAndPermission[] grantAndPermissions)Adds a set of grantee/permission pairs to the ACL, where each item in the set is aGrantAndPermissionobject.voidgrantPermission(GranteeInterface grantee, Permission permission)Adds a grantee to the ACL with the given permission.booleanhasGranteeAndPermission(GranteeInterface grantee, Permission permission)booleanisCannedRestACL()Deprecated.0.8.0booleanisRESTHeaderACL()voidrevokeAllPermissions(GranteeInterface grantee)Revokes the permissions of a grantee by removing the grantee from the ACL.voidsetOwner(StorageOwner owner)StringtoString()Returns a string representation of the ACL contents, useful for debugging.StringtoXml()com.jamesmurty.utils.XMLBuildertoXMLBuilder()
-
-
-
Field Detail
-
REST_CANNED_PRIVATE
public static final AccessControlList REST_CANNED_PRIVATE
A pre-canned REST ACL to set an object's permissions to Private (only owner can read/write)
-
REST_CANNED_PUBLIC_READ
public static final AccessControlList REST_CANNED_PUBLIC_READ
A pre-canned REST ACL to set an object's permissions to Public Read (anyone can read, only owner can write)
-
REST_CANNED_PUBLIC_READ_WRITE
public static final AccessControlList REST_CANNED_PUBLIC_READ_WRITE
A pre-canned REST ACL to set an object's permissions to Public Read and Write (anyone can read/write)
-
REST_CANNED_AUTHENTICATED_READ
public static final AccessControlList REST_CANNED_AUTHENTICATED_READ
A pre-canned REST ACL to set an object's permissions to Authenticated Read (authenticated Amazon users can read, only owner can write)
-
-
Method Detail
-
toString
public String toString()
Returns a string representation of the ACL contents, useful for debugging.
-
getOwner
public StorageOwner getOwner()
-
setOwner
public void setOwner(StorageOwner owner)
-
getPermissionsForGrantee
public List<Permission> getPermissionsForGrantee(GranteeInterface grantee)
- Parameters:
grantee-- Returns:
- list of permissions assigned to the given grantee in this ACL
-
getGranteesWithPermission
public List<GranteeInterface> getGranteesWithPermission(Permission permission)
- Parameters:
permission-- Returns:
- list of grantees assigned the given permission in this ACL
-
hasGranteeAndPermission
public boolean hasGranteeAndPermission(GranteeInterface grantee, Permission permission)
- Parameters:
grantee-permission-- Returns:
- true if the given grantee has the given permission in this ACL
-
grantPermission
public void grantPermission(GranteeInterface grantee, Permission permission)
Adds a grantee to the ACL with the given permission. If this ACL already contains the grantee (ie the same grantee object) the permission for the grantee will be updated.- Parameters:
grantee- the grantee to whom the permission will applypermission- the permission to apply to the grantee.
-
grantAllPermissions
public void grantAllPermissions(GrantAndPermission[] grantAndPermissions)
Adds a set of grantee/permission pairs to the ACL, where each item in the set is aGrantAndPermissionobject.- Parameters:
grantAndPermissions- the grant and permission combinations to add.
-
revokeAllPermissions
public void revokeAllPermissions(GranteeInterface grantee)
Revokes the permissions of a grantee by removing the grantee from the ACL.- Parameters:
grantee- the grantee to remove from this ACL.
-
getGrantAndPermissions
public GrantAndPermission[] getGrantAndPermissions()
- Returns:
- the grant and permission collections in this ACL.
-
toXMLBuilder
public com.jamesmurty.utils.XMLBuilder toXMLBuilder() throws ServiceException, ParserConfigurationException, FactoryConfigurationError, TransformerException
-
toXml
public String toXml() throws ServiceException
- Returns:
- an XML representation of the Access Control List object, suitable to send to a storage service in the request body.
- Throws:
ServiceException
-
isCannedRestACL
@Deprecated public boolean isCannedRestACL()
Deprecated.0.8.0- Returns:
- true if this ACL is a REST pre-canned one, in which case REST/HTTP implementations can use the x-amz-acl header as a short-cut to set permissions on upload rather than using a full ACL XML document.
-
isRESTHeaderACL
public boolean isRESTHeaderACL()
- Returns:
- true if this ACL can be set via an HTTP header, rather than via an XML document.
-
getValueForRESTHeaderACL
public String getValueForRESTHeaderACL()
- Returns:
- the header value string for this ACL if it is a canned ACL, otherwise return null;
-
-