Clearspace API (2.5.29) Core Javadocs

com.jivesoftware.community
Class Permissions

java.lang.Object
  extended by com.jivesoftware.community.Permissions
All Implemented Interfaces:
com.jivesoftware.community.cache.Cacheable, Serializable

public class Permissions
extends Object
implements com.jivesoftware.community.cache.Cacheable

Represents a set of permissions that an entity has for an object in the system. For example, the rights that a user has for a community. Permissions are used by the protection proxy objects defined for each major component of the system to provide access rights.

A Permissions object is internally represented as a long with each bit indicating whether a particular permission is set. The constants defined by extensions of this class define the bit masks that can be used for permission operations. For example, the following code creates permissions:


 // Create a permissions object with only read permissions set to true.
 Permissions perms1 = new Permissions(Permissions.VIEW_COMMUNITY);
 // Create a permissions object with read and system admin permissions set to true.
 Permissions perms2 = new Permissions(Permissions.VIEW_COMMUNITY |
          Permissions.SYSTEM_ADMIN);
If we were to view the bits of each variable, perms1 would be 0000000000000000000000000000000000000000000000000000000000000001 and perms2 would be 0000000000000000000000000000000010000000000000000000000000000001.

See Also:
Serialized Form

Nested Class Summary
static class Permissions.PermissionAtom
           
 
Field Summary
static long COMMUNITY_ADMIN
          Permission to administer a community.
static long CREATE_ANNOUNCEMENT
          Permission to create, delete, and schedule announcements.
static long CREATE_BLOG
          Permission to create a blog.
static long CREATE_BLOG_POST
          Place-holder for permission to create a blog post.
static long CREATE_CHAT_EVENT
          Permission to create a chat event.
static long CREATE_COMMENT
          Permission to create a comment
static long CREATE_DOC_ATTACHMENT
          Permission to create an attachment
static long CREATE_DOCUMENT
          Permission to create a document
static long CREATE_IMAGE
          Permission to create an image
static long CREATE_MESSAGE
          Permission to create a new message.
static long CREATE_MESSAGE_ATTACHMENT
          Permission to create attachments.
static long CREATE_POLL
          Permission to create polls.
static long CREATE_PRIVATE_MESSAGE_ATTACHMENT
          Permission to create attachments in a private message.
static long CREATE_PROJECT
          Permission to create a project.
static long CREATE_SOCIAL_GROUP
          Permission to create a social group.
static long CREATE_THREAD
          Permission to create a new thread.
static long EDIT_AVATAR
          Permission to create and delete avatars
static long GROUP_ADMIN
          Permission to administer a particular group.
static long HOSTED_ADMIN
          Permission to perform hosted operations
static long MODERATOR
          Permission to moderate content.
static long NONE
          No permissions.
static long PRIVATE_MESSAGE
          Permission to get and send private messages.
static long RATE_DOCUMENT
          Permission to rate documents in a community
static long RATE_MESSAGE
          Permission to rate messages.
static long READ_BLOG
          Permission to read blog a blog.
static long READ_COMMENT
          Permission to read a comment
static long READ_DOCUMENT
          Permission to read a document
static long SYSTEM_ADMIN
          Permission to administer the entire sytem.
static long USER_ADMIN
          Permission to administer a particular user.
static long VIEW_COMMUNITY
          Permission to read object.
static long VIEW_ONLINE_STATUS
          Permission to see the online status of a particular user.
static long VOTE_IN_POLL
          Permission to vote in polls.
 
Constructor Summary
Permissions(org.acegisecurity.GrantedAuthority[] authorities)
          Creates a permissions object with the given granted authorities from the acegi infrastructure.
Permissions(long permissions)
          Create a new permissions object with the specified permissions.
Permissions(Permissions permissions1, Permissions permissions2)
          Creates a new Permission object by combining two permissions objects.
 
Method Summary
 int getCachedSize()
           
static Map<Long,String> getPermissionNames()
           
 boolean hasPermission(long permissionTypes)
          Returns true if one or more of the permission types is set to true.
 void set(long permissionTypes, boolean value)
          Sets the permissions given by a bit mask to true or false.
 String toString()
           
 long value()
          Returns the long value (bitmask) of the permissions that are set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final long NONE
No permissions.


VIEW_ONLINE_STATUS

public static final long VIEW_ONLINE_STATUS
Permission to see the online status of a particular user.


USER_ADMIN

public static final long USER_ADMIN
Permission to administer a particular user. Used for LDAP


GROUP_ADMIN

public static final long GROUP_ADMIN
Permission to administer a particular group. Usec for LDAP


SYSTEM_ADMIN

public static final long SYSTEM_ADMIN
Permission to administer the entire sytem.


HOSTED_ADMIN

public static final long HOSTED_ADMIN
Permission to perform hosted operations


READ_DOCUMENT

public static final long READ_DOCUMENT
Permission to read a document


READ_COMMENT

public static final long READ_COMMENT
Permission to read a comment


CREATE_DOCUMENT

public static final long CREATE_DOCUMENT
Permission to create a document


CREATE_COMMENT

public static final long CREATE_COMMENT
Permission to create a comment


CREATE_DOC_ATTACHMENT

public static final long CREATE_DOC_ATTACHMENT
Permission to create an attachment


RATE_DOCUMENT

public static final long RATE_DOCUMENT
Permission to rate documents in a community


CREATE_IMAGE

public static final long CREATE_IMAGE
Permission to create an image


VIEW_COMMUNITY

public static final long VIEW_COMMUNITY
Permission to read object.


CREATE_MESSAGE

public static final long CREATE_MESSAGE
Permission to create a new message.


CREATE_THREAD

public static final long CREATE_THREAD
Permission to create a new thread.


CREATE_MESSAGE_ATTACHMENT

public static final long CREATE_MESSAGE_ATTACHMENT
Permission to create attachments.


CREATE_POLL

public static final long CREATE_POLL
Permission to create polls.


PRIVATE_MESSAGE

public static final long PRIVATE_MESSAGE
Permission to get and send private messages.


RATE_MESSAGE

public static final long RATE_MESSAGE
Permission to rate messages.


MODERATOR

public static final long MODERATOR
Permission to moderate content.


COMMUNITY_ADMIN

public static final long COMMUNITY_ADMIN
Permission to administer a community.


VOTE_IN_POLL

public static final long VOTE_IN_POLL
Permission to vote in polls.


CREATE_PRIVATE_MESSAGE_ATTACHMENT

public static final long CREATE_PRIVATE_MESSAGE_ATTACHMENT
Permission to create attachments in a private message.


CREATE_ANNOUNCEMENT

public static final long CREATE_ANNOUNCEMENT
Permission to create, delete, and schedule announcements.


EDIT_AVATAR

public static final long EDIT_AVATAR
Permission to create and delete avatars


READ_BLOG

public static final long READ_BLOG
Permission to read blog a blog.


CREATE_BLOG

public static final long CREATE_BLOG
Permission to create a blog.


CREATE_PROJECT

public static final long CREATE_PROJECT
Permission to create a project.


CREATE_SOCIAL_GROUP

public static final long CREATE_SOCIAL_GROUP
Permission to create a social group.


CREATE_CHAT_EVENT

public static final long CREATE_CHAT_EVENT
Permission to create a chat event.


CREATE_BLOG_POST

public static final long CREATE_BLOG_POST
Place-holder for permission to create a blog post.

Constructor Detail

Permissions

public Permissions(long permissions)
Create a new permissions object with the specified permissions.

Parameters:
permissions - integer bitmask values to for the new Permissions.

Permissions

public Permissions(org.acegisecurity.GrantedAuthority[] authorities)
Creates a permissions object with the given granted authorities from the acegi infrastructure.

Parameters:
authorities -

Permissions

public Permissions(Permissions permissions1,
                   Permissions permissions2)
Creates a new Permission object by combining two permissions objects. The higher permission of each permission type will be used.

Parameters:
permissions1 - the first permissions to use when creating the new Permissions.
permissions2 - the second permissions to use when creating the new Permissions.
Method Detail

hasPermission

public boolean hasPermission(long permissionTypes)
Returns true if one or more of the permission types is set to true.

Parameters:
permissionTypes -
Returns:
true if one or more of the permission types is set to true, false otherwise.

set

public void set(long permissionTypes,
                boolean value)
Sets the permissions given by a bit mask to true or false. For example, the following would set the VIEW_COMMUNITY and SYSTEM_ADMIN permissions to true:
 permissions.set(Permissions.VIEW_COMMUNITY | Permissions.SYSTEM_ADMIN, true);
 

Parameters:
permissionTypes - the permission types to set.
value - true to enable the permission, false to disable.

value

public long value()
Returns the long value (bitmask) of the permissions that are set.

Returns:
the long value of the object.

toString

public String toString()
Overrides:
toString in class Object

getCachedSize

public int getCachedSize()
Specified by:
getCachedSize in interface com.jivesoftware.community.cache.Cacheable

getPermissionNames

public static Map<Long,String> getPermissionNames()

Clearspace Project Page

Copyright © 1999-2007 Jive Software.