Interface RoleMapper

  • All Known Implementing Classes:
    MappedRoleMapper, RegexRoleMapper
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface RoleMapper
    A role mapper is responsible for mapping roles based on their raw form.

    Roles are basically represented as String values, where these values are their names. Role mapping allows to transform roles from their raw form (eg.: just like they were loaded from a identity store such as a database or LDAP server) in a more consistent form.

    Author:
    Pedro Igor
    • Field Detail

      • IDENTITY_ROLE_MAPPER

        static final RoleMapper IDENTITY_ROLE_MAPPER
        A default implementation that does nothing but return the given roles.
    • Method Detail

      • mapRoles

        Roles mapRoles​(Roles rolesToMap)
        Returns a set of strings representing the roles mapped from the given roles in their raw form.
        Parameters:
        rolesToMap - the roles in their raw form to apply mapping
        Returns:
        the mapped role set
      • and

        default RoleMapper and​(RoleMapper other)
        Create a role mapper which is the intersection (logical "and") of the results of this and the given role mapper.
        Parameters:
        other - the other role mapper
        Returns:
        the intersection role mapper
      • or

        default RoleMapper or​(RoleMapper other)
        Create a role mapper which is the union (logical "or") of the results of this and the given role mapper.
        Parameters:
        other - the other role mapper
        Returns:
        the union role mapper
      • xor

        default RoleMapper xor​(RoleMapper other)
        Create a role mapper which is the symmetric difference (or disjunction, or logical "xor") of the results of this and the given role mapper.
        Parameters:
        other - the other role mapper
        Returns:
        the difference role mapper
      • minus

        default RoleMapper minus​(RoleMapper other)
        Create a role mapper which contains all the roles mapped by this mapper, minus the roles mapped by the given role mapper.
        Parameters:
        other - the other role mapper
        Returns:
        the difference role mapper
      • aggregate

        static RoleMapper aggregate​(RoleMapper mapper1,
                                    RoleMapper mapper2)
        Create an aggregate role mapper. Each role mapper is applied in order.
        Parameters:
        mapper1 - the first role mapper to apply (must not be null)
        mapper2 - the second role mapper to apply (must not be null)
        Returns:
        the aggregate role mapper (not null)
      • aggregate

        static RoleMapper aggregate​(RoleMapper... mappers)
        Create an aggregate role mapper. Each role mapper is applied in order.
        Parameters:
        mappers - the role mappers to apply (most not be null or contain null elements)
        Returns:
        the aggregate role mapper (not null)
      • constant

        static RoleMapper constant​(Roles roles)
        Create a role mapper that always returns the same set of roles regardless of the input.
        Parameters:
        roles - the set of roles to always be returned (must not be null)
        Returns:
        the constant role mapper (not null)