Package net.shibboleth.idp.authn
Class AbstractUsernamePasswordCredentialValidator
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.idp.authn.AbstractCredentialValidator
net.shibboleth.idp.authn.AbstractUsernamePasswordCredentialValidator
- All Implemented Interfaces:
CredentialValidator,PrincipalSupportingComponent,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent
- Direct Known Subclasses:
HTPasswdCredentialValidator,JAASCredentialValidator,KerberosCredentialValidator,LDAPCredentialValidator
@ThreadSafeAfterInit
public abstract class AbstractUsernamePasswordCredentialValidator
extends AbstractCredentialValidator
An abstract
CredentialValidator that checks for a UsernamePasswordContext and delegates
to subclasses to produce a result.- Since:
- 4.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.shibboleth.idp.authn.CredentialValidator
CredentialValidator.ErrorHandler, CredentialValidator.WarningHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringDefault prefix for metrics.private final org.slf4j.LoggerClass logger.private booleanConvert username to lowercase prior to transforms?private PatternA regular expression to apply for acceptance testing.private booleanWhether to save the password in the Java Subject's private credentials.Match patterns and replacement strings to apply prior to use.private booleanTrim username prior to transforms?private booleanConvert username to uppercase prior to transforms?Lookup strategy for UP context. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringapplyTransforms(String input) Apply any configured regular expression replacements to an input value and return the result.protected abstract SubjectdoValidate(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext, UsernamePasswordContext usernamePasswordContext, CredentialValidator.WarningHandler warningHandler, CredentialValidator.ErrorHandler errorHandler) Override method for subclasses to use to perform the actual validation.protected SubjectdoValidate(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext, CredentialValidator.WarningHandler warningHandler, CredentialValidator.ErrorHandler errorHandler) Override method for subclasses to use to perform the actual validation.protected SubjectpopulateSubject(Subject subject, UsernamePasswordContext usernamePasswordContext) Decorate the subject with "standard" content from the validation and clean up as instructed.booleanGet whether to save the password in the private credential set.voidsetLowercase(boolean flag) Controls conversion to lowercase prior to applying any transforms.voidsetMatchExpression(Pattern expression) Set a matching expression to apply to the username for acceptance.voidsetSavePasswordToCredentialSet(boolean flag) Set whether to save the password in the private credential set.voidsetTransforms(Collection<Pair<String, String>> newTransforms) A collection of regular expression and replacement pairs.voidsetTrim(boolean flag) Controls whitespace trimming prior to applying any transforms.voidsetUppercase(boolean flag) Controls conversion to uppercase prior to applying any transforms.voidsetUsernamePasswordContextLookupStrategy(Function<AuthenticationContext, UsernamePasswordContext> strategy) Set the lookup strategy to locate theUsernamePasswordContext.Methods inherited from class net.shibboleth.idp.authn.AbstractCredentialValidator
getLogPrefix, getSupportedPrincipals, isAcceptable, populateSubject, setActivationCondition, setId, setSupportedPrincipals, validateMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
doInitialize, ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentExceptionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.IdentifiedComponent
getId
-
Field Details
-
DEFAULT_METRIC_NAME
Default prefix for metrics.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
usernamePasswordContextLookupStrategy
@Nonnull private Function<AuthenticationContext,UsernamePasswordContext> usernamePasswordContextLookupStrategyLookup strategy for UP context. -
savePasswordToCredentialSet
private boolean savePasswordToCredentialSetWhether to save the password in the Java Subject's private credentials. -
matchExpression
A regular expression to apply for acceptance testing. -
transforms
Match patterns and replacement strings to apply prior to use. -
uppercase
private boolean uppercaseConvert username to uppercase prior to transforms? -
lowercase
private boolean lowercaseConvert username to lowercase prior to transforms? -
trim
private boolean trimTrim username prior to transforms?
-
-
Constructor Details
-
AbstractUsernamePasswordCredentialValidator
public AbstractUsernamePasswordCredentialValidator()Constructor.
-
-
Method Details
-
setUsernamePasswordContextLookupStrategy
public void setUsernamePasswordContextLookupStrategy(@Nonnull Function<AuthenticationContext, UsernamePasswordContext> strategy) Set the lookup strategy to locate theUsernamePasswordContext.- Parameters:
strategy- lookup strategy
-
savePasswordToCredentialSet
public boolean savePasswordToCredentialSet()Get whether to save the password in the private credential set.- Returns:
- whether to save the password in the private credential set
-
setSavePasswordToCredentialSet
public void setSavePasswordToCredentialSet(boolean flag) Set whether to save the password in the private credential set.- Parameters:
flag- flag to set
-
setMatchExpression
Set a matching expression to apply to the username for acceptance.- Parameters:
expression- a matching expression
-
setTransforms
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
-
doValidate
protected Subject doValidate(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext, @Nullable CredentialValidator.WarningHandler warningHandler, @Nullable CredentialValidator.ErrorHandler errorHandler) throws Exception Override method for subclasses to use to perform the actual validation.- Specified by:
doValidatein classAbstractCredentialValidator- Parameters:
profileRequestContext- profile request contextauthenticationContext- authentication contextwarningHandler- optional warning handler interfaceerrorHandler- optional error handler interface- Returns:
- the validated result, or null if inapplicable
- Throws:
Exception- if an error occurs
-
doValidate
@Nullable protected abstract Subject doValidate(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext, @Nonnull UsernamePasswordContext usernamePasswordContext, @Nullable CredentialValidator.WarningHandler warningHandler, @Nullable CredentialValidator.ErrorHandler errorHandler) throws Exception Override method for subclasses to use to perform the actual validation.Any configured transforms will have been applied to populate the context with a transformed username prior to this method call.
- Parameters:
profileRequestContext- profile request contextauthenticationContext- authentication contextusernamePasswordContext- the username/password to validatewarningHandler- optional warning handler interfaceerrorHandler- optional error handler interface- Returns:
- the validated result, or null if inapplicable
- Throws:
Exception- if an error occurs
-
populateSubject
@Nonnull protected Subject populateSubject(@Nonnull Subject subject, @Nonnull UsernamePasswordContext usernamePasswordContext) Decorate the subject with "standard" content from the validation and clean up as instructed.- Parameters:
subject- the subject being returnedusernamePasswordContext- the username/password validated- Returns:
- the decorated subject
-
applyTransforms
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
-