Package net.shibboleth.idp.authn.impl
Class PrePopulateUsername
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.profile.action.AbstractProfileAction
org.opensaml.profile.action.AbstractConditionalProfileAction
net.shibboleth.idp.profile.AbstractProfileAction
net.shibboleth.idp.authn.AbstractAuthenticationAction
net.shibboleth.idp.authn.AbstractExtractionAction
net.shibboleth.idp.authn.impl.PrePopulateUsername
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,ProfileAction,Aware,MessageSource,MessageSourceAware,Action
An action to populate a username into a cleared
UsernamePasswordContext, either from a form
submission, a cookie, or an existing session to "prime" the login view.
Because this action is essentially a UI optimization, it's forgiving of errors or problems it encounters and will only warn.
- Since:
- 5.1.0
- Event:
EventIds.PROCEED_EVENT_ID- Postcondition:
UsernamePasswordContext.setUsername(String)is called with an existing value if found
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CookieManagerOptional cookie manager to use.private StringUsername cookie name.private DataSealerOptional data sealer to use.private final org.slf4j.LoggerClass logger.Order to pull username from.private UsernamePasswordContextContext to operate on.private StringForm parameter name to carry username.Strategy used to create/locate theUsernamePasswordContextto operate on. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoExecute(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext) Performs this authentication action.protected booleandoPreExecute(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext) Performs this authentication action's pre-execute step.private StringgetUsernameFromCookie(ProfileRequestContext profileRequestContext) Gets the username from an existing sealed cookie, if any.private StringgetUsernameFromForm(ProfileRequestContext profileRequestContext) Gets the username from a form submission.private StringgetUsernameFromSession(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext) Gets the username from an existingIdPSession, if any.voidsetCookieManager(CookieManager manager) Sets optionalCookieManagerto use.voidsetCookieName(String name) Set cookie name to use for cached username.voidsetDataSealer(DataSealer sealer) Sets optionalDataSealerto use.voidsetPrecedence(Collection<String> order) Sets the precedence rules to use in populating the username.voidsetUsernameFieldName(String name) Sets the name of the form field to carry the username.voidsetUsernamePasswordContextCreationStrategy(Function<ProfileRequestContext, UsernamePasswordContext> strategy) Set the strategy used to create/locate theUsernamePasswordContextto operate on.Methods inherited from class net.shibboleth.idp.authn.AbstractExtractionAction
applyTransforms, applyTransforms, setLowercase, setTransforms, setTrim, setUppercase, setUsernameRemappingStrategyMethods inherited from class net.shibboleth.idp.authn.AbstractAuthenticationAction
doExecute, doPreExecute, setAuthenticationContextLookupStrategyMethods inherited from class net.shibboleth.idp.profile.AbstractProfileAction
doExecute, execute, getBean, getBean, getMessage, getMessage, getMessage, getParameter, getParameter, getProfileContextLookupStrategy, getRequestContext, getResult, setMessageSource, setProfileContextLookupStrategyMethods inherited from class org.opensaml.profile.action.AbstractConditionalProfileAction
getActivationCondition, setActivationConditionMethods inherited from class org.opensaml.profile.action.AbstractProfileAction
doPostExecute, doPostExecute, ensureHttpServletRequest, ensureHttpServletResponse, execute, getHttpServletRequest, getHttpServletRequestSupplier, getHttpServletResponse, getHttpServletResponseSupplier, getLogPrefix, isPreExecuteCalled, setHttpServletRequestSupplier, setHttpServletResponseSupplierMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, doInitialize, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, 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.InitializableComponent
initialize, isInitialized
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
usernamePasswordContextCreationStrategy
@Nonnull private Function<ProfileRequestContext,UsernamePasswordContext> usernamePasswordContextCreationStrategyStrategy used to create/locate theUsernamePasswordContextto operate on. -
usernameFieldName
Form parameter name to carry username. -
cookieName
Username cookie name. -
cookieManager
Optional cookie manager to use. -
dataSealer
Optional data sealer to use. -
precedence
Order to pull username from. -
usernameContext
Context to operate on.
-
-
Constructor Details
-
PrePopulateUsername
public PrePopulateUsername()Constructor.
-
-
Method Details
-
setUsernamePasswordContextCreationStrategy
public void setUsernamePasswordContextCreationStrategy(@Nonnull Function<ProfileRequestContext, UsernamePasswordContext> strategy) Set the strategy used to create/locate theUsernamePasswordContextto operate on.- Parameters:
strategy- creation strategy
-
setUsernameFieldName
Sets the name of the form field to carry the username.- Parameters:
name- field name
-
setCookieName
Set cookie name to use for cached username.- Parameters:
name- cookie name
-
setPrecedence
Sets the precedence rules to use in populating the username.Valid tokens are "form", "session", and "cookie" and that is the default order.
- Parameters:
order- precedence to use
-
doPreExecute
protected boolean doPreExecute(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext) Performs this authentication action's pre-execute step. Default implementation just returns true.- Overrides:
doPreExecutein classAbstractAuthenticationAction- Parameters:
profileRequestContext- the current IdP profile request contextauthenticationContext- the current authentication context- Returns:
- true iff execution should continue
-
doExecute
protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext) Performs this authentication action. Default implementation throws an exception.- Overrides:
doExecutein classAbstractAuthenticationAction- Parameters:
profileRequestContext- the current IdP profile request contextauthenticationContext- the current authentication context
-
getUsernameFromForm
Gets the username from a form submission.Also processes do-not-cache instruction.
- Parameters:
profileRequestContext- profile request context- Returns:
- submitted username, after applying any configured transforms
-
getUsernameFromCookie
@Nullable private String getUsernameFromCookie(@Nonnull ProfileRequestContext profileRequestContext) Gets the username from an existing sealed cookie, if any.- Parameters:
profileRequestContext- profile request context- Returns:
- username from existing sealed cookie, or null
-
getUsernameFromSession
@Nullable private String getUsernameFromSession(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext) Gets the username from an existingIdPSession, if any.- Parameters:
profileRequestContext- profile request contextauthenticationContext- authentication context- Returns:
- username from existing session, or null
-