Class PermissionHelper

java.lang.Object
org.jenkinsci.plugins.rolestrategy.permissions.PermissionHelper

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public class PermissionHelper extends Object
Helper methods for dangerous permission handling.
Author:
Oleg Nenashev
  • Field Details

    • DANGEROUS_PERMISSIONS

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static final Set<Permission> DANGEROUS_PERMISSIONS
      List of the dangerous permissions, which need to be suppressed by the plugin.
  • Method Details

    • fromStrings

      @NonNull public static Set<Permission> fromStrings(@CheckForNull Collection<String> permissionStrings, boolean allowPermissionId)
      Convert a set of string to a collection of permissions. Dangerous and non-solvable permissions are ignored
      Parameters:
      permissionStrings - A list of Permission IDs or UI names.
      allowPermissionId - Allow to resolve the permission from the ID.
      Returns:
      Created set of permissions
    • isDangerous

      public static boolean isDangerous(Permission p)
      Check if the permissions is dangerous.
      Parameters:
      p - Permission
      Returns:
      true if the permission is considered as dangerous.
    • findPermission

      @CheckForNull public static Permission findPermission(String id)
      Attempt to match a given permission to what is defined in the UI.
      Parameters:
      id - String of the form "Title/Permission" (Look in the UI) for a particular permission
      Returns:
      a matched permission
    • findPermissionId

      @CheckForNull public static String findPermissionId(String id)
      Attempt to match a given permission to what is defined in the UI.
      Parameters:
      id - String of the form "Title/Permission" (Look in the UI) for a particular permission
      Returns:
      a matched permission ID
    • resolvePermissionFromString

      @CheckForNull public static Permission resolvePermissionFromString(String id)
      Attempt to match a given permission to what is defined in the UI or from the ID representation used in the config.xml
      Parameters:
      id - String of the form "Title/Permission" (Look in the UI) for a particular permission or in the form used in the config.xml
      Returns:
      a matched permission, null if permission couldn't be resolved or is dangerous