Package org.apache.archiva.redback.rbac
Interface Role
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractRole
,JpaRole
,MemoryRole
public interface Role extends Serializable
Role A role is assignable to a user and effectively grants that user all of the permissions that are present in that role. A role can also contain other roles which add the permissions in those roles to the available permissions for authorization. A role can contain any number of permissions A role can contain any number of other roles A role can be assigned to any number of users- Author:
- Jesse McConnell, Joakim Erdfelt, Martin Stockhammer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addChildRole(Role child)
Adds a child role and sets the list of child names and child ids.void
addChildRoleId(String id)
Adds a child role idvoid
addChildRoleName(String name)
Adds a role to the list of child rolesvoid
addPermission(Permission permission)
Adds a permission to the listList<String>
getChildRoleIds()
Returns the child role idsList<String>
getChildRoleNames()
Returns the list of child rolesString
getDescription()
Long description of the role.String
getId()
The role identifier.default String
getModelId()
Returns the model the role is derived from.String
getName()
Get the name.List<? extends Permission>
getPermissions()
Returns the list of permissions assigned to this role.default String
getResource()
Returns the resource that is used to build this role from a template.boolean
hasChildRoles()
Convenience method to see if Role has Child Roles.boolean
isAssignable()
True
, if this role is available to be assigned to a user, otherwisefalse
.boolean
isPermanent()
Test to see if the object is a permanent object or not.default boolean
isTemplateInstance()
Returnstrue
, if this role is a instance of a template role, otherwisefalse
.void
removePermission(Permission permission)
Removes the given permission from the list.void
setAssignable(boolean assignable)
Set totrue
, if this role should available to be assigned to a uservoid
setChildRoleIds(List<String> ids)
Sets the list of child role idsvoid
setChildRoleNames(List<String> names)
Sets the names of children roles.void
setDescription(String description)
Set the Descriptionvoid
setId(String id)
Sets the role idvoid
setModelId(String modelId)
Sets the model id.void
setName(String name)
Set the role name NOTE: This field is considered the Primary Key for this object.void
setPermanent(boolean permanent)
Set flag indicating if the object is a permanent object or not.void
setPermissions(List<Permission> permissions)
Set role permissions.void
setResource(String resource)
Sets the resource, this template instance is attached to.void
setTemplateInstance(boolean templateInstanceFlag)
Sets the template instance flag.
-
-
-
Method Detail
-
addPermission
void addPermission(Permission permission)
Adds a permission to the list- Parameters:
permission
- the permission to add to the list
-
addChildRoleName
void addChildRoleName(String name)
Adds a role to the list of child roles- Parameters:
name
- the name of the child role.
-
getChildRoleNames
List<String> getChildRoleNames()
Returns the list of child roles
-
addChildRole
void addChildRole(Role child)
Adds a child role and sets the list of child names and child ids.- Parameters:
child
- the child role
-
addChildRoleId
void addChildRoleId(String id)
Adds a child role id- Parameters:
id
- the id
-
getChildRoleIds
List<String> getChildRoleIds()
Returns the child role ids- Returns:
- the list of child role ids
-
hasChildRoles
boolean hasChildRoles()
Convenience method to see if Role has Child Roles.- Returns:
- true if child roles exists and has any roles being tracked.
-
getDescription
String getDescription()
Long description of the role.- Returns:
- the role description
-
getName
String getName()
Get the name. Must be unique. NOTE: This field is considered the Primary Key for this object.- Returns:
- the name of the role
-
getPermissions
List<? extends Permission> getPermissions()
Returns the list of permissions assigned to this role.- Returns:
- the list of permissions assigned to this role
-
isAssignable
boolean isAssignable()
True
, if this role is available to be assigned to a user, otherwisefalse
.- Returns:
true
, if this role can be assigned to users, otherwisefalse
-
removePermission
void removePermission(Permission permission)
Removes the given permission from the list. If the permission does not exist in the list of assigned permissions, nothing happens.- Parameters:
permission
- the permission to remove.
-
setAssignable
void setAssignable(boolean assignable)
Set totrue
, if this role should available to be assigned to a user- Parameters:
assignable
- the assignable flag
-
setChildRoleNames
void setChildRoleNames(List<String> names)
Sets the names of children roles. Children roles inherit the permissions of the parent role.- Parameters:
names
- the list of names of child roles.
-
setChildRoleIds
void setChildRoleIds(List<String> ids)
Sets the list of child role ids- Parameters:
ids
-
-
setDescription
void setDescription(String description)
Set the Description- Parameters:
description
- the role description
-
setName
void setName(String name)
Set the role name NOTE: This field is considered the Primary Key for this object.- Parameters:
name
- the role name
-
setPermissions
void setPermissions(List<Permission> permissions)
Set role permissions. The list of assigned permissions is replaced by this list.- Parameters:
permissions
- the permissions to set
-
isPermanent
boolean isPermanent()
Test to see if the object is a permanent object or not.- Returns:
true
, if the object is permanent.
-
setPermanent
void setPermanent(boolean permanent)
Set flag indicating if the object is a permanent object or not.- Parameters:
permanent
- true if the object is permanent.
-
getId
String getId()
The role identifier. Should be built from the modelId and the resource. And must be unique.- Returns:
- the role identifier
- Since:
- 3.0
-
setId
void setId(String id)
Sets the role id- Parameters:
id
- the identifier of the role, should not be null or empty.- Since:
- 3.0
-
getModelId
default String getModelId()
Returns the model the role is derived from.- Returns:
- The model id or empty string, if this role was not created from a model
- Since:
- 3.0
-
setModelId
void setModelId(String modelId)
Sets the model id.- Parameters:
modelId
- the identifier of the model, or empty string. Should not be null.
-
isTemplateInstance
default boolean isTemplateInstance()
Returnstrue
, if this role is a instance of a template role, otherwisefalse
. Templated roles are built from a template together with a resource identifier.- Returns:
true
, if this role is a templated role, otherwisefalse
- Since:
- 3.0
-
setTemplateInstance
void setTemplateInstance(boolean templateInstanceFlag)
Sets the template instance flag.- Parameters:
templateInstanceFlag
- Set totrue
, if this is a template instance, otherwisefalse
- Since:
- 3.0
-
getResource
default String getResource()
Returns the resource that is used to build this role from a template. If this is not a templated role, a empty string should be returned.- Returns:
- the resource identifier, used to build this role or a empty string, if this role is not templated
- Since:
- 3.0
-
setResource
void setResource(String resource)
Sets the resource, this template instance is attached to.- Parameters:
resource
- the resource identifier. Must not be null.
-
-