Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base.database
Class DbPermissionsManager

java.lang.Object
  extended by com.jivesoftware.base.database.DbPermissionsManager
All Implemented Interfaces:
JiveManager, PermissionsManager

public class DbPermissionsManager
extends java.lang.Object
implements PermissionsManager, JiveManager

Database implementation of the PermissionsManager interface. This implementation differs from the interface in that calls to the actual interface methods will throw UnsupportedOperationException. Instead, all calls to this class should use the corresponding methods with "int objectType, long objectID" prepended to the method's parameter list.


Nested Class Summary
static class DbPermissionsManager.PermissionsBundle
          Stores the full set of permissions for a permissions context (an objectType and an objectID).
 
Field Summary
static Cache userPermsCache
           
 
Method Summary
 void addAnonymousUserPermission(int objectType, long objectID, PermissionType permissionType, long permission)
           
 void addAnonymousUserPermission(PermissionType permissionType, long permission)
          Add a permission of the specified PermissionType for anonymous users.
 void addGroupPermission(Group group, PermissionType permissionType, long permission)
          Grants a group a particular permission.
 void addGroupPermission(int objectType, long objectID, Group group, PermissionType permissionType, long permission)
           
 void addRegisteredUserPermission(int objectType, long objectID, PermissionType permissionType, long permission)
           
 void addRegisteredUserPermission(PermissionType permissionType, long permission)
          Add a permission of the specified PermissionType for registered users.
 void addUserPermission(int objectType, long objectID, User user, PermissionType permissionType, long permission)
           
 void addUserPermission(User user, PermissionType permissionType, long permission)
          Add a permission of the specified PermissionType for the specified user.
 boolean anonymousUserHasPermission(int objectType, long objectID, PermissionType permissionType, long permission)
           
 boolean anonymousUserHasPermission(PermissionType permissionType, long permission)
          Returns true if the anonymous users have a particular permission.
 void destroy()
          Notifies the manager to release any resources that may be holding on too.
 Permissions getFinalUserPerms(int objectType, long objectID, long userID, PermissionType permissionType)
          Returns the Permissions object that corresponds to the combined permissions that a user has for a particular object: Anonymous and "registered users" permissions.
static DbPermissionsManager getInstance()
           
 java.util.Iterator groupsWithPermission(int objectType, long objectID, PermissionType permissionType, long permission)
           
 java.util.Iterator groupsWithPermission(PermissionType permissionType, long permission)
          Returns an Iterator of groups with a particular permission.
 int groupsWithPermissionCount(int objectType, long objectID, PermissionType permissionType, long permission)
           
 int groupsWithPermissionCount(PermissionType permissionType, long permission)
          Returns a count of the groups that have a particular permission.
 boolean hasPermissionsSet(int objectType, long objectID)
           
 void initialize()
          Initialize the manager.
 void permissionModificationDetected()
          Is called when a permission is modified.
 void permissionModificationDetected(int objectType, long objectID)
          Sends event to the dispatcher.
 boolean registeredUserHasPermission(int objectType, long objectID, PermissionType permissionType, long permission)
           
 boolean registeredUserHasPermission(PermissionType permissionType, long permission)
          Returns true if registered users have a particular permission.
 void removeAllGroupPermissions(int objectType, long objectID, PermissionType permissionType)
           
 void removeAllGroupPermissions(PermissionType permissionType)
          Revokes all group permissions.
 void removeAllPermissions(java.sql.Connection con, int objectType, long objectID)
           
 void removeAllPermissions(int objectType, long objectID)
           
 void removeAllUserPermissions(int objectType, long objectID, PermissionType permissionType)
           
 void removeAllUserPermissions(PermissionType permissionType)
          Removes all user permissions.
 void removeAnonymousUserPermission(int objectType, long objectID, PermissionType permissionType, long permission)
           
 void removeAnonymousUserPermission(PermissionType permissionType, long permission)
          Removes a permission of the specified PermissionType for anonymous users.
 void removeGroupPermission(Group group, PermissionType permissionType, long permission)
          Removes a permission of the specified PermissionType for a group.
 void removeGroupPermission(int objectType, long objectID, Group group, PermissionType permissionType, long permission)
           
 void removeRegisteredUserPermission(int objectType, long objectID, PermissionType permissionType, long permission)
           
 void removeRegisteredUserPermission(PermissionType permissionType, long permission)
          Removes a permission of the specified PermissionType for registered users.
 void removeUserPermission(int objectType, long objectID, User user, PermissionType permissionType, long permission)
           
 void removeUserPermission(User user, PermissionType permissionType, long permission)
          Removes a permission of the specified PermissionType for the specified user.
static int toDbFormat(long permission)
          Converts a normal permissions value into the db format.
 java.util.Iterator usersWithPermission(int objectType, long objectID, PermissionType permissionType, long permission)
           
 java.util.Iterator usersWithPermission(PermissionType permissionType, long permission)
          Returns all the userID's of users with a particular permission.
 int usersWithPermissionCount(int objectType, long objectID, PermissionType permissionType, long permission)
           
 int usersWithPermissionCount(PermissionType permissionType, long permission)
          Returns a count of the users that have a particular permission.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userPermsCache

public static Cache userPermsCache
Method Detail

getInstance

public static DbPermissionsManager getInstance()

initialize

public void initialize()
Description copied from interface: JiveManager
Initialize the manager. It is within this method that it is ok to create, access and/or otherwise use external classes (including caches). Until this method is called implementation should not access any external classes that could possibly either access one of the main Factory classes or any caches since doing so can cause deadlocks and possible clustering issues during startup.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
initialize in interface JiveManager

destroy

public void destroy()
Description copied from interface: JiveManager
Notifies the manager to release any resources that may be holding on too. This could also be used to clear out the managers caches, etc.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
destroy in interface JiveManager

addUserPermission

public void addUserPermission(User user,
                              PermissionType permissionType,
                              long permission)
Description copied from interface: PermissionsManager
Add a permission of the specified PermissionType for the specified user. Only category or system administrators can assign permissions to a category, and only system admins can assign system level and category administration permissions. If this permissions context is at the system level, only system admins can call this method.

Specified by:
addUserPermission in interface PermissionsManager
Parameters:
user - the User to add a permission to.
permissionType - the type of permission to add.
permission - the permission to add.

addAnonymousUserPermission

public void addAnonymousUserPermission(PermissionType permissionType,
                                       long permission)
Description copied from interface: PermissionsManager
Add a permission of the specified PermissionType for anonymous users. Any registered user automatically inherits any anonymous user permissions. Only category or system administrators can assign permissions to a category, and only system admins can assign category administration permissions. If this permissions context is at the system level, only system admins can call this method.

Specified by:
addAnonymousUserPermission in interface PermissionsManager
Parameters:
permissionType - the type of permission to add.
permission - the permission to add.

addRegisteredUserPermission

public void addRegisteredUserPermission(PermissionType permissionType,
                                        long permission)
Description copied from interface: PermissionsManager
Add a permission of the specified PermissionType for registered users. "Registered Users" does not refer to the static current list of users. Instead, it dynamically matches to any member of the user database. Only category or system administrators can assign permissions to a category, and only system admins can assign category administration permissions. If this permissions context is at the system level, only system admins can call this method.

Specified by:
addRegisteredUserPermission in interface PermissionsManager
Parameters:
permissionType - the type of permission to add.
permission - the permission to add.

removeUserPermission

public void removeUserPermission(User user,
                                 PermissionType permissionType,
                                 long permission)
Description copied from interface: PermissionsManager
Removes a permission of the specified PermissionType for the specified user. Only category or system administrators can assign permissions to a category, and only system admins can assign category administration permissions. If this permissions context is at the system level, only system admins can call this method.

Specified by:
removeUserPermission in interface PermissionsManager
Parameters:
user - the User to remove a permission from.
permissionType - the type of permission to remove.

removeAnonymousUserPermission

public void removeAnonymousUserPermission(PermissionType permissionType,
                                          long permission)
Description copied from interface: PermissionsManager
Removes a permission of the specified PermissionType for anonymous users. Only category or system administrators can assign permissions to a category, and only system admins can assign category administration permissions. If this permissions context is at the system level, only system admins can call this method.

Specified by:
removeAnonymousUserPermission in interface PermissionsManager
Parameters:
permissionType - the type of permission to remove.

removeRegisteredUserPermission

public void removeRegisteredUserPermission(PermissionType permissionType,
                                           long permission)
Description copied from interface: PermissionsManager
Removes a permission of the specified PermissionType for registered users. "Registered Users" does not refer to the static current list of users. Instead, it dynamically matches to any member of the user database. Only category or system administrators can assign permissions to a category, and only system admins can assign category administration permissions. If this permissions context is at the system level, only system admins can call this method.

Specified by:
removeRegisteredUserPermission in interface PermissionsManager
Parameters:
permissionType - the type of permission to remove.

removeAllUserPermissions

public void removeAllUserPermissions(PermissionType permissionType)
Description copied from interface: PermissionsManager
Removes all user permissions. Only system administrators can call this method.

Specified by:
removeAllUserPermissions in interface PermissionsManager
Parameters:
permissionType - the type of permissions to remove.

anonymousUserHasPermission

public boolean anonymousUserHasPermission(PermissionType permissionType,
                                          long permission)
Description copied from interface: PermissionsManager
Returns true if the anonymous users have a particular permission.

Specified by:
anonymousUserHasPermission in interface PermissionsManager
Parameters:
permissionType - the type of permission to check.
permission - the permission to check.
Returns:
true if anonymous users have the specified permission.

registeredUserHasPermission

public boolean registeredUserHasPermission(PermissionType permissionType,
                                           long permission)
Description copied from interface: PermissionsManager
Returns true if registered users have a particular permission. "Registered Users" does not refer to the static current list of users. Instead, it dynamically matches to any member of the user database.

Specified by:
registeredUserHasPermission in interface PermissionsManager
Parameters:
permissionType - the type of permission to check.
permission - the permission to check.
Returns:
true if all registered users have the specified permission.

usersWithPermission

public java.util.Iterator usersWithPermission(PermissionType permissionType,
                                              long permission)
Description copied from interface: PermissionsManager
Returns all the userID's of users with a particular permission. This list does not include the special "anonymous users" and "registered users" permission types. This method is not the normal method for determining if a user has a certain permission on an object in the system; instead it is only useful for permission management. For example, to check if a user has read access on a knowledge base category, simply call category.isAuthorized(KbPermissions.READ_ENTRY), where category is the category you want to check perms on.

Specified by:
usersWithPermission in interface PermissionsManager
Parameters:
permissionType - the type of permission to check.
permission - the permission to check.
Returns:
an Iterator of all the users with the specified permission.

usersWithPermissionCount

public int usersWithPermissionCount(PermissionType permissionType,
                                    long permission)
Description copied from interface: PermissionsManager
Returns a count of the users that have a particular permission. This list does not include the special "anonymous users" and "registered users" permission types.

Specified by:
usersWithPermissionCount in interface PermissionsManager
Parameters:
permissionType - the type of permission to check.
permission - the permission to check.
Returns:
a count of the users that have a particular permission.

addGroupPermission

public void addGroupPermission(Group group,
                               PermissionType permissionType,
                               long permission)
Description copied from interface: PermissionsManager
Grants a group a particular permission. Only category or system administrators can assign permissions to a category, and only system admins can assign category administration permissions. If this permissions context is at the system level, only system admins can call this method.

Specified by:
addGroupPermission in interface PermissionsManager
Parameters:
group - the group to grant a permission to.
permissionType - the type of permission to add.
permission - the permission to grant the group.

removeGroupPermission

public void removeGroupPermission(Group group,
                                  PermissionType permissionType,
                                  long permission)
Description copied from interface: PermissionsManager
Removes a permission of the specified PermissionType for a group. Only category or system administrators can assign permissions to a category, and only system admins can assign category administration permissions. If this permissions context is at the system level, only system admins can call this method.

Specified by:
removeGroupPermission in interface PermissionsManager
Parameters:
group - the group to remove the permission from.
permissionType - the type of permission to remove.
permission - the permission to remove.

removeAllGroupPermissions

public void removeAllGroupPermissions(PermissionType permissionType)
Description copied from interface: PermissionsManager
Revokes all group permissions. Only system admins can call this method.

Specified by:
removeAllGroupPermissions in interface PermissionsManager
Parameters:
permissionType - the type of permissions to remove.

groupsWithPermission

public java.util.Iterator groupsWithPermission(PermissionType permissionType,
                                               long permission)
Description copied from interface: PermissionsManager
Returns an Iterator of groups with a particular permission.

Specified by:
groupsWithPermission in interface PermissionsManager
Parameters:
permissionType - the type of permission to check.
permission - the permission to check.
Returns:
an Iterator of all the groups with the specified permission.

groupsWithPermissionCount

public int groupsWithPermissionCount(PermissionType permissionType,
                                     long permission)
Description copied from interface: PermissionsManager
Returns a count of the groups that have a particular permission.

Specified by:
groupsWithPermissionCount in interface PermissionsManager
Parameters:
permissionType - the type of permission to check.
permission - the permission to check.
Returns:
a count of the groups that have a particular permission.

permissionModificationDetected

public void permissionModificationDetected()
Description copied from interface: PermissionsManager
Is called when a permission is modified.

Specified by:
permissionModificationDetected in interface PermissionsManager

addUserPermission

public void addUserPermission(int objectType,
                              long objectID,
                              User user,
                              PermissionType permissionType,
                              long permission)

addAnonymousUserPermission

public void addAnonymousUserPermission(int objectType,
                                       long objectID,
                                       PermissionType permissionType,
                                       long permission)

addRegisteredUserPermission

public void addRegisteredUserPermission(int objectType,
                                        long objectID,
                                        PermissionType permissionType,
                                        long permission)

removeUserPermission

public void removeUserPermission(int objectType,
                                 long objectID,
                                 User user,
                                 PermissionType permissionType,
                                 long permission)

removeAnonymousUserPermission

public void removeAnonymousUserPermission(int objectType,
                                          long objectID,
                                          PermissionType permissionType,
                                          long permission)

removeRegisteredUserPermission

public void removeRegisteredUserPermission(int objectType,
                                           long objectID,
                                           PermissionType permissionType,
                                           long permission)

removeAllUserPermissions

public void removeAllUserPermissions(int objectType,
                                     long objectID,
                                     PermissionType permissionType)

removeAllPermissions

public void removeAllPermissions(int objectType,
                                 long objectID)

removeAllPermissions

public void removeAllPermissions(java.sql.Connection con,
                                 int objectType,
                                 long objectID)
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

anonymousUserHasPermission

public boolean anonymousUserHasPermission(int objectType,
                                          long objectID,
                                          PermissionType permissionType,
                                          long permission)

registeredUserHasPermission

public boolean registeredUserHasPermission(int objectType,
                                           long objectID,
                                           PermissionType permissionType,
                                           long permission)

usersWithPermission

public java.util.Iterator usersWithPermission(int objectType,
                                              long objectID,
                                              PermissionType permissionType,
                                              long permission)

usersWithPermissionCount

public int usersWithPermissionCount(int objectType,
                                    long objectID,
                                    PermissionType permissionType,
                                    long permission)

addGroupPermission

public void addGroupPermission(int objectType,
                               long objectID,
                               Group group,
                               PermissionType permissionType,
                               long permission)

removeGroupPermission

public void removeGroupPermission(int objectType,
                                  long objectID,
                                  Group group,
                                  PermissionType permissionType,
                                  long permission)

removeAllGroupPermissions

public void removeAllGroupPermissions(int objectType,
                                      long objectID,
                                      PermissionType permissionType)

groupsWithPermission

public java.util.Iterator groupsWithPermission(int objectType,
                                               long objectID,
                                               PermissionType permissionType,
                                               long permission)

groupsWithPermissionCount

public int groupsWithPermissionCount(int objectType,
                                     long objectID,
                                     PermissionType permissionType,
                                     long permission)

hasPermissionsSet

public boolean hasPermissionsSet(int objectType,
                                 long objectID)

getFinalUserPerms

public Permissions getFinalUserPerms(int objectType,
                                     long objectID,
                                     long userID,
                                     PermissionType permissionType)
Returns the Permissions object that corresponds to the combined permissions that a user has for a particular object:


toDbFormat

public static int toDbFormat(long permission)
Converts a normal permissions value into the db format. So, converting from y to x in: 2^x=y.

Parameters:
permission - the normal permissions value.
Returns:
the db format of the permissions value.

permissionModificationDetected

public void permissionModificationDetected(int objectType,
                                           long objectID)
Sends event to the dispatcher.

Parameters:
objectType -
objectID -

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.