Package org.apache.fulcrum.security.spi
Class AbstractPermissionManager
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.fulcrum.security.spi.AbstractManager
-
- org.apache.fulcrum.security.spi.AbstractEntityManager
-
- org.apache.fulcrum.security.spi.AbstractPermissionManager
-
- All Implemented Interfaces:
Serializable
,org.apache.avalon.framework.activity.Disposable
,org.apache.avalon.framework.configuration.Configurable
,org.apache.avalon.framework.logger.LogEnabled
,org.apache.avalon.framework.service.Serviceable
,org.apache.avalon.framework.thread.ThreadSafe
,PermissionManager
public abstract class AbstractPermissionManager extends AbstractEntityManager implements PermissionManager
This implementation keeps all objects in memory. This is mostly meant to help with testing and prototyping of ideas.- Version:
- $Id: AbstractPermissionManager.java 1372918 2012-08-14 15:19:40Z tv $
- Author:
- Eric Pugh
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.fulcrum.security.spi.AbstractManager
manager
-
Fields inherited from interface org.apache.fulcrum.security.PermissionManager
ROLE
-
-
Constructor Summary
Constructors Constructor Description AbstractPermissionManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T extends Permission>
TaddPermission(T permission)
Creates a new permission with specified attributes.boolean
checkExists(Permission permission)
Check whether a specified permission exists.<T extends Permission>
TgetPermissionById(Object id)
Retrieve a Permission object with specified Id.<T extends Permission>
TgetPermissionByName(String name)
Retrieve a Permission object with specified name.<T extends Permission>
TgetPermissionInstance()
Construct a blank Permission object.<T extends Permission>
TgetPermissionInstance(String permName)
Construct a blank Permission object.protected abstract <T extends Permission>
TpersistNewPermission(T permission)
-
Methods inherited from class org.apache.fulcrum.security.spi.AbstractEntityManager
configure, getClassName, setClassName
-
Methods inherited from class org.apache.fulcrum.security.spi.AbstractManager
dispose, getGroupManager, getPermissionManager, getRoleManager, getServiceManager, getUserManager, release, resolve, service
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.fulcrum.security.PermissionManager
checkExists, getAllPermissions, removePermission, renamePermission
-
-
-
-
Constructor Detail
-
AbstractPermissionManager
public AbstractPermissionManager()
-
-
Method Detail
-
persistNewPermission
protected abstract <T extends Permission> T persistNewPermission(T permission) throws DataBackendException
- Throws:
DataBackendException
-
getPermissionInstance
public <T extends Permission> T getPermissionInstance() throws DataBackendException
Construct a blank Permission object. This method calls getPermissionClass, and then creates a new object using the default constructor.- Specified by:
getPermissionInstance
in interfacePermissionManager
- Type Parameters:
T
- permission type- Returns:
- an object implementing Permission interface.
- Throws:
DataBackendException
- if the object could not be instantiated.
-
getPermissionInstance
public <T extends Permission> T getPermissionInstance(String permName) throws DataBackendException
Construct a blank Permission object. This method calls getPermissionClass, and then creates a new object using the default constructor.- Specified by:
getPermissionInstance
in interfacePermissionManager
- Type Parameters:
T
- permission type- Parameters:
permName
- The name of the permission.- Returns:
- an object implementing Permission interface.
- Throws:
DataBackendException
- if the object could not be instantiated.
-
getPermissionByName
public <T extends Permission> T getPermissionByName(String name) throws DataBackendException, UnknownEntityException
Retrieve a Permission object with specified name.- Specified by:
getPermissionByName
in interfacePermissionManager
- Type Parameters:
T
- permission type- Parameters:
name
- the name of the Permission.- Returns:
- an object representing the Permission with specified name.
- Throws:
DataBackendException
- if there was an error accessing the data backend.UnknownEntityException
- if the permission does not exist.
-
getPermissionById
public <T extends Permission> T getPermissionById(Object id) throws DataBackendException, UnknownEntityException
Retrieve a Permission object with specified Id.- Specified by:
getPermissionById
in interfacePermissionManager
- Type Parameters:
T
- permission type- Parameters:
id
- the ID of the Permission.- Returns:
- an object representing the Permission with specified name.
- Throws:
UnknownEntityException
- if the permission does not exist in the database.DataBackendException
- if there is a problem accessing the storage.
-
addPermission
public <T extends Permission> T addPermission(T permission) throws DataBackendException, EntityExistsException
Creates a new permission with specified attributes.- Specified by:
addPermission
in interfacePermissionManager
- Parameters:
permission
- the object describing the permission to be created.- Returns:
- a new Permission object that has id set up properly.
- Throws:
DataBackendException
- if there was an error accessing the data backend.EntityExistsException
- if the permission already exists.
-
checkExists
public boolean checkExists(Permission permission) throws DataBackendException
Check whether a specified permission exists. The name is used for looking up the permission- Specified by:
checkExists
in interfacePermissionManager
- Parameters:
permission
- The permission to be checked.- Returns:
- true if the specified permission exists
- Throws:
DataBackendException
- if there was an error accessing the data backend.
-
-