[java-identity-provider COMMIT] /trunk/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/UpdateSessionWi...
noreply at shibboleth.net
noreply at shibboleth.net
Mon Oct 21 15:29:07 EDT 2013
Author: scantor
Date: Mon Oct 21 15:29:06 2013
New Revision: 4891
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4891&view=rev
Log:
Inject a predicate to selectively control authn result caching.
Modified:
trunk/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/UpdateSessionWithAuthenticationResult.java
Modified: trunk/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/UpdateSessionWithAuthenticationResult.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/UpdateSessionWithAuthenticationResult.java?rev=4891&r1=4890&r2=4891&view=diff
==============================================================================
--- trunk/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/UpdateSessionWithAuthenticationResult.java (original)
+++ trunk/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/UpdateSessionWithAuthenticationResult.java Mon Oct 21 15:29:06 2013
@@ -39,6 +39,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Predicate;
+
/**
* An authentication action that establishes a record of the {@link AuthenticationResult} in an
* {@link IdPSession} for the client, either by updating an existing session or creating a new
@@ -77,6 +79,9 @@
/** Existing SubjectContext. */
@Nullable private SubjectContext subjectCtx;
+ /** Predicate determining whether to save off an {@link AuthenticationResult} to a session. */
+ @Nullable private Predicate<ProfileRequestContext> saveResultPredicate;
+
/** Flag to turn action on or off. */
private boolean enabled;
@@ -102,7 +107,24 @@
* @param flag flag to set
*/
public void setEnabled(final boolean flag) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
enabled = flag;
+ }
+
+ /**
+ * Set a {@link Predicate} governing whether to preserve an {@link AuthenticationResult} in
+ * an {@link IdPSession}.
+ *
+ * <p>If the rules for determining this differ by type of result, a compound predicate may be
+ * needed that can deal with the full range of possible result types and situations.</p>
+ *
+ * @param predicate the predicate to install, or null
+ */
+ public void setSaveResultPredicate(@Nullable final Predicate<ProfileRequestContext> predicate) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ saveResultPredicate = predicate;
}
/** {@inheritDoc} */
@@ -123,7 +145,15 @@
sessionCtx = profileRequestContext.getSubcontext(SessionContext.class, true);
// We can only do work if a session exists or a non-empty SubjectContext exists.
- return sessionCtx.getIdPSession() != null || (subjectCtx != null && subjectCtx.getPrincipalName() != null);
+ if (sessionCtx.getIdPSession() != null || (subjectCtx != null && subjectCtx.getPrincipalName() != null)) {
+
+ // Check the predicate, if any.
+ if (saveResultPredicate != null) {
+ return saveResultPredicate.apply(profileRequestContext);
+ } else {
+ return true;
+ }
+ }
}
return false;
More information about the commits
mailing list