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 RBACManager
MemoryRbacManager: 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 Operation
createOperation(String name)
Permission
createPermission(String name)
Creates an implementation specificPermission
, or return an existingPermission
, depending on the providedname
parameter.Permission
createPermission(String name, String operationName, String resourceIdentifier)
Resource
createResource(String identifier)
Role
createRole(String id, String name)
Creates a new role with the given id and role name.UserAssignment
createUserAssignment(String principal)
Creates an implementation specificUserAssignment
, or return an existingUserAssignment
, depending on the providedidentifier
parameter.void
eraseDatabase()
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 definedString
getDescriptionKey()
Operation
getOperation(String operationName)
Permission
getPermission(String permissionName)
Resource
getResource(String resourceIdentifier)
List<Resource>
getResources()
Role
getRole(String roleName)
Returns the role identified by the given nameRole
getRoleById(String id)
Returns the role identified by the given IDUserAssignment
getUserAssignment(String principal)
List<UserAssignment>
getUserAssignmentsForRoles(Collection<String> roleIds)
Returns the assignments for the given rolesboolean
isFinalImplementation()
boolean
isReadOnly()
Is the RBACManager read only? if so then create and modify actions are to be disabledvoid
removeOperation(Operation operation)
void
removePermission(Permission permission)
void
removeResource(Resource resource)
void
removeRole(Role role)
Removes the given role from the datastore.void
removeUserAssignment(UserAssignment userAssignment)
Method removeAssignmentOperation
saveOperation(Operation operation)
Save the new or existing operation to the store.Permission
savePermission(Permission permission)
Resource
saveResource(Resource resource)
Role
saveRole(Role role)
Persists the given role to the backend datastore.void
saveRoles(Collection<Role> roles)
Persists all of the given roles to the backend datastore.UserAssignment
saveUserAssignment(UserAssignment userAssignment)
Method saveUserAssignmentvoid
triggerInit()
-
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:RBACManager
Persists the given role to the backend datastore.- Specified by:
saveRole
in 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:RBACManager
Persists all of the given roles to the backend datastore. Implementations should try to save all role instances and throw exceptions afterwards.- Specified by:
saveRoles
in 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:RBACManager
Returns the role identified by the given name- Specified by:
getRole
in 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:RBACManager
Returns the role identified by the given ID- Specified by:
getRoleById
in 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:RBACManager
Removes the given role from the datastore.- Specified by:
removeRole
in 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:RBACManager
Returns all roles defined in the datastore.- Specified by:
getAllRoles
in 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:RBACManager
Save the new or existing operation to the store.- Specified by:
saveOperation
in 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:
savePermission
in interfaceRBACManager
- Throws:
RbacManagerException
-
saveResource
public Resource saveResource(Resource resource) throws RbacManagerException
- Specified by:
saveResource
in interfaceRBACManager
- Throws:
RbacManagerException
-
saveUserAssignment
public UserAssignment saveUserAssignment(UserAssignment userAssignment) throws RbacManagerException
Description copied from interface:RBACManager
Method saveUserAssignment- Specified by:
saveUserAssignment
in 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:RBACManager
Creates an implementation specificOperation
, or return an existingOperation
, depending on the providedname
parameter. Note: Be sure to useRBACManager.saveOperation(Operation)
in order to persist any changes to the Role.- Specified by:
createOperation
in 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:RBACManager
Creates an implementation specificPermission
, or return an existingPermission
, depending on the providedname
parameter. Note: Be sure to useRBACManager.savePermission(Permission)
in order to persist any changes to the Role.- Specified by:
createPermission
in 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:RBACManager
Creates an implementation specificPermission
with specifiedOperation
, andResource
identifiers. Note: Be sure to useRBACManager.savePermission(Permission)
in order to persist any changes to the Role.- Specified by:
createPermission
in 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:RBACManager
Creates an implementation specificResource
, or return an existingResource
, depending on the providedidentifier
parameter. Note: Be sure to useRBACManager.saveResource(Resource)
in order to persist any changes to the Role.- Specified by:
createResource
in 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:RBACManager
Creates a new role with the given id and role name.- Specified by:
createRole
in 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:
getPermission
in interfaceRBACManager
- Throws:
RbacObjectNotFoundException
RbacManagerException
-
getResources
public List<Resource> getResources() throws RbacManagerException
- Throws:
RbacManagerException
-
removeOperation
public void removeOperation(Operation operation) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
removeOperation
in interfaceRBACManager
- Throws:
RbacObjectNotFoundException
RbacManagerException
-
removePermission
public void removePermission(Permission permission) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
removePermission
in interfaceRBACManager
- Throws:
RbacObjectNotFoundException
RbacManagerException
-
removeResource
public void removeResource(Resource resource) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
removeResource
in interfaceRBACManager
- Throws:
RbacObjectNotFoundException
RbacManagerException
-
removeUserAssignment
public void removeUserAssignment(UserAssignment userAssignment) throws RbacObjectNotFoundException, RbacManagerException
Description copied from interface:RBACManager
Method removeAssignment- Specified by:
removeUserAssignment
in 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:
eraseDatabase
in interfaceRBACManager
-
createUserAssignment
public UserAssignment createUserAssignment(String principal) throws RbacManagerException
Description copied from interface:RBACManager
Creates an implementation specificUserAssignment
, or return an existingUserAssignment
, depending on the providedidentifier
parameter. Note: Be sure to useRBACManager.saveUserAssignment(UserAssignment)
in order to persist any changes to the Role.- Specified by:
createUserAssignment
in 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:
getAllOperations
in interfaceRBACManager
- Throws:
RbacManagerException
-
getAllPermissions
public List<Permission> getAllPermissions() throws RbacManagerException
- Specified by:
getAllPermissions
in interfaceRBACManager
- Throws:
RbacManagerException
-
getAllResources
public List<Resource> getAllResources() throws RbacManagerException
- Specified by:
getAllResources
in interfaceRBACManager
- Throws:
RbacManagerException
-
getAllUserAssignments
public List<UserAssignment> getAllUserAssignments() throws RbacManagerException
Description copied from interface:RBACManager
Returns all user assignments defined- Specified by:
getAllUserAssignments
in 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:RBACManager
Returns the assignments for the given roles- Specified by:
getUserAssignmentsForRoles
in 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:
getUserAssignment
in interfaceRBACManager
- Throws:
RbacObjectNotFoundException
RbacManagerException
-
getOperation
public Operation getOperation(String operationName) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
getOperation
in interfaceRBACManager
- Throws:
RbacObjectNotFoundException
RbacManagerException
-
getResource
public Resource getResource(String resourceIdentifier) throws RbacObjectNotFoundException, RbacManagerException
- Specified by:
getResource
in interfaceRBACManager
- Throws:
RbacObjectNotFoundException
RbacManagerException
-
triggerInit
public void triggerInit()
-
isFinalImplementation
public boolean isFinalImplementation()
- Specified by:
isFinalImplementation
in interfaceRBACManager
- Overrides:
isFinalImplementation
in classAbstractRBACManager
- Returns:
- true if this implementation is a final one and not a wrapper (configurable, cached)
-
getDescriptionKey
public String getDescriptionKey()
- Specified by:
getDescriptionKey
in interfaceRBACManager
- Returns:
- a key to be able to customize label in UI
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:RBACManager
Is the RBACManager read only? if so then create and modify actions are to be disabled- Specified by:
isReadOnly
in interfaceRBACManager
- Returns:
- boolean true if user manager is read only
-
-