[java-identity-provider COMMIT] in /trunk: idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationFlowDes...
noreply at shibboleth.net
noreply at shibboleth.net
Tue May 6 13:42:49 EDT 2014
Author: scantor
Date: Tue May 6 13:42:49 2014
New Revision: 5854
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5854&view=rev
Log:
Support generalized conditional activation of authentication flows.
Modified:
trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationFlowDescriptor.java
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/DefaultAuthenticationResultSerializer.java
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SelectAuthenticationFlow.java
Modified: trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationFlowDescriptor.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationFlowDescriptor.java?rev=5854&r1=5853&r2=5854&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationFlowDescriptor.java (original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationFlowDescriptor.java Tue May 6 13:42:49 2014
@@ -38,9 +38,11 @@
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
+import org.opensaml.profile.context.ProfileRequestContext;
import org.opensaml.storage.StorageSerializer;
import com.google.common.base.Objects;
+import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
@@ -54,7 +56,7 @@
* </p>
*/
public class AuthenticationFlowDescriptor extends AbstractIdentifiableInitializableComponent implements
- PrincipalSupportingComponent, StorageSerializer<AuthenticationResult> {
+ PrincipalSupportingComponent, Predicate<ProfileRequestContext>, StorageSerializer<AuthenticationResult> {
/** Additional allowance for storage of result records to avoid race conditions during use. */
public static final long STORAGE_EXPIRATION_OFFSET;
@@ -77,12 +79,16 @@
*/
@Nonnull private Subject supportedPrincipals;
+ /** Predicate that must be true for this flow to be usable for a given request. */
+ @Nonnull private Predicate<ProfileRequestContext> activationCondition;
+
/** Custom serializer for the results generated by this flow. */
@Nullable private StorageSerializer<AuthenticationResult> resultSerializer;
/** Constructor. */
public AuthenticationFlowDescriptor() {
supportedPrincipals = new Subject();
+ activationCondition = Predicates.alwaysTrue();
inactivityTimeout = 30 * 60 * 1000;
}
@@ -228,6 +234,21 @@
}
/**
+ * Set the activation condition in the form of a {@link Predicate} such that iff the condition evaluates to true
+ * should the corresponding flow be allowed/possible.
+ *
+ * @param condition predicate that controls activation of the flow
+ */
+ public void setActivationCondition(@Nonnull final Predicate<ProfileRequestContext> condition) {
+ activationCondition = Constraint.isNotNull(condition, "Activation condition predicate cannot be null");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(ProfileRequestContext input) {
+ return activationCondition.apply(input);
+ }
+
+ /**
* Set a custom serializer for results produced by this flow.
*
* @param serializer the custom serializer
Modified: trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/DefaultAuthenticationResultSerializer.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/DefaultAuthenticationResultSerializer.java?rev=5854&r1=5853&r2=5854&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/DefaultAuthenticationResultSerializer.java (original)
+++ trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/DefaultAuthenticationResultSerializer.java Tue May 6 13:42:49 2014
@@ -174,12 +174,13 @@
gen.writeEnd().writeEnd().close();
return sink.toString();
- } catch (JsonException e) {
+ } catch (final JsonException e) {
log.error("Exception while serializing AuthenticationResult", e);
throw new IOException("Exception while serializing AuthenticationResult", e);
}
}
+// Checkstyle: CyclomaticComplexity OFF
/** {@inheritDoc} */
@Override
@Nonnull public AuthenticationResult deserialize(final int version, @Nonnull @NotEmpty final String context,
@@ -234,10 +235,11 @@
return result;
- } catch (NullPointerException | ClassCastException | ArithmeticException | JsonException e) {
+ } catch (final NullPointerException | ClassCastException | ArithmeticException | JsonException e) {
log.error("Exception while parsing AuthenticationResult", e);
[... 190 lines stripped ...]
More information about the commits
mailing list