Class Role
java.lang.Object
com.michelin.cio.hudson.plugins.rolestrategy.Role
- All Implemented Interfaces:
Comparable
Class representing a role, which holds a set of
Permission
s.- Author:
- Thomas Maurel
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Compare role names.boolean
Gets the role description.getName()
Getter for the role name.Getter for the regexp pattern.Getter for thePermission
s set.hasAnyPermission
(Set<Permission> permissions) Checks if the role holds any of the givenPermission
.int
hashCode()
hasPermission
(Permission permission) Checks if the role holds the givenPermission
.void
refreshPermissionsFromTemplate
(PermissionTemplate permissionTemplate) Updates the permissions from the given template.void
refreshPermissionsFromTemplate
(Collection<PermissionTemplate> permissionTemplates) Deprecated.void
setTemplateName
(String templateName)
-
Field Details
-
GLOBAL_ROLE_PATTERN
- See Also:
-
-
Constructor Details
-
Role
-
Role
-
Role
public Role(String name, Pattern pattern, Set<Permission> permissions, @CheckForNull String description) Create a Role.- Parameters:
name
- The role namepattern
- The pattern matchingAccessControlled
objects namespermissions
- ThePermission
s associated to the role.null
permissions will be ignored.description
- A description for the role
-
Role
public Role(String name, Pattern pattern, Set<Permission> permissions, @CheckForNull String description, String templateName) Create a Role.- Parameters:
name
- The role namepattern
- The pattern matchingAccessControlled
objects namespermissions
- ThePermission
s associated to the role.null
permissions will be ignored.description
- A description for the roletemplateName
- True to mark this role as generated
-
-
Method Details
-
setTemplateName
-
getTemplateName
-
getName
Getter for the role name.- Returns:
- The role name
-
getPattern
Getter for the regexp pattern.- Returns:
- The pattern associated to the role
-
getPermissions
Getter for thePermission
s set.- Returns:
Permission
s set
-
refreshPermissionsFromTemplate
@Deprecated public void refreshPermissionsFromTemplate(Collection<PermissionTemplate> permissionTemplates) Deprecated.Updates the permissions from the template matching the name.- Parameters:
permissionTemplates
- List of templates to look for
-
refreshPermissionsFromTemplate
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void refreshPermissionsFromTemplate(@CheckForNull PermissionTemplate permissionTemplate) Updates the permissions from the given template. The name of the given template must match the configured template name in the role.- Parameters:
permissionTemplate
- PermissionTemplate
-
getDescription
Gets the role description.- Returns:
- Role description.
null
if not set
-
hasPermission
Checks if the role holds the givenPermission
.- Parameters:
permission
- The permission you want to check- Returns:
- True if the role holds this permission
-
hasAnyPermission
Checks if the role holds any of the givenPermission
.- Parameters:
permissions
- APermission
s set- Returns:
- True if the role holds any of the given
Permission
s
-
compareTo
Compare role names. Used to sort the sets. We presume that any role name is being used once and only once.- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- The object you want to compare this instance to- Returns:
- Comparison of role names
-
hashCode
public int hashCode() -
equals
-
refreshPermissionsFromTemplate(PermissionTemplate)