Class PermGrantHelper

  • All Implemented Interfaces:

    
    public class PermGrantHelper
    
                        
    Root permission is empty, so the unite result is followed by `. *`.
    `inherit` means the scopes separated by `.` is an implicit inheritance relationship.
    `grant` means binding authorization.
    
    Since:

    2021-03-07

    Author:

    trydofor

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static String ALL
      public final static String SPL
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

      • PermGrantHelper

        PermGrantHelper()
    • Method Detail

      • canInherit

         static boolean canInherit(String top, String sub)

        Whether the `top` include `sub` (sub inherit top, case-insensitive) `*` means all, Compare actions with the same name

        Parameters:
        top - e.g.
        sub - e.g.
      • canInherit

         static boolean canInherit(String top, String sub, String spl)

        Whether the `top` include `sub` (sub inherit top, case-insensitive) `*` means all, Compare actions with the same name

        Parameters:
        top - e.g.
        sub - e.g.
        spl - separator, default `.
      • inheritPerm

        @NotNull() static Set<String> inheritPerm(String permCode, Map<Long, String> permAll)

        Get the inherited permission by code. e.g. `system.menu` inherits from `system`

        Parameters:
        permCode - top perm code
        permAll - all perms id-code map
        Returns:

        inherited perms

      • inheritPerm

        @NotNull() static Set<String> inheritPerm(long permId, Map<Long, String> permAll)

        Get the inherited permission by id. e.g. `system.menu` inherits from `system`

        Parameters:
        permId - top perm id
        permAll - all perms id-code map
        Returns:

        inherited perms

      • grantRole

        @NotNull() static Set<String> grantRole(long roleId, Map<Long, String> roleAll, Map<Long, Set<Long>> roleGrant)

        Get authorized roles by id

        Parameters:
        roleId - top role id
        roleAll - all roles id-name map
        roleGrant - id-Set[id] map with inheritance
        Returns:

        inherited roles