Wildfire 3.2.4 Javadoc

org.jivesoftware.wildfire
Class Permissions

java.lang.Object
  extended by org.jivesoftware.wildfire.Permissions
All Implemented Interfaces:
Serializable, Cacheable

public class Permissions
extends Object
implements 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 category. 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(ForumPermissions.READ_FORUM); // Create a permissions object with read and system admin permissions set to true. Permissions perms2 = new Permissions(ForumPermissions.READ_FORUM | ForumPermissions.SYSTEM_ADMIN);

If we were to view the bits of each variable, perms1 would be 0000000000000000000000000000000000000000000000000000000000000001 and perms2 would be 0000000000000000000000000000000010000000000000000000000000000001.

Author:
Matt Tucker
See Also:
Serialized Form

Field Summary
static long GROUP_ADMIN
          Permission to administer a particular group.
static long NONE
          No permissions.
static long SYSTEM_ADMIN
          Permission to administer the entire sytem.
static long USER_ADMIN
          Permission to administer a particular user.
static long VIEW_ONLINE_STATUS
          Permission to see the online status of a particular user.
 
Constructor Summary
Permissions(long permissions)
          Create a new permissions object with the specified permissions.
Permissions(Permissions permissions1, Permissions permissions2)
          Creates a new ForumPermission object by combining two permissions objects.
 
Method Summary
 int getCachedSize()
          Returns the approximate size of the Object in bytes.
 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.

See Also:
Constant Field Values

VIEW_ONLINE_STATUS

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

See Also:
Constant Field Values

USER_ADMIN

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

See Also:
Constant Field Values

GROUP_ADMIN

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

See Also:
Constant Field Values

SYSTEM_ADMIN

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

See Also:
Constant Field Values
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(Permissions permissions1,
                   Permissions permissions2)
Creates a new ForumPermission 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 READ_FORUM and SYSTEM_ADMIN permissions to true:

 permissions.set(ForumPermissions.READ_FORUM | ForumPermissions.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()
Description copied from interface: Cacheable
Returns the approximate size of the Object in bytes. The size should be considered to be a best estimate of how much memory the Object occupies and may be based on empirical trials or dynamic calculations.

Specified by:
getCachedSize in interface Cacheable
Returns:
the size of the Object in bytes.

Wildfire 3.2.4 Javadoc

Copyright © 2003-2007 Jive Software.