Package com.parse

Class ParseACL


  • public class ParseACL
    extends java.lang.Object
    A 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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static <any> CREATOR  
    • Constructor Summary

      Constructors 
      Constructor Description
      ParseACL()
      Creates an ACL with no permissions granted.
      ParseACL​(ParseACL acl)
      Creates a copy of acl.
      ParseACL​(ParseUser owner)
      Creates an ACL where only the provided user has access.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int describeContents()  
      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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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 ParseObjects 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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.String userId, boolean allowed)
      Set whether the given user id is allowed to write this object.
      void writeToParcel​(Parcel dest, int flags)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CREATOR

        public static final <any> CREATOR
    • Constructor Detail

      • ParseACL

        public ParseACL()
        Creates an ACL with no permissions granted.
      • ParseACL

        public ParseACL​(ParseACL acl)
        Creates a copy of acl.
        Parameters:
        acl - The acl to copy.
      • ParseACL

        public ParseACL​(ParseUser owner)
        Creates an ACL where only the provided user has access.
        Parameters:
        owner - The only user that can read or write objects governed by this ACL.
    • Method Detail

      • setDefaultACL

        public static void setDefaultACL​(ParseACL acl,
                                         boolean withAccessForCurrentUser)
        Sets a default ACL that will be applied to all ParseObjects when they are created.
        Parameters:
        acl - The ACL to use as a template for all ParseObjects 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 ParseObjects.
        withAccessForCurrentUser - If true, the ParseACL that is applied to newly-created ParseObjects 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.
      • getPublicReadAccess

        public boolean getPublicReadAccess()
        Get whether the public is allowed to read this object.
      • setPublicReadAccess

        public void setPublicReadAccess​(boolean allowed)
        Set whether the public is allowed to read this object.
      • getPublicWriteAccess

        public boolean getPublicWriteAccess()
        Set whether the public is allowed to write this object.
      • setPublicWriteAccess

        public void setPublicWriteAccess​(boolean allowed)
        Set whether the public is allowed to write this object.
      • setReadAccess

        public void setReadAccess​(java.lang.String userId,
                                  boolean allowed)
        Set whether the given user id is allowed to read this object.
      • getReadAccess

        public boolean getReadAccess​(java.lang.String userId)
        Get whether the given user id is *explicitly* allowed to read this object. Even if this returns 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.
      • setWriteAccess

        public void setWriteAccess​(java.lang.String userId,
                                   boolean allowed)
        Set whether the given user id is allowed to write this object.
      • getWriteAccess

        public boolean getWriteAccess​(java.lang.String userId)
        Get whether the given user id is *explicitly* allowed to write this object. Even if this returns 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.
      • setReadAccess

        public void setReadAccess​(ParseUser user,
                                  boolean allowed)
        Set whether the given user is allowed to read this object.
      • getReadAccess

        public boolean getReadAccess​(ParseUser user)
        Get whether the given user id is *explicitly* allowed to read this object. Even if this returns 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.
      • setWriteAccess

        public void setWriteAccess​(ParseUser user,
                                   boolean allowed)
        Set whether the given user is allowed to write this object.
      • getWriteAccess

        public boolean getWriteAccess​(ParseUser user)
        Get whether the given user id is *explicitly* allowed to write this object. Even if this returns 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.
      • getRoleReadAccess

        public boolean getRoleReadAccess​(java.lang.String roleName)
        Get whether users belonging to the role with the given roleName are allowed to read this object. Even if this returns false, the role may still be able to read it if a parent role has read access.
        Parameters:
        roleName - The name of the role.
        Returns:
        true if the role has read access. false otherwise.
      • setRoleReadAccess

        public void setRoleReadAccess​(java.lang.String roleName,
                                      boolean allowed)
        Set whether users belonging to the role with the given roleName are allowed to read this object.
        Parameters:
        roleName - The name of the role.
        allowed - Whether the given role can read this object.
      • getRoleWriteAccess

        public boolean getRoleWriteAccess​(java.lang.String roleName)
        Get whether users belonging to the role with the given roleName are allowed to write this object. Even if this returns false, the role may still be able to write it if a parent role has write access.
        Parameters:
        roleName - The name of the role.
        Returns:
        true if the role has write access. false otherwise.
      • setRoleWriteAccess

        public void setRoleWriteAccess​(java.lang.String roleName,
                                       boolean allowed)
        Set whether users belonging to the role with the given roleName are allowed to write this object.
        Parameters:
        roleName - The name of the role.
        allowed - Whether the given role can write this object.
      • getRoleReadAccess

        public boolean getRoleReadAccess​(ParseRole role)
        Get whether users belonging to the given role are allowed to read this object. Even if this returns 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.
        Parameters:
        role - The role to check for access.
        Returns:
        true if the role has read access. false otherwise.
      • setRoleReadAccess

        public void setRoleReadAccess​(ParseRole role,
                                      boolean allowed)
        Set whether users belonging to the given role are allowed to read this object. The role must already be saved on the server and its data must have been fetched in order to use this method.
        Parameters:
        role - The role to assign access.
        allowed - Whether the given role can read this object.
      • getRoleWriteAccess

        public boolean getRoleWriteAccess​(ParseRole role)
        Get whether users belonging to the given role are allowed to write this object. Even if this returns 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.
        Parameters:
        role - The role to check for access.
        Returns:
        true if the role has write access. false otherwise.
      • setRoleWriteAccess

        public void setRoleWriteAccess​(ParseRole role,
                                       boolean allowed)
        Set whether users belonging to the given role are allowed to write this object. The role must already be saved on the server and its data must have been fetched in order to use this method.
        Parameters:
        role - The role to assign access.
        allowed - Whether the given role can write this object.
      • describeContents

        public int describeContents()
      • writeToParcel

        public void writeToParcel​(Parcel dest,
                                  int flags)