[java-identity-provider COMMIT] in /trunk: idp-authn-api/src/main/java/net/shibboleth/idp/authn/MultiFactorAuthentica...
noreply at shibboleth.net
noreply at shibboleth.net
Mon May 16 17:58:31 EDT 2016
Author: scantor
Date: Mon May 16 17:58:31 2016
New Revision: 8242
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8242&view=rev
Log:
Flesh out signaling in MFA transitions.
Modified:
trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/MultiFactorAuthenticationTransition.java
trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/MultiFactorAuthenticationTransitionTest.java
Modified: trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/MultiFactorAuthenticationTransition.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/MultiFactorAuthenticationTransition.java?rev=8242&r1=8241&r2=8242&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/MultiFactorAuthenticationTransition.java (original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/MultiFactorAuthenticationTransition.java Mon May 16 17:58:31 2016
@@ -18,6 +18,9 @@
package net.shibboleth.idp.authn;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -26,12 +29,15 @@
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.annotation.constraint.Live;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.logic.FunctionSupport;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.opensaml.profile.context.ProfileRequestContext;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
@@ -41,7 +47,11 @@
*
* <p>After each factor is successfully completed, this object supplies rules for determining whether additional
* factors are required, how to combine {@link Subject}s produced by different factors when a flow completes,
- * and what flow should execute next.</p>
+ * and what should happen next.</p>
+ *
+ * <p>The latter is handled with a bit of pseudo-SWF reinvention that allows an event to be mapped to a new
+ * flow to run by means of a function. If no mapping exists, or the function returns null, then the event
+ * is simply raised as the result of the overall flow execution.</p>
*
* @since 3.3.0
*/
@@ -54,13 +64,13 @@
@Nonnull private Function<ProfileRequestContext,AuthenticationResult> resultMergingStrategy;
/** A function that determines the next flow to execute. */
- @Nonnull private Function<ProfileRequestContext,String> nextFlowStrategy;
+ @Nonnull @NonnullElements private Map<String,Function<ProfileRequestContext,String>> nextFlowStrategyMap;
/** Constructor. */
public MultiFactorAuthenticationTransition() {
completionCondition = new DefaultCompletionCondition();
resultMergingStrategy = new DefaultResultMergingStrategy();
- setNextFlow(null);
+ nextFlowStrategyMap = new HashMap<>();
}
/**
@@ -110,34 +120,69 @@
/**
* Get the function to run to determine the next subflow to run.
*
- * <p>The flow ID must be fully-qualified; that is, for the typical case that a login subflow needs to be
- * run, the "authn/" prefix must be included.</p>
+ * @param event the event to transition from
*
* @return flow determination strategy
*/
- @Nonnull public Function<ProfileRequestContext,String> getNextFlowStrategy() {
- return nextFlowStrategy;
- }
-
- /**
- * Set the function to run to determine the next subflow to run.
- *
- * @param strategy flow determination strategy
- */
- public void setNextFlowStrategy(@Nonnull final Function<ProfileRequestContext,String> strategy) {
- nextFlowStrategy = Constraint.isNotNull(strategy, "Flow determination strategy cannot be null");
- }
-
- /**
- * Set the next flow to run instead of using a strategy function.
- *
- * <p>The flow ID must be fully-qualified; that is, for the typical case that a login subflow needs to be
- * run, the "authn/" prefix must be included.</p>
+ @Nonnull public Function<ProfileRequestContext,String> getNextFlowStrategy(@Nonnull @NotEmpty final String event) {
+ if (nextFlowStrategyMap.containsKey(event)) {
+ return nextFlowStrategyMap.get(event);
+ } else {
+ return FunctionSupport.constant(null);
+ }
+ }
+
+ /**
+ * Get the map of transition rules to follow.
+ *
+ * @return a map of transition functions keyed by event ID
+ */
[... 66 lines stripped ...]
More information about the commits
mailing list