Class Role
- java.lang.Object
-
- com.michelin.cio.hudson.plugins.rolestrategy.Role
-
- All Implemented Interfaces:
Comparable
public final class Role extends Object implements Comparable
Class representing a role, which holds a set ofPermission
s.- Author:
- Thomas Maurel
-
-
Field Summary
Fields Modifier and Type Field Description static String
GLOBAL_ROLE_PATTERN
-
Constructor Summary
Constructors Constructor Description Role(String name, String pattern, Set<String> permissionIds, String description)
Role(String name, String pattern, Set<String> permissionIds, String description, String templateName)
Role(String name, Pattern pattern, Set<Permission> permissions, String description)
Create a Role.Role(String name, Pattern pattern, Set<Permission> permissions, String description, String templateName)
Create a Role.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
compareTo(Object o)
Compare role names.boolean
equals(Object obj)
String
getDescription()
Gets the role description.String
getName()
Getter for the role name.Pattern
getPattern()
Getter for the regexp pattern.Set<Permission>
getPermissions()
Getter for thePermission
s set.String
getTemplateName()
Boolean
hasAnyPermission(Set<Permission> permissions)
Checks if the role holds any of the givenPermission
.int
hashCode()
Boolean
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 Detail
-
GLOBAL_ROLE_PATTERN
public static final String GLOBAL_ROLE_PATTERN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Role
@DataBoundConstructor public Role(@NonNull String name, @CheckForNull String pattern, @CheckForNull Set<String> permissionIds, @CheckForNull String description, String templateName)
-
Role
public Role(@NonNull String name, @CheckForNull String pattern, @CheckForNull Set<String> permissionIds, @CheckForNull String description)
-
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 Detail
-
setTemplateName
public void setTemplateName(@CheckForNull String templateName)
-
getTemplateName
public String getTemplateName()
-
getName
public String getName()
Getter for the role name.- Returns:
- The role name
-
getPattern
public Pattern getPattern()
Getter for the regexp pattern.- Returns:
- The pattern associated to the role
-
getPermissions
public Set<Permission> 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
@CheckForNull public String getDescription()
Gets the role description.- Returns:
- Role description.
null
if not set
-
hasPermission
public Boolean hasPermission(Permission permission)
Checks if the role holds the givenPermission
.- Parameters:
permission
- The permission you want to check- Returns:
- True if the role holds this permission
-
hasAnyPermission
public Boolean hasAnyPermission(Set<Permission> permissions)
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
public int compareTo(@NonNull Object o)
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
-
-