Interface PrincipalDecoder

All Superinterfaces:
Function<Principal,String>
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 PrincipalDecoder extends Function<Principal,String>
A decoder for extracting a simple name from a principal.
Author:
David M. Lloyd
  • Field Details

  • Method Details

    • getName

      String getName(Principal principal)
      Get the name from a principal. If this decoder cannot understand the given principal type or contents, null is returned.
      Parameters:
      principal - the principal to decode
      Returns:
      the name, or null if this decoder does not understand the principal
    • apply

      default String apply(Principal principal)
      Specified by:
      apply in interface Function<Principal,String>
    • asPrincipalRewriter

      default UnaryOperator<Principal> asPrincipalRewriter()
      Get this principal decoder as a principal rewriter that produces a NamePrincipal if the decode succeeds.
      Returns:
      the rewriter (not null)
    • withRewriter

      default PrincipalDecoder withRewriter(NameRewriter nameRewriter)
      Add a name rewriter to this principal decoder. If the name is decoded, it will then be rewritten with the given rewriter. If the rewriter deems the name invalid, then the name will be considered not decoded.
      Parameters:
      nameRewriter - the name rewriter
      Returns:
      the combined decoder
    • aggregate

      static PrincipalDecoder aggregate(PrincipalDecoder... decoders)
      Create an aggregated principal decoder. The aggregated decoder will check each principal decoder until one matches the principal; this result will be returned.
      Parameters:
      decoders - the constituent decoders
      Returns:
      the aggregated decoder
    • concatenating

      static PrincipalDecoder concatenating(PrincipalDecoder former, String joinString, PrincipalDecoder latter)
      Create a principal decoder which concatenates the results of two principal decoders. If one decoder is not able to decode the principal, null is returned.
      Parameters:
      former - the former decoder
      joinString - the string to use to join the results
      latter - the latter decoder
      Returns:
      the concatenated result
    • concatenating

      static PrincipalDecoder concatenating(String joinString, PrincipalDecoder... decoders)
      Create a principal decoder that concatenates the results of the given principal decoders in the order in which they're given. If any decoder is not able to decode the principal, then null is returned.
      Parameters:
      joinString - the string to use to join the results
      decoders - the principal decoders (must not be null, cannot have null elements)
      Returns:
      the concatenating decoder
    • constant

      static PrincipalDecoder constant(String name)
      Create a principal decoder which always returns the same name.
      Parameters:
      name - the name to return
      Returns:
      the constant decoder