com.arsdigita.kernel.permissions
Class PermissionCache

java.lang.Object
  extended bycom.arsdigita.kernel.permissions.PermissionCache

public final class PermissionCache
extends Object

Permissions Cache for reducing number of queries issued to the for permission checks. The data in cache stored for duration of transaction. Primary purpose of this class to reduce number of permission queries by caching all of party on object. So the subsequent calls to checkPermission don't issue queries against database even if permission check done for different PrivilegeDescriptors. The typical place to use this class is situation when UI build to show collection of objects with checks for delete, edit, etc links based on user permissions. In the following example there is only one query issued to db: Party party - current User ACSObject - some object to check permision Privilege read -read privilege Privilege write - write privilege privilege admin - admin privilege { PermissinCache permCache = PermissionCache.getInstance(); permCache.checkPermission( New PermissionDescriptor(read, obj, party)); permCache.checkPermission( New PermissionDescriptor(read, obj, party)); permCache.checkPermission( New PermissionDescriptor(write, obj, party)); permCache.checkPermission( New PermissionDescriptor(admin, obj, party)); permCache.checkPermission( New PermissionDescriptor(write, obj, party)); }

Author:
aram@kananov.com

Method Summary
 boolean checkPermission(PermissionDescriptor perm)
          Checks the permission represented by the passed in PermissionDescriptor.
static PermissionCache getInstance()
          Fetches the shared instance of the security manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static PermissionCache getInstance()
Fetches the shared instance of the security manager.

Returns:
The security manager

checkPermission

public boolean checkPermission(PermissionDescriptor perm)
Checks the permission represented by the passed in PermissionDescriptor. First looks in cache for privileges of (party,obj) tuple , if tuple is not present in the cache, only then issues query to get privileges for party on object.

Returns:
true if the PermissionDescriptor's base object has the specified permission; false otherwise.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC