[java-identity-provider COMMIT] in /trunk: idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateMultiFa...
noreply at shibboleth.net
noreply at shibboleth.net
Sat Aug 6 18:32:41 EDT 2016
Author: scantor
Date: Sat Aug 6 18:32:41 2016
New Revision: 8315
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8315&view=rev
Log:
IDP-962 - Login flow or framework for combining authentication factors (e.g. Duo)
https://issues.shibboleth.net/jira/browse/IDP-962
Add ability to produce transition rule map dynamically.
Modified:
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateMultiFactorAuthenticationContext.java
trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/BaseMultiFactorAuthenticationContextTest.java
trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/PopulateMultiFactorAuthenticationContextTest.java
trunk/idp-conf/src/main/resources/system/flows/authn/mfa-authn-beans.xml
Modified: trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateMultiFactorAuthenticationContext.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateMultiFactorAuthenticationContext.java?rev=8315&r1=8314&r2=8315&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateMultiFactorAuthenticationContext.java (original)
+++ trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateMultiFactorAuthenticationContext.java Sat Aug 6 18:32:41 2016
@@ -19,8 +19,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -30,12 +28,14 @@
import net.shibboleth.idp.authn.AbstractAuthenticationAction;
import net.shibboleth.idp.authn.AuthenticationFlowDescriptor;
import net.shibboleth.idp.authn.AuthenticationResult;
+import net.shibboleth.idp.authn.AuthnEventIds;
import net.shibboleth.idp.authn.MultiFactorAuthenticationTransition;
import net.shibboleth.idp.authn.context.AuthenticationContext;
import net.shibboleth.idp.authn.context.MultiFactorAuthenticationContext;
import net.shibboleth.idp.authn.principal.AuthenticationResultPrincipal;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.logic.FunctionSupport;
import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.profile.action.ActionSupport;
@@ -53,8 +53,12 @@
* and with any active "factors" found, if an active result from the MFA flow is present in the
* {@link AuthenticationContext}.
*
+ * <p>If the lookup strategy supplies no transition rules to use, then the {@link AuthnEventIds#RESELECT_FLOW}
+ * event is signaled.</p>
+ *
* @event {@link EventIds#PROCEED_EVENT_ID}
* @event {@link EventIds#INVALID_PROFILE_CTX}
+ * @event {@link AuthnEventIds#RESELECT_FLOW}
* @pre <pre>ProfileRequestContext.getSubcontext(AuthenticationContext.class) != null</pre>
* @post <pre>ProfileRequestContext.getSubcontext(AuthenticationContext.class).getSubcontext(
* MultiFactorAuthenticationContext.class) != null</pre>
@@ -64,8 +68,9 @@
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(PopulateMultiFactorAuthenticationContext.class);
- /** Map of login "factors" (flows) and the transition rules to run after them. */
- @Nonnull private Map<String,MultiFactorAuthenticationTransition> transitionMap;
+ /** Lookup strategy for obtaining the map of transition rules to use. */
+ @Nonnull
+ private Function<ProfileRequestContext,Map<String,MultiFactorAuthenticationTransition>> transitionMapLookupStrategy;
/** Lookup/creation function for the context to populate. */
@Nonnull
@@ -76,7 +81,7 @@
/** Constructor. */
PopulateMultiFactorAuthenticationContext() {
- transitionMap = Collections.emptyMap();
+ transitionMapLookupStrategy = FunctionSupport.constant(null);
multiFactorContextCreationStrategy = Functions.compose(
new ChildContextLookup(MultiFactorAuthenticationContext.class, true),
new ChildContextLookup(AuthenticationContext.class));
@@ -84,15 +89,15 @@
}
/**
- * Set the map of transitions to apply.
- *
- * @param map map of transition logic
- */
- public void setTransitionMap(@Nonnull final Map<String,MultiFactorAuthenticationTransition> map) {
+ * Set the strategy to lookup the map of transition rules to apply.
+ *
+ * @param strategy lookup strategy
+ */
+ public void setTransitionMapLookupStrategy(
+ @Nonnull final Function<ProfileRequestContext,Map<String,MultiFactorAuthenticationTransition>> strategy) {
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- Constraint.isNotNull(map, "Map cannot be null");
-
- transitionMap = new HashMap<>(map);
+
[... 104 lines stripped ...]
More information about the commits
mailing list