[java-identity-provider COMMIT] in /trunk: idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult....

noreply at shibboleth.net noreply at shibboleth.net
Mon Oct 21 15:47:23 EDT 2013


Author: scantor
Date: Mon Oct 21 15:47:23 2013
New Revision: 4892

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4892&view=rev
Log:
Switch predicate to flag on result class, easier to disable from a login form.

Modified:
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult.java
    trunk/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/UpdateSessionWithAuthenticationResult.java
    trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/UpdateSessionWithAuthenticationResultTest.java

Modified: trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult.java?rev=4892&r1=4891&r2=4892&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult.java (original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult.java Mon Oct 21 15:47:23 2013
@@ -45,6 +45,9 @@
 @ThreadSafe
 public class AuthenticationResult implements PrincipalSupportingComponent {
 
+    /** Result may be cached for reuse in the normal way. */
+    private boolean cacheable;
+    
     /** The Subject established by the authentication result. */
     @Nonnull private final Subject subject;
 
@@ -69,6 +72,7 @@
 
         authenticationFlowId = Constraint.isNotNull(StringSupport.trimOrNull(flowId),
                 "Authentication flow ID cannot be null nor empty");
+        cacheable = true;
         subject = Constraint.isNotNull(newSubject, "Subject list cannot be null or empty");
         authenticationInstant = System.currentTimeMillis();
         lastActivityInstant = authenticationInstant;
@@ -86,6 +90,27 @@
     }
     
     /**
+     * Get whether this result is suitable for caching (such as in a session) for reuse.
+     * 
+     * <p>This can be controlled per-instance to override the normal policy set based on
+     * inactivity, etc.</p>
+     * 
+     * @return  true iff the result may be cached/reused, subject to other policy
+     */
+    public boolean isCacheable() {
+        return cacheable;
+    }
+    
+    /**
+     * Set whether this result is suitable for caching (such as in a session) for reuse.
+     * 
+     * @param flag  flag to set
+     */
+    public void setCacheable(final boolean flag) {
+        cacheable = flag;
+    }
+    
+    /**
      * Get the Subject identifying the authenticated entity.
      * 
      * @return a Subject identifying the authenticated entity
@@ -178,6 +203,7 @@
     /** {@inheritDoc} */
     public String toString() {
         return Objects.toStringHelper(this).add("authenticationFlowId", authenticationFlowId)
+                .add("cacheable", cacheable)
                 .add("authenticatedPrincipal", getSubjectName())
                 .add("authenticationInstant", new DateTime(authenticationInstant))
                 .add("lastActivityInstant", new DateTime(lastActivityInstant)).toString();

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=4892&r1=4891&r2=4892&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:47:23 2013
@@ -39,8 +39,6 @@
 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
@@ -79,9 +77,6 @@
     /** 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;
     
@@ -112,21 +107,6 @@
         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) {

[... 69 lines stripped ...]


More information about the commits mailing list