Class MemoryRbacManager
- java.lang.Object
-
- org.apache.archiva.redback.rbac.AbstractRBACManager
-
- org.apache.archiva.redback.rbac.memory.MemoryRbacManager
-
- All Implemented Interfaces:
RBACManager
@Service("rbacManager#memory") public class MemoryRbacManager extends AbstractRBACManager implements RBACManagerMemoryRbacManager: a very quick and dirty implementation of a rbac store WARNING: not for actual usage, its not sound - jesse- Author:
- Jesse McConnell, Joakim Erdfelt
-
-
Field Summary
-
Fields inherited from class org.apache.archiva.redback.rbac.AbstractRBACManager
log
-
-
Constructor Summary
Constructors Constructor Description MemoryRbacManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OperationcreateOperation(String name)PermissioncreatePermission(String name)Creates an implementation specificPermission, or return an existingPermission, depending on the providednameparameter.PermissioncreatePermission(String name, String operationName, String resourceIdentifier)ResourcecreateResource(String identifier)RolecreateRole(String id, String name)Creates a new role with the given id and role name.UserAssignmentcreateUserAssignment(String principal)Creates an implementation specificUserAssignment, or return an existingUserAssignment, depending on the providedidentifierparameter.voideraseDatabase()List<Operation>getAllOperations()List<Permission>getAllPermissions()List<Resource>getAllResources()List<Role>getAllRoles()Returns all roles defined in the datastore.List<UserAssignment>getAllUserAssignments()Returns all user assignments definedStringgetDescriptionKey()OperationgetOperation(String operationName)PermissiongetPermission(String permissionName)ResourcegetResource(String resourceIdentifier)List<Resource>getResources()RolegetRole(String roleName)Returns the role identified by the given nameRolegetRoleById(String id)Returns the role identified by the given IDUserAssignmentgetUserAssignment(String principal)List<UserAssignment>getUserAssignmentsForRoles(Collection<String> roleIds)Returns the assignments for the given rolesbooleanisFinalImplementation()booleanisReadOnly()Is the RBACManager read only? if so then create and modify actions are to be disabledvoidremoveOperation(Operation operation)voidremovePermission(Permission permission)voidremoveResource(Resource resource)voidremoveRole(Role role)Removes the given role from the datastore.voidremoveUserAssignment(UserAssignment userAssignment)Method removeAssignmentOperationsaveOperation(Operation operation)Save the new or existing operation to the store.PermissionsavePermission(Permission permission)ResourcesaveResource(Resource resource)RolesaveRole(Role role)Persists the given role to the backend datastore.voidsaveRoles(Collection<Role> roles)Persists all of the given roles to the backend datastore.UserAssignmentsaveUserAssignment(UserAssignment userAssignment)Method saveUserAssignmentvoidtriggerInit()-
Methods inherited from class org.apache.archiva.redback.rbac.AbstractRBACManager
addChildRole, addListener, createRole, fireRbacInit, fireRbacPermissionRemoved, fireRbacPermissionSaved, fireRbacRoleRemoved, fireRbacRoleSaved, fireRbacUserAssignmentRemoved, fireRbacUserAssignmentSaved, getAllAssignableRoles, getAssignedPermissionMap, getAssignedPermissions, getAssignedRoles, getAssignedRoles, getChildRoleIds, getChildRoleNames, getEffectivelyAssignedRoles, getEffectivelyAssignedRoles, getEffectivelyUnassignedRoles, getEffectiveRoles, getGlobalResource, getParentRoleIds, getParentRoleNames, getRoles, getUnassignedRoles, initialize, operationExists, operationExists, permissionExists, permissionExists, removeListener, removeOperation, removePermission, removeResource, removeRole, removeRoleById, removeUserAssignment, resourceExists, resourceExists, roleExists, roleExists, roleExistsById, userAssignmentExists, userAssignmentExists
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.archiva.redback.rbac.RBACManager
addChildRole, addListener, createRole, getAllAssignableRoles, getAssignedPermissionMap, getAssignedPermissions, getAssignedRoles, getAssignedRoles, getChildRoleIds, getChildRoleNames, getEffectivelyAssignedRoles, getEffectivelyUnassignedRoles, getEffectiveRoles, getGlobalResource, getParentRoleIds, getParentRoleNames, getRoles, getUnassignedRoles, initialize, operationExists, operationExists, permissionExists, permissionExists, removeListener, removeOperation, removePermission, removeResource, removeRole, removeRoleById, removeUserAssignment, resourceExists, resourceExists, roleExists, roleExists, roleExistsById, userAssignmentExists, userAssignmentExists
-
-
-
-
Constructor Detail
-
MemoryRbacManager
public MemoryRbacManager()
-
-
Method Detail
-
saveRole
public Role saveRole(Role role) throws RbacManagerException
Description copied from interface:RBACManagerPersists the given role to the backend datastore.- Specified by:
saveRolein interfaceRBACManager- Parameters:
role- the role to save- Returns:
- the persisted role, if the method was successful
- Throws:
RbacObjectInvalidException- if the given role object was not validRbacManagerException- if the access to the backend datastore failed
-
saveRoles
public void saveRoles(Collection<Role> roles) throws RbacObjectInvalidException, RbacManagerException
Description copied from interface:RBACManagerPersists all of the given roles to the backend datastore. Implementations should try to save all role instances and throw exceptions afterwards.- Specified by:
saveRolesin interfaceRBACManager- Parameters:
roles- the list of roles to save- Throws:
RbacObjectInvalidException- if one of the given role objects was not validRbacManagerException- if the access to the backend datastore failed
-
getRole
public Role getRole(String roleName) throws RbacObjectNotFoundException
Description copied from interface:RBACManagerReturns the role identified by the given name- Specified by:
getRolein interfaceRBACManager- Parameters:
roleName- the role name- Returns:
- the role instance, if a role by this name was found
- Throws:
RbacObjectNotFoundException- if not role was found with the given name
-
getRoleById
public Role getRoleById(String id) throws RbacObjectNotFoundException, RbacManagerException
Description copied from interface:RBACManagerReturns the role identified by the given ID- Specified by:
getRoleByIdin interfaceRBACManager- Parameters:
id- the role id- Returns:
- the role object, if the role with the given id exists
- Throws:
RbacObjectNotFoundException- if no role was found with the given idRbacManagerException- if the access to the underlying datastore failed
-
removeRole
public void removeRole(Role role) throws RbacManagerException, RbacObjectNotFoundException
Description copied from interface:RBACManagerRemoves the given role from the datastore.- Specified by:
removeRolein interfaceRBACManager- Parameters:
role- the role to remove- Throws:
RbacManagerException- if the access to the backend datastore failedRbacObjectNotFoundException- if the given role was not foundRbacObjectInvalidException- if the given role has invalid data
-
getAllRoles
public List<Role> getAllRoles() throws RbacManagerException
Description copied from interface:RBACManagerReturns all roles defined in the datastore.- Specified by:
getAllRolesin interfaceRBACManager- Returns:
- the list of roles defined in the datastore
- Throws:
RbacManagerException- if the access to the backend datastore failed
-
saveOperation
public Operation saveOperation(Operation operation) throws RbacManagerException
Description copied from interface:RBACManagerSave the new or existing operation to the store.- Specified by:
saveOperationin interfaceRBACManager- Parameters:
operation- the operation to save (new or existing)- Returns:
- the Operation that was saved.
- Throws:
RbacObjectInvalidException- if the object is not valid and cannot be savedRbacManagerException- if the access to the backend datastore failed
-
savePermission
public Permission savePermission(Permission permission) throws RbacManagerException
- Specified by:
savePermissionin interfaceRBACManager- Throws:
RbacManagerException
-
saveResource
public Resource saveResource(Resource resource) throws RbacManagerException
- Specified by:
saveResourcein interfaceRBACManager- Throws:
RbacManagerException
-
saveUserAssignment
public UserAssignment saveUserAssignment(UserAssignment userAssignment) throws RbacManagerException
Description copied from interface:RBACManagerMethod saveUserAssignment- Specified by:
saveUserAssignmentin interfaceRBACManager- Parameters:
userAssignment- the user assignment instance to save- Throws:
RbacObjectInvalidException- if the instance has invalid data and cannot be savedRbacManagerException- if the access to the backend datastore failed
-
createOperation
public Operation createOperation(String name) throws RbacManagerException
Description copied from interface:RBACManagerCreates an implementation specificOperation, or return an existingOperation, depending on the providednameparameter. Note: Be sure to useRBACManager.saveOperation(Operation)in order to persist any changes to the Role.- Specified by:
createOperationin interfaceRBACManager- Parameters:
name- the name.- Returns:
- the new Operation.
- Throws:
RbacManagerException- if the access to the backend datastore failed
-
createPermission
public Permission createPermission(String name) throws RbacManagerException
Description copied from interface:RBACManagerCreates an implementation specificPermission, or return an existingPermission, depending on the providednameparameter. Note: Be sure to useRBACManager.savePermission(Permission)in order to persist any changes to the Role.- Specified by:
createPermissionin interfaceRBACManager- Parameters:
name- the name.- Returns:
- the new Permission.
- Throws:
RbacManagerException- if the access to the backend datastore failed
-
createPermission
public Permission createPermission(String name, String operationName, String resourceIdentifier) throws RbacManagerException
Description copied from interface:RBACManagerCreates an implementation specificPermissionwith specifiedOperation, andResourceidentifiers. Note: Be sure to useRBACManager.savePermission(Permission)in order to persist any changes to the Role.- Specified by:
createPermissionin interfaceRBACManager- Parameters:
name- the name.operationName- theOperation.setName(String)valueresourceIdentifier- theResource.setIdentifier(String)value- Returns:
- the new Permission.
- Throws:
RbacManagerException- if the access to the backend datastore failed
-
createResource
public Resource createResource(String identifier) throws RbacManagerException
Description copied from interface:RBACManagerCreates an implementation specificResource, or return an existingResource, depending on the providedidentifierparameter. Note: Be sure to useRBACManager.saveResource(Resource)in order to persist any changes to the Role.- Specified by:
createResourcein interfaceRBACManager- Parameters:
identifier- the identifier.- Returns:
- the new Resource.
- Throws:
RbacManagerException- if the access to the backend datastore failed
-
createRole
public Role createRole(String id, String name)
Description copied from interface:RBACManagerCreates a new role with the given id and role name.- Specified by:
createRolein interfaceRBACManager- Parameters:
id- the role identifier, which must be uniquename- the role name, which must be unique- Returns:
- the new role instance
-
getPermission
public Permission getPermission(String permissionName) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
getPermissionin interfaceRBACManager- Throws:
RbacObjectNotFoundExceptionRbacManagerException
-
getResources
public List<Resource> getResources() throws RbacManagerException
- Throws:
RbacManagerException
-
removeOperation
public void removeOperation(Operation operation) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
removeOperationin interfaceRBACManager- Throws:
RbacObjectNotFoundExceptionRbacManagerException
-
removePermission
public void removePermission(Permission permission) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
removePermissionin interfaceRBACManager- Throws:
RbacObjectNotFoundExceptionRbacManagerException
-
removeResource
public void removeResource(Resource resource) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
removeResourcein interfaceRBACManager- Throws:
RbacObjectNotFoundExceptionRbacManagerException
-
removeUserAssignment
public void removeUserAssignment(UserAssignment userAssignment) throws RbacObjectNotFoundException, RbacManagerException
Description copied from interface:RBACManagerMethod removeAssignment- Specified by:
removeUserAssignmentin interfaceRBACManager- Parameters:
userAssignment- the assignment to remove- Throws:
RbacObjectNotFoundException- if the assignment was not foundRbacObjectInvalidException- if the provided assignment instance has invalid dataRbacManagerException- if the access to the backend datastore failed
-
eraseDatabase
public void eraseDatabase()
- Specified by:
eraseDatabasein interfaceRBACManager
-
createUserAssignment
public UserAssignment createUserAssignment(String principal) throws RbacManagerException
Description copied from interface:RBACManagerCreates an implementation specificUserAssignment, or return an existingUserAssignment, depending on the providedidentifierparameter. Note: Be sure to useRBACManager.saveUserAssignment(UserAssignment)in order to persist any changes to the Role.- Specified by:
createUserAssignmentin interfaceRBACManager- Parameters:
principal- the principal reference to the user.- Returns:
- the new UserAssignment object.
- Throws:
RbacManagerException- if the access to the backend datastore failed
-
getAllOperations
public List<Operation> getAllOperations() throws RbacManagerException
- Specified by:
getAllOperationsin interfaceRBACManager- Throws:
RbacManagerException
-
getAllPermissions
public List<Permission> getAllPermissions() throws RbacManagerException
- Specified by:
getAllPermissionsin interfaceRBACManager- Throws:
RbacManagerException
-
getAllResources
public List<Resource> getAllResources() throws RbacManagerException
- Specified by:
getAllResourcesin interfaceRBACManager- Throws:
RbacManagerException
-
getAllUserAssignments
public List<UserAssignment> getAllUserAssignments() throws RbacManagerException
Description copied from interface:RBACManagerReturns all user assignments defined- Specified by:
getAllUserAssignmentsin interfaceRBACManager- Returns:
- list of assignments
- Throws:
RbacManagerException- if the access to the backend datastore failed
-
getUserAssignmentsForRoles
public List<UserAssignment> getUserAssignmentsForRoles(Collection<String> roleIds) throws RbacManagerException
Description copied from interface:RBACManagerReturns the assignments for the given roles- Specified by:
getUserAssignmentsForRolesin interfaceRBACManager- Parameters:
roleIds- collection of role names- Throws:
RbacManagerException- if the access to the backend datastore failed
-
getUserAssignment
public UserAssignment getUserAssignment(String principal) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
getUserAssignmentin interfaceRBACManager- Throws:
RbacObjectNotFoundExceptionRbacManagerException
-
getOperation
public Operation getOperation(String operationName) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
getOperationin interfaceRBACManager- Throws:
RbacObjectNotFoundExceptionRbacManagerException
-
getResource
public Resource getResource(String resourceIdentifier) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
getResourcein interfaceRBACManager- Throws:
RbacObjectNotFoundExceptionRbacManagerException
-
triggerInit
public void triggerInit()
-
isFinalImplementation
public boolean isFinalImplementation()
- Specified by:
isFinalImplementationin interfaceRBACManager- Overrides:
isFinalImplementationin classAbstractRBACManager- Returns:
- true if this implementation is a final one and not a wrapper (configurable, cached)
-
getDescriptionKey
public String getDescriptionKey()
- Specified by:
getDescriptionKeyin interfaceRBACManager- Returns:
- a key to be able to customize label in UI
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:RBACManagerIs the RBACManager read only? if so then create and modify actions are to be disabled- Specified by:
isReadOnlyin interfaceRBACManager- Returns:
- boolean true if user manager is read only
-
-