Class AbstractSubjectCanonicalizer

All Implemented Interfaces:
Function<SubjectCanonicalizationContext,String>, Predicate<ProfileRequestContext>, SubjectCanonicalizer, FlowDescriptor, Component, DestructableComponent, IdentifiableComponent, IdentifiedComponent, InitializableComponent
Direct Known Subclasses:
AttributeSourcedSubjectCanonicalization, FunctionSubjectCanonicalization, SimpleSubjectCanonicalization, X500SubjectCanonicalization

public abstract class AbstractSubjectCanonicalizer extends SubjectCanonicalizationFlowDescriptor implements SubjectCanonicalizer
A base class for "stand-alone" subject c14n implementations.
  • Field Details

    • log

      @Nonnull private final org.slf4j.Logger log
      Class logger.
    • logPrefix

      @NonnullAfterInit private String logPrefix
      Cached log prefix.
    • transforms

      @Nonnull private List<Pair<Pattern,String>> transforms
      Match patterns and replacement strings to apply.
    • uppercase

      private boolean uppercase
      Convert to uppercase prior to transforms?
    • lowercase

      private boolean lowercase
      Convert to lowercase prior to transforms?
    • trim

      private boolean trim
      Trim prior to transforms?
  • Constructor Details

    • AbstractSubjectCanonicalizer

      public AbstractSubjectCanonicalizer()
      Constructor.
  • Method Details

    • setTransforms

      public void setTransforms(@Nullable Collection<Pair<String,String>> newTransforms)
      A collection of regular expression and replacement pairs.
      Parameters:
      newTransforms - collection of replacement transforms
    • setUppercase

      public void setUppercase(boolean flag)
      Controls conversion to uppercase prior to applying any transforms.
      Parameters:
      flag - uppercase flag
    • setLowercase

      public void setLowercase(boolean flag)
      Controls conversion to lowercase prior to applying any transforms.
      Parameters:
      flag - lowercase flag
    • setTrim

      public void setTrim(boolean flag)
      Controls whitespace trimming prior to applying any transforms.
      Parameters:
      flag - trim flag
    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class SubjectCanonicalizationFlowDescriptor
      Throws:
      ComponentInitializationException
    • apply

      @Nullable public String apply(@Nullable SubjectCanonicalizationContext c14nContext)
      Performs this c14n action's pre-execute step. Default implementation just returns true iff a subject is set.
      Specified by:
      apply in interface Function<SubjectCanonicalizationContext,String>
      Parameters:
      c14nContext - the current subject canonicalization context
      Returns:
      event indicating result of function
    • doApply

      @Nullable protected abstract String doApply(@Nonnull SubjectCanonicalizationContext c14nContext)
      Performs c14n if possible.
      Parameters:
      c14nContext - the current subject canonicalization context
      Returns:
      event indicating result of function
    • applyTransforms

      @Nonnull @NotEmpty protected String applyTransforms(@Nonnull @NotEmpty String input)
      Apply any configured regular expression replacements to an input value and return the result.
      Parameters:
      input - the input string
      Returns:
      the result of applying the expressions
    • getLogPrefix

      @NonnullAfterInit protected String getLogPrefix()
      Return a prefix for logging messages for this component.
      Returns:
      a string for insertion at the beginning of any log messages