Interface RealmMapper

  • All Known Implementing Classes:
    MappedRegexRealmMapper, SimpleRegexRealmMapper
    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 RealmMapper
    A realm mapper. Examines authentication identity information and translates it into a realm name. If the realm mapper does not recognize the authentication information, a default realm will be chosen.
    Author:
    David M. Lloyd
    • Field Detail

      • DEFAULT_REALM_MAPPER

        static final RealmMapper DEFAULT_REALM_MAPPER
        A realm mapper which always falls back to a default realm.
    • Method Detail

      • getRealmMapping

        String getRealmMapping​(Principal principal,
                               Evidence evidence)
        Get the realm mapping. Return null if the default realm should be used.
        Parameters:
        principal - the authentication principal (or null if none is known for this authentication)
        evidence - the authentication evidence (or null if none is known for this authentication)
        Returns:
        the realm, or null if no particular realm matches the authentication information
      • single

        static RealmMapper single​(String realmName)
        Create a realm mapper that always maps to the given realm.
        Parameters:
        realmName - the realm name to return, or null if the default realm should be used
        Returns:
        the realm mapper returning realmName
      • matching

        static RealmMapper matching​(BiPredicate<? super Principal,​? super Evidence> matchRule,
                                    String realmName)
        Create a realm mapper that matches when the given predicate matches.
        Parameters:
        matchRule - the match rule (must not be null)
        realmName - the realm name to return, or null to return the default realm
        Returns:
        the realm mapper (not null)
      • matchingPrincipal

        static RealmMapper matchingPrincipal​(Predicate<? super Principal> matchRule,
                                             String realmName)
        Create a realm mapper that matches when the given predicate matches the principal.
        Parameters:
        matchRule - the match rule (must not be null)
        realmName - the realm name to return, or null to return the default realm
        Returns:
        the realm mapper (not null)
      • matchingPrincipalType

        static RealmMapper matchingPrincipalType​(Class<? extends Principal> principalType,
                                                 String realmName)
        Create a realm mapper that matches when the principal is of the given type.
        Parameters:
        principalType - the principal type class (must not be null)
        realmName - the realm name to return, or null to return the default realm
        Returns:
        the realm mapper (not null)
      • matchingEvidence

        static RealmMapper matchingEvidence​(Predicate<? super Evidence> matchRule,
                                            String realmName)
        Create a realm mapper that matches when the given predicate matches the evidence.
        Parameters:
        matchRule - the match rule (must not be null)
        realmName - the realm name to return, or null to return the default realm
        Returns:
        the realm mapper (not null)
      • matchingEvidenceType

        static RealmMapper matchingEvidenceType​(Class<? extends Evidence> evidenceType,
                                                String realmName)
        Create a realm mapper that matches when the evidence is of the given type.
        Parameters:
        evidenceType - the evidence type class (must not be null)
        realmName - the realm name to return, or null to return the default realm
        Returns:
        the realm mapper (not null)
      • aggregate

        static RealmMapper aggregate​(RealmMapper mapper1,
                                     RealmMapper mapper2)
        Create an aggregate realm mapping strategy.
        Parameters:
        mapper1 - the first mapper to try (must not be null)
        mapper2 - the second mapper to try (must not be null)
        Returns:
        an aggregated mapper (not null)
      • aggregate

        static RealmMapper aggregate​(RealmMapper... mappers)
        Create an aggregate realm mapping strategy.
        Parameters:
        mappers - the mappers to try (must not be null)
        Returns:
        an aggregated mapper (not null)