Package net.shibboleth.idp.authn.impl
Class JAASCredentialValidator
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.idp.authn.AbstractCredentialValidator
net.shibboleth.idp.authn.AbstractUsernamePasswordCredentialValidator
net.shibboleth.idp.authn.impl.JAASCredentialValidator
- All Implemented Interfaces:
CredentialValidator,PrincipalSupportingComponent,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent
@ThreadSafeAfterInit
public class JAASCredentialValidator
extends AbstractUsernamePasswordCredentialValidator
A password validator that authenticates against JAAS.
Support for complex chaining of JAAS modules remains supported but should be avoided in favor of the new support for chaining validators in most cases.
- Since:
- 4.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA callback handler that provides name and password data to a JAAS login process, along with other miscellany.Nested classes/interfaces inherited from interface net.shibboleth.idp.authn.CredentialValidator
CredentialValidator.ErrorHandler, CredentialValidator.WarningHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.slf4j.LoggerClass logger.private Collection<String>Holder for simple configurations defined by name.private Configuration.ParametersType-specific configuration parameters.private ResourceJAAS configuration resource.private Function<ProfileRequestContext,Collection<Pair<String, Subject>>> Strategy function to dynamically derive the login config(s) to use.private StringType of JAAS Configuration to instantiate.private Collection<Pair<String,Subject>> Application name(s) in JAAS configuration to use. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Subjectauthenticate(String loginConfigName, UsernamePasswordContext usernamePasswordContext) Create a JAAS configuration and attempt a login with it.protected voidprotected SubjectdoValidate(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext, UsernamePasswordContext usernamePasswordContext, CredentialValidator.WarningHandler warningHandler, CredentialValidator.ErrorHandler errorHandler) Override method for subclasses to use to perform the actual validation.Get the type-specific parameters of the JAASConfigurationto use.Get the type of JAASConfigurationto use.protected SubjectpopulateSubject(Subject subject, Subject derivedSubject, UsernamePasswordContext usernamePasswordContext) Finish decorating the result.voidsetLoginConfigNames(Collection<String> names) Set the JAAS application name(s) to use.voidSet a URI to use as a JAAS configuration parameter.voidsetLoginConfigResource(Resource resource) Set a login configuration resource to use.voidSet the strategy function to use to obtain the JAAS application configuration(s) to use.voidsetLoginConfigType(String type) Set the type of JAASConfigurationto use.voidsetLoginConfigurations(Collection<Pair<String, Collection<Principal>>> configs) Set the JAAS application name(s) to use, along with an optional collection of custom principals to apply to the result.Methods inherited from class net.shibboleth.idp.authn.AbstractUsernamePasswordCredentialValidator
applyTransforms, doValidate, populateSubject, savePasswordToCredentialSet, setLowercase, setMatchExpression, setSavePasswordToCredentialSet, setTransforms, setTrim, setUppercase, setUsernamePasswordContextLookupStrategyMethods inherited from class net.shibboleth.idp.authn.AbstractCredentialValidator
getLogPrefix, getSupportedPrincipals, isAcceptable, populateSubject, setActivationCondition, setId, setSupportedPrincipals, validateMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
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
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
loginConfigType
Type of JAAS Configuration to instantiate. -
loginConfigResource
JAAS configuration resource. -
loginConfigParameters
Type-specific configuration parameters. -
loginConfigNames
Holder for simple configurations defined by name. -
loginConfigurations
Application name(s) in JAAS configuration to use. -
loginConfigStrategy
@Nullable private Function<ProfileRequestContext,Collection<Pair<String, loginConfigStrategySubject>>> Strategy function to dynamically derive the login config(s) to use.
-
-
Constructor Details
-
JAASCredentialValidator
public JAASCredentialValidator()Constructor.
-
-
Method Details
-
getLoginConfigType
Get the type of JAASConfigurationto use.- Returns:
- the type of JAAS configuration to use
-
setLoginConfigType
Set the type of JAASConfigurationto use.- Parameters:
type- the type of JAAS configuration to use
-
getLoginConfigParameters
Get the type-specific parameters of the JAASConfigurationto use.- Returns:
- the JAAS configuration parameters to use
-
setLoginConfigParameters
Set a URI to use as a JAAS configuration parameter.- Parameters:
uri- the JAAS configuration URI parameters to use
-
setLoginConfigurations
public void setLoginConfigurations(@Nullable Collection<Pair<String, Collection<Principal>>> configs) Set the JAAS application name(s) to use, along with an optional collection of custom principals to apply to the result.- Parameters:
configs- list of JAAS application names and custom principals to use
-
setLoginConfigNames
Set the JAAS application name(s) to use.- Parameters:
names- list of JAAS application names to use
-
setLoginConfigStrategy
public void setLoginConfigStrategy(@Nullable Function<ProfileRequestContext, Collection<Pair<String, Subject>>> strategy) Set the strategy function to use to obtain the JAAS application configuration(s) to use.- Parameters:
strategy- strategy function
-
doInitialize
- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-
doValidate
@Nullable protected 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.
- Specified by:
doValidatein classAbstractUsernamePasswordCredentialValidator- 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
-
authenticate
@Nonnull private Subject authenticate(@Nonnull @NotEmpty String loginConfigName, @Nonnull UsernamePasswordContext usernamePasswordContext) throws LoginException, NoSuchAlgorithmException Create a JAAS configuration and attempt a login with it.- Parameters:
loginConfigName- the application name to useusernamePasswordContext- input context- Returns:
- the JAAS result
- Throws:
LoginException- if the JAAS login process failsNoSuchAlgorithmException- if a JAAS configuration cannot be created
-
populateSubject
@Nonnull protected Subject populateSubject(@Nonnull Subject subject, @Nullable Subject derivedSubject, @Nonnull UsernamePasswordContext usernamePasswordContext) Finish decorating the result.- Parameters:
subject- the JAAS resultderivedSubject- container for additional principalsusernamePasswordContext- input context- Returns:
- final result
-