Package net.shibboleth.idp.authn

# Class AbstractSubjectCanonicalizer

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.idp.authn.SubjectCanonicalizationFlowDescriptor
net.shibboleth.idp.authn.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 Summary

Fields
Modifier and Type
Field
Description
`private final org.slf4j.Logger`
`log`
Class logger.
`private String`
`logPrefix`
Cached log prefix.
`private boolean`
`lowercase`
Convert to lowercase prior to transforms?
`private List<Pair<Pattern,String>>`
`transforms`
Match patterns and replacement strings to apply.
`private boolean`
`trim`
Trim prior to transforms?
`private boolean`
`uppercase`
Convert to uppercase prior to transforms?

## Constructor Summary

Constructors
Constructor
Description
`AbstractSubjectCanonicalizer()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`String`
`apply(SubjectCanonicalizationContext c14nContext)`
Performs this c14n action's pre-execute step.
`protected String`
`applyTransforms(String input)`
Apply any configured regular expression replacements to an input value and return the result.
`protected abstract String`
`doApply(SubjectCanonicalizationContext c14nContext)`
Performs c14n if possible.
`protected void`
`doInitialize()`
`protected String`
`getLogPrefix()`
Return a prefix for logging messages for this component.
`void`
`setLowercase(boolean flag)`
Controls conversion to lowercase prior to applying any transforms.
`void`
`setTransforms(Collection<Pair<String,String>> newTransforms)`
A collection of regular expression and replacement pairs.
`void`
`setTrim(boolean flag)`
Controls whitespace trimming prior to applying any transforms.
`void`
`setUppercase(boolean flag)`
Controls conversion to uppercase prior to applying any transforms.

### Methods inherited from class net.shibboleth.idp.authn.SubjectCanonicalizationFlowDescriptor

`equals, getFlowId, hashCode, setActivationCondition, setFlowId, test, toString`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent

`setId`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent

`ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface net.shibboleth.shared.component.DestructableComponent

`destroy, isDestroyed`

### Methods inherited from interface java.util.function.Function

`andThen, compose`

### Methods inherited from interface net.shibboleth.shared.component.IdentifiableComponent

`setId`

### Methods inherited from interface net.shibboleth.shared.component.IdentifiedComponent

`getId`

### Methods inherited from interface net.shibboleth.shared.component.InitializableComponent

`initialize, isInitialized`

### Methods inherited from interface java.util.function.Predicate

`and, negate, or`

## 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