Class RoleRepositoryProviderUtils<T extends BaseRole>

java.lang.Object
io.jmix.security.impl.role.RoleRepositoryProviderUtils<T>

@Component("sec_RoleRepositoryProviderUtils") @Scope("prototype") public class RoleRepositoryProviderUtils<T extends BaseRole> extends Object
Different implementations of RoleRepository delegate working with RoleProvider to this class. The class is responsible for searching for roles in multiple role providers, for deleting roles from providers.
  • Constructor Details

  • Method Details

    • deleteRole

      public boolean deleteRole(String roleCode)
    • getAllRoles

      public Collection<T> getAllRoles()
    • getAllRoles

      public Collection<T> getAllRoles(boolean includePolicies)
    • findRoleByCodeExcludeVisited

      public @Nullable T findRoleByCodeExcludeVisited(String roleCode, Set<String> visited, BiConsumer<T,T> roleMergingOperation)
      Finds a role by its code and merges its child roles into it, at all levels.

      The role is taken from the first provider that has it. Then each of its child roles is found the same way, with its own child roles already merged, and is passed together with the role to roleMergingOperation. The operation changes the role object returned by the provider, usually by adding the policies of the child role to the role's policies of all levels.

      The child roles of a role with the RoleSource.ANNOTATED_CLASS source are not merged, because its policies already include the policies of the role interfaces it extends.

      visited collects the codes of the roles found during the call, including roleCode. A child role whose code is already in it is skipped, so a cycle of child roles ends, and a child role that is reachable by several paths is merged only on the first path.

      Parameters:
      roleCode - the code of the role to find
      visited - the codes of the roles that must not be merged again; the method adds codes to it
      roleMergingOperation - the operation that merges a child role (second argument) into a role (first argument)
      Returns:
      the role with its child roles merged, or null if no provider has a role with this code