Class ValidateDuoAuthAPI
- java.lang.Object
-
- net.shibboleth.utilities.java.support.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.AbstractValidationAction
-
- net.shibboleth.idp.authn.impl.AbstractAuditingValidationAction
-
- net.shibboleth.idp.authn.duo.impl.ValidateDuoAuthAPI
-
- All Implemented Interfaces:
PrincipalSupportingComponent,Component,DestructableComponent,InitializableComponent,ProfileAction,Aware,MessageSource,MessageSourceAware,Action
public class ValidateDuoAuthAPI extends AbstractAuditingValidationAction
An action that checks for aDuoAuthenticationContextand directly produces anAuthenticationResultbased on that identity by authenticating against the Duo AuthAPI.- Event:
EventIds.PROCEED_EVENT_ID,AuthnEventIds.AUTHN_EXCEPTION,AuthnEventIds.ACCOUNT_LOCKED,AuthnEventIds.ACCOUNT_WARNING,AuthnEventIds.ACCOUNT_ERROR,AuthnEventIds.NO_CREDENTIALS,AuthnEventIds.INVALID_CREDENTIALS- Precondition:
ProfileRequestContext.getSubcontext(AuthenticationContext.class).getAttemptedFlow() != null- Postcondition:
- If AuthenticationContext.getSubcontext(DuoAuthenticationContext.class) != null, then an
AuthenticationResultis saved to theAuthenticationContexton a successful login. On a failed login, theAbstractValidationAction.handleError(ProfileRequestContext, AuthenticationContext, String, String)method is called.
-
-
Field Summary
Fields Modifier and Type Field Description private DuoAuthAuthenticatorauthAuthenticatorImplementation of Duo AuthApi /auth endpoint.private static StringDEFAULT_METRIC_NAMEDefault prefix for metrics.private DuoAuthenticationContextduoContextDuoApi context for tokens.private DuoIntegrationduoIntegrationDuo integration to use.private Function<ProfileRequestContext,DuoIntegration>duoIntegrationLookupStrategyLookp strategy for Duo integration.private org.slf4j.LoggerlogClass logger.private DuoPreauthAuthenticatorpreauthAuthenticatorImplementation of Duo AuthApi /preauth enpoint.private StringusernameAttempted username.private Function<ProfileRequestContext,String>usernameLookupStrategyLookup strategy for username to match against Duo identity.
-
Constructor Summary
Constructors Constructor Description ValidateDuoAuthAPI()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbuildAuthenticationResult(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext)Normally called upon successful completion of credential validation, calls theAbstractValidationAction.populateSubject(Subject)abstract method, stores anAuthenticationResultin theAuthenticationContext, and attaches aSubjectCanonicalizationContextto theProfileRequestContextin preparation for c14n to occur.protected voiddoExecute(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext)Performs this authentication action.protected voiddoInitialize()protected booleandoPreExecute(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext)Performs this authentication action's pre-execute step.protected Map<String,String>getAuditFields(ProfileRequestContext profileRequestContext)Subclasses can override this method to supply additional audit fields to store.protected SubjectpopulateSubject(Subject subject)voidsetAuthAuthenticator(DuoAuthAuthenticator authenticator)Set theDuoAuthAuthenticator.voidsetDuoIntegration(DuoIntegration duo)Set DuoIntegration details to use directly.voidsetDuoIntegrationLookupStrategy(Function<ProfileRequestContext,DuoIntegration> strategy)Set DuoIntegration lookup strategy to use.voidsetPreauthAuthenticator(DuoPreauthAuthenticator authenticator)Set theDuoPreauthAuthenticator.voidsetUsernameLookupStrategy(Function<ProfileRequestContext,String> strategy)Set the lookup strategy to use for the username to match against Duo identity.-
Methods inherited from class net.shibboleth.idp.authn.impl.AbstractAuditingValidationAction
doAudit, doExecute, getAuditContext, recordFailure, recordSuccess, setAuditContextCreationStrategy, setPopulateAuditContextAction, setWriteAuditLogAction
-
Methods inherited from class net.shibboleth.idp.authn.AbstractValidationAction
addDefaultPrincipals, getClassifiedErrors, getCleanupHook, getMetricName, getRequesterLookupStrategy, getResponderLookupStrategy, getResultCachingPredicate, getSubject, getSupportedPrincipals, handleError, handleError, handleWarning, recordFailure, recordSuccess, setAddDefaultPrincipals, setClassifiedMessages, setCleanupHook, setMetricName, setRequesterLookupStrategy, setResponderLookupStrategy, setResultCachingPredicate, setSupportedPrincipals
-
Methods inherited from class net.shibboleth.idp.authn.AbstractAuthenticationAction
doExecute, doPreExecute, setAuthenticationContextLookupStrategy
-
Methods inherited from class net.shibboleth.idp.profile.AbstractProfileAction
execute, getBean, getBean, getMessage, getMessage, getMessage, getParameter, getParameter, getProfileContextLookupStrategy, getRequestContext, getResult, setMessageSource, setProfileContextLookupStrategy
-
Methods inherited from class org.opensaml.profile.action.AbstractConditionalProfileAction
getActivationCondition, setActivationCondition
-
Methods inherited from class org.opensaml.profile.action.AbstractProfileAction
doPostExecute, doPostExecute, execute, getHttpServletRequest, getHttpServletRequestSupplier, getHttpServletResponse, getHttpServletResponseSupplier, getLogPrefix, setHttpServletRequest, setHttpServletRequestSupplier, setHttpServletResponse, setHttpServletResponseSupplier
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
-
-
-
-
Field Detail
-
DEFAULT_METRIC_NAME
@Nonnull @NotEmpty private static final String DEFAULT_METRIC_NAME
Default prefix for metrics.- See Also:
- Constant Field Values
-
log
@Nonnull @NotEmpty private final org.slf4j.Logger log
Class logger.
-
duoIntegrationLookupStrategy
@Nonnull private Function<ProfileRequestContext,DuoIntegration> duoIntegrationLookupStrategy
Lookp strategy for Duo integration.
-
usernameLookupStrategy
@Nonnull private Function<ProfileRequestContext,String> usernameLookupStrategy
Lookup strategy for username to match against Duo identity.
-
authAuthenticator
@Nonnull private DuoAuthAuthenticator authAuthenticator
Implementation of Duo AuthApi /auth endpoint.
-
preauthAuthenticator
@Nonnull private DuoPreauthAuthenticator preauthAuthenticator
Implementation of Duo AuthApi /preauth enpoint.
-
duoContext
@Nonnull @NotEmpty private DuoAuthenticationContext duoContext
DuoApi context for tokens.
-
duoIntegration
@Nullable private DuoIntegration duoIntegration
Duo integration to use.
-
-
Method Detail
-
setDuoIntegrationLookupStrategy
public void setDuoIntegrationLookupStrategy(@Nonnull Function<ProfileRequestContext,DuoIntegration> strategy)Set DuoIntegration lookup strategy to use.- Parameters:
strategy- lookup strategy
-
setDuoIntegration
public void setDuoIntegration(@Nonnull DuoIntegration duo)Set DuoIntegration details to use directly.- Parameters:
duo- Duo integration details
-
setUsernameLookupStrategy
public void setUsernameLookupStrategy(@Nonnull Function<ProfileRequestContext,String> strategy)Set the lookup strategy to use for the username to match against Duo identity.- Parameters:
strategy- lookup strategy
-
setAuthAuthenticator
public void setAuthAuthenticator(@Nonnull DuoAuthAuthenticator authenticator)Set theDuoAuthAuthenticator.- Parameters:
authenticator- a Duo AuthAPI /auth endpoint implementation
-
setPreauthAuthenticator
public void setPreauthAuthenticator(@Nonnull DuoPreauthAuthenticator authenticator)Set theDuoPreauthAuthenticator.- Parameters:
authenticator- a Duo AuthAPI /preauth endpoint implementation
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
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 classAbstractValidationAction- 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
-
populateSubject
protected Subject populateSubject(@Nonnull Subject subject)
Subclasses must override this method to complete the population of theSubjectwithPrincipaland credential information based on the validation they perform.Typically this will include attaching a
UsernamePrincipal, but this is not a requirement if other components are suitably overridden.- Specified by:
populateSubjectin classAbstractValidationAction- Parameters:
subject- subject to populate- Returns:
- the input subject
-
buildAuthenticationResult
protected void buildAuthenticationResult(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext)Normally called upon successful completion of credential validation, calls theAbstractValidationAction.populateSubject(Subject)abstract method, stores anAuthenticationResultin theAuthenticationContext, and attaches aSubjectCanonicalizationContextto theProfileRequestContextin preparation for c14n to occur.- Overrides:
buildAuthenticationResultin classAbstractValidationAction- Parameters:
profileRequestContext- the current profile request contextauthenticationContext- the current authentication context
-
getAuditFields
@Nullable protected Map<String,String> getAuditFields(@Nonnull ProfileRequestContext profileRequestContext)
Subclasses can override this method to supply additional audit fields to store.- Overrides:
getAuditFieldsin classAbstractAuditingValidationAction- Parameters:
profileRequestContext- profile request context- Returns:
- audit fields
-
-