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

noreply at shibboleth.net noreply at shibboleth.net
Mon Oct 21 20:21:11 EDT 2013


Author: scantor
Date: Mon Oct 21 20:21:11 2013
New Revision: 4895

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4895&view=rev
Log:
Move result caching indicator to context so other actions can set it, implement bypass in form action.

Modified:
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationResult.java
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/AuthenticationContext.java
    trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromFormRequest.java
    trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromFormRequestTest.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/AbstractValidationAction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java?rev=4895&r1=4894&r2=4895&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java (original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.java Mon Oct 21 20:21:11 2013
@@ -306,26 +306,19 @@
         
         AuthenticationResult result = new AuthenticationResult(authenticationContext.getAttemptedFlow().getId(),
                 populateSubject(authenticatedSubject));
-        result.setCacheable(isResultCacheable(profileRequestContext, authenticationContext));
         authenticationContext.setAuthenticationResult(result);
+        
+        // Override cacheability if a predicate is installed.
+        if (authenticationContext.isResultCacheable() && resultCachingPredicate != null) {
+            authenticationContext.setResultCacheable(resultCachingPredicate.apply(profileRequestContext));
+            log.info("{} Predicate indicates authentication result {} be cacheable in a session", getLogPrefix(),
+                    authenticationContext.isResultCacheable() ? "will" : "will not");
+        }
+        
+        // Transfer the subject to a new c14n context.
         profileRequestContext.getSubcontext(SubjectCanonicalizationContext.class, true).setSubject(result.getSubject());
     }
     
-    /**
-     * Override to determine whether the {@link AuthenticationResult} built by this action should be cacheable.
-     * 
-     * <p>The default implementation applies a predicate if one is set.</p>
-     * 
-     * @param profileRequestContext the current profile request context
-     * @param authenticationContext the current authentication context
-     * 
-     * @return true iff result should be cacheable
-     */
-    protected boolean isResultCacheable(@Nonnull final ProfileRequestContext profileRequestContext,
-            @Nonnull final AuthenticationContext authenticationContext) {
-        return resultCachingPredicate != null ? resultCachingPredicate.apply(profileRequestContext) : true;
-    }
-
     /**
      * Subclasses must override this method to complete the population of the {@link Subject} with
      * {@link Principal} and credential information based on the validation they perform.

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=4895&r1=4894&r2=4895&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 20:21:11 2013
@@ -44,9 +44,6 @@
  */
 @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;
@@ -72,7 +69,6 @@
 
         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;
@@ -90,27 +86,6 @@
     }
     
     /**
-     * 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

[... 251 lines stripped ...]


More information about the commits mailing list