Qizx/db 2.1 API

com.qizx.api.util.accesscontrol
Class AccessControlBase

java.lang.Object
  extended bycom.qizx.api.util.accesscontrol.AccessControlBase
All Implemented Interfaces:
AccessControl
Direct Known Subclasses:
UnixStyleAccessControl

public abstract class AccessControlBase
extends Object
implements AccessControl

Base implementation of AccessControl usable for custom implementations.

This implementation offers a cache to speed-up access to permissions from a Library member.

Permissions are a mask of basic permissions CONTENT_READ, CONTENT_CHANGE, PROPERTY_READ, PROPERTY_CHANGE corresponding to the methods of AccessControl.

A concrete subclass needs to implement the method computePermissions() which return the permission mask each time a member is not found in the cache.


Field Summary
protected static int CONTENT_CHANGE
          Cached permission flag associated with a Library member
protected static int CONTENT_READ
          Cached permission flag associated with a Library member
protected static int DEFINED
          Cached flag associated with a Library member: indicates that permissions are defined.
protected static int PROPERTY_CHANGE
          Cached permission flag associated with a Library member
protected static int PROPERTY_READ
          Cached permission flag associated with a Library member
 
Constructor Summary
protected AccessControlBase(int cacheSize)
          Default constructor.
 
Method Summary
protected  void cachePermissions(LibraryMember member, int perms)
          Cached permissions for a Library member.
protected  void clearPermissions(LibraryMember member)
          Erases permission from cache to force recomputation.
protected abstract  int computePermissions(LibraryMember member, User user)
          This method should be implemented by a concrete subclass: it is called when a library member is not found in cache.
protected  int findPermissions(User user, LibraryMember member)
          General method to obtain the permissions for a given user.
protected  int getCachedPermissions(LibraryMember member)
          Gets cached permissions for a member.
protected  int getCacheSize()
          Returns the current permission cache size.
 void reset()
          Resets the internal state when the Library session is updated by a commit(), rollback(), refresh() or lock().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.qizx.api.AccessControl
copy, mayChangeContent, mayChangeProperty, mayReadContent, mayReadProperty
 

Field Detail

DEFINED

protected static final int DEFINED
Cached flag associated with a Library member: indicates that permissions are defined.

See Also:
Constant Field Values

CONTENT_READ

protected static final int CONTENT_READ
Cached permission flag associated with a Library member

See Also:
Constant Field Values

CONTENT_CHANGE

protected static final int CONTENT_CHANGE
Cached permission flag associated with a Library member

See Also:
Constant Field Values

PROPERTY_READ

protected static final int PROPERTY_READ
Cached permission flag associated with a Library member

See Also:
Constant Field Values

PROPERTY_CHANGE

protected static final int PROPERTY_CHANGE
Cached permission flag associated with a Library member

See Also:
Constant Field Values
Constructor Detail

AccessControlBase

protected AccessControlBase(int cacheSize)
Default constructor.

Method Detail

getCacheSize

protected int getCacheSize()
Returns the current permission cache size.

Returns:
the current permission cache size.

reset

public void reset()
Description copied from interface: AccessControl
Resets the internal state when the Library session is updated by a commit(), rollback(), refresh() or lock().

This method typically clears internal permission caches in order to recompute permissions properly.

Specified by:
reset in interface AccessControl

findPermissions

protected int findPermissions(User user,
                              LibraryMember member)
General method to obtain the permissions for a given user. First looks up in the cache and if not found calls the computePermissions() method.

Parameters:
user - the user associated with the XML Library session that owns this access control. It should never change.
member - concerned object of the Library
Returns:
a mask of basic permissions CONTENT_READ, CONTENT_CHANGE, PROPERTY_READ, PROPERTY_CHANGE

computePermissions

protected abstract int computePermissions(LibraryMember member,
                                          User user)
                                   throws DataModelException
This method should be implemented by a concrete subclass: it is called when a library member is not found in cache.

Parameters:
member - concerned object of the Library
user - user concerned by the access control
Returns:
a mask of basic permissions CONTENT_READ, CONTENT_CHANGE, PROPERTY_READ, PROPERTY_CHANGE
Throws:
DataModelException - if access problem

getCachedPermissions

protected int getCachedPermissions(LibraryMember member)
Gets cached permissions for a member. Returns 0 if not found (not cached). Otherwise returns a mask of permissions set by cachePermissions(LibraryMember, int) (CONTENT_READ etc)

Parameters:
member - library member of interest
Returns:
a mask of permissions

cachePermissions

protected void cachePermissions(LibraryMember member,
                                int perms)
Cached permissions for a Library member.

Parameters:
member - library member of interest
perms - a mask like returned by findPermissions

clearPermissions

protected void clearPermissions(LibraryMember member)
Erases permission from cache to force recomputation.

Parameters:
member - library member of interest

© 2008 Axyana Software