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 of Permissions.
Author:
Thomas Maurel
  • Field Details

  • Constructor Details

    • 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 name
      pattern - The pattern matching AccessControlled objects names
      permissions - The Permissions 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 name
      pattern - The pattern matching AccessControlled objects names
      permissions - The Permissions associated to the role. null permissions will be ignored.
      description - A description for the role
      templateName - True to mark this role as generated
  • Method Details

    • 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 the Permissions set.
      Returns:
      Permissions set
    • refreshPermissionsFromTemplate

      @Deprecated public void refreshPermissionsFromTemplate(Collection<PermissionTemplate> permissionTemplates)
      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 given Permission.
      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 given Permission.
      Parameters:
      permissions - A Permissions set
      Returns:
      True if the role holds any of the given Permissions
    • 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 interface Comparable
      Parameters:
      o - The object you want to compare this instance to
      Returns:
      Comparison of role names
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object