public class ParseACL extends Object
ParseACL
is used to control which users can access or modify a particular object. Each
ParseObject
can have its own ParseACL
. You can grant read and write permissions
separately to specific users, to groups of users that belong to roles, or you can grant
permissions to "the public" so that, for example, any user could read a particular object but
only a particular set of users could write to that object.Constructor and Description |
---|
ParseACL()
Creates an ACL with no permissions granted.
|
ParseACL(ParseUser owner)
Creates an ACL where only the provided user has access.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getPublicReadAccess()
Get whether the public is allowed to read this object.
|
boolean |
getPublicWriteAccess()
Set whether the public is allowed to write this object.
|
boolean |
getReadAccess(ParseUser user)
Get whether the given user id is *explicitly* allowed to read this object.
|
boolean |
getReadAccess(String userId)
Get whether the given user id is *explicitly* allowed to read this object.
|
boolean |
getRoleReadAccess(ParseRole role)
Get whether users belonging to the given role are allowed to read this object.
|
boolean |
getRoleReadAccess(String roleName)
Get whether users belonging to the role with the given roleName are allowed to read this
object.
|
boolean |
getRoleWriteAccess(ParseRole role)
Get whether users belonging to the given role are allowed to write this object.
|
boolean |
getRoleWriteAccess(String roleName)
Get whether users belonging to the role with the given roleName are allowed to write this
object.
|
boolean |
getWriteAccess(ParseUser user)
Get whether the given user id is *explicitly* allowed to write this object.
|
boolean |
getWriteAccess(String userId)
Get whether the given user id is *explicitly* allowed to write this object.
|
static void |
setDefaultACL(ParseACL acl,
boolean withAccessForCurrentUser)
Sets a default ACL that will be applied to all
ParseObject s when they are created. |
void |
setPublicReadAccess(boolean allowed)
Set whether the public is allowed to read this object.
|
void |
setPublicWriteAccess(boolean allowed)
Set whether the public is allowed to write this object.
|
void |
setReadAccess(ParseUser user,
boolean allowed)
Set whether the given user is allowed to read this object.
|
void |
setReadAccess(String userId,
boolean allowed)
Set whether the given user id is allowed to read this object.
|
void |
setRoleReadAccess(ParseRole role,
boolean allowed)
Set whether users belonging to the given role are allowed to read this object.
|
void |
setRoleReadAccess(String roleName,
boolean allowed)
Set whether users belonging to the role with the given roleName are allowed to read this
object.
|
void |
setRoleWriteAccess(ParseRole role,
boolean allowed)
Set whether users belonging to the given role are allowed to write this object.
|
void |
setRoleWriteAccess(String roleName,
boolean allowed)
Set whether users belonging to the role with the given roleName are allowed to write this
object.
|
void |
setWriteAccess(ParseUser user,
boolean allowed)
Set whether the given user is allowed to write this object.
|
void |
setWriteAccess(String userId,
boolean allowed)
Set whether the given user id is allowed to write this object.
|
public ParseACL()
public ParseACL(ParseUser owner)
owner
- The only user that can read or write objects governed by this ACL.public static void setDefaultACL(ParseACL acl, boolean withAccessForCurrentUser)
ParseObject
s when they are created.acl
- The ACL to use as a template for all ParseObject
s created after setDefaultACL
has been called. This value will be copied and used as a template for the creation of
new ACLs, so changes to the instance after setDefaultACL(ParseACL, boolean)
has been called will not be reflected in new ParseObject
s.withAccessForCurrentUser
- If true
, the ParseACL
that is applied to newly-created
ParseObject
s will provide read and write access to the
ParseUser.getCurrentUser()
at the time of creation. If false
, the
provided ACL will be used without modification. If acl is null
, this value is
ignored.public void setPublicReadAccess(boolean allowed)
public boolean getPublicReadAccess()
public void setPublicWriteAccess(boolean allowed)
public boolean getPublicWriteAccess()
public void setReadAccess(String userId, boolean allowed)
public boolean getReadAccess(String userId)
false
, the user may still be able to access it if getPublicReadAccess returns
true
or a role that the user belongs to has read access.public void setWriteAccess(String userId, boolean allowed)
public boolean getWriteAccess(String userId)
false
, the user may still be able to write it if getPublicWriteAccess returns
true
or a role that the user belongs to has write access.public void setReadAccess(ParseUser user, boolean allowed)
public boolean getReadAccess(ParseUser user)
false
, the user may still be able to access it if getPublicReadAccess returns
true
or a role that the user belongs to has read access.public void setWriteAccess(ParseUser user, boolean allowed)
public boolean getWriteAccess(ParseUser user)
false
, the user may still be able to write it if getPublicWriteAccess returns
true
or a role that the user belongs to has write access.public boolean getRoleReadAccess(String roleName)
false
, the role may still be able to read it if a parent
role has read access.roleName
- The name of the role.true
if the role has read access. false
otherwise.public void setRoleReadAccess(String roleName, boolean allowed)
roleName
- The name of the role.allowed
- Whether the given role can read this object.public boolean getRoleWriteAccess(String roleName)
false
, the role may still be able to write it if a parent
role has write access.roleName
- The name of the role.true
if the role has write access. false
otherwise.public void setRoleWriteAccess(String roleName, boolean allowed)
roleName
- The name of the role.allowed
- Whether the given role can write this object.public boolean getRoleReadAccess(ParseRole role)
false
, the role may still be able to read it if a parent role has read access.
The role must already be saved on the server and its data must have been fetched in order to
use this method.role
- The role to check for access.true
if the role has read access. false
otherwise.public void setRoleReadAccess(ParseRole role, boolean allowed)
role
- The role to assign access.allowed
- Whether the given role can read this object.public boolean getRoleWriteAccess(ParseRole role)
false
, the role may still be able to write it if a parent role has write
access. The role must already be saved on the server and its data must have been fetched in
order to use this method.role
- The role to check for access.true
if the role has write access. false
otherwise.public void setRoleWriteAccess(ParseRole role, boolean allowed)
role
- The role to assign access.allowed
- Whether the given role can write this object.