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

noreply at shibboleth.net noreply at shibboleth.net
Tue Aug 13 13:52:36 EDT 2013


Author: scantor
Date: Tue Aug 13 13:52:35 2013
New Revision: 4683

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4683&view=rev
Log:
Fix handling of context lookup functions.

Modified:
    trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractAuthenticationAction.java
    trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SimpleSubjectCanonicalization.java

Modified: trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractAuthenticationAction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractAuthenticationAction.java?rev=4683&r1=4682&r2=4683&view=diff
==============================================================================
--- trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractAuthenticationAction.java (original)
+++ trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractAuthenticationAction.java Tue Aug 13 13:52:35 2013
@@ -51,23 +51,18 @@
     public AbstractAuthenticationAction() {
         super();
 
-        authnCtxLookupStrategy =
-                new ChildContextLookup<ProfileRequestContext, AuthenticationContext>(
-                        AuthenticationContext.class, false);
+        authnCtxLookupStrategy = new ChildContextLookup(AuthenticationContext.class, false);
     }
 
     /**
-     * Constructor.
+     * Set the context lookup strategy.
      * 
-     * @param strategy lookup function to locate {@link AuthenticationContext}
+     * @param strategy  lookup strategy function for {@link AuthenticationContext}.
      */
-    public AbstractAuthenticationAction(
-            @Nonnull Function<ProfileRequestContext, AuthenticationContext> strategy) {
-        super();
-
-        authnCtxLookupStrategy = Constraint.isNotNull(strategy, "Lookup strategy function cannot be null");
+    public void setLookupStrategy(@Nonnull final Function<ProfileRequestContext, AuthenticationContext> strategy) {
+        authnCtxLookupStrategy = Constraint.isNotNull(strategy, "Strategy cannot be null");
     }
-
+    
     /** {@inheritDoc} */
     protected final boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext)
             throws ProfileException {

Modified: trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SimpleSubjectCanonicalization.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SimpleSubjectCanonicalization.java?rev=4683&r1=4682&r2=4683&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SimpleSubjectCanonicalization.java (original)
+++ trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SimpleSubjectCanonicalization.java Tue Aug 13 13:52:35 2013
@@ -26,11 +26,15 @@
 import net.shibboleth.idp.authn.SubjectCanonicalizationException;
 import net.shibboleth.idp.authn.UsernamePrincipal;
 import net.shibboleth.idp.authn.context.SubjectCanonicalizationContext;
+import net.shibboleth.utilities.java.support.logic.Constraint;
 
+import org.opensaml.messaging.context.navigate.ChildContextLookup;
 import org.opensaml.profile.ProfileException;
 import org.opensaml.profile.action.AbstractProfileAction;
 import org.opensaml.profile.action.ActionSupport;
 import org.opensaml.profile.context.ProfileRequestContext;
+
+import com.google.common.base.Function;
 
 /**
  * An action that operates on a {@link SubjectCanonicalizationContext} child of the current
@@ -46,16 +50,35 @@
  */
 public class SimpleSubjectCanonicalization extends AbstractProfileAction {
 
+    /**
+     * Strategy used to find the {@link SubjectCanonicalizationContext} from the
+     * {@link ProfileRequestContext}.
+     */
+    @Nonnull private Function<ProfileRequestContext, SubjectCanonicalizationContext> scCtxLookupStrategy;
+    
     /** SubjectCanonicalizationContext to operate on. */
     @Nullable private SubjectCanonicalizationContext scContext;
     
     /** Constructor. */
     SimpleSubjectCanonicalization() {
+        super();
+        
+        scCtxLookupStrategy = new ChildContextLookup(SubjectCanonicalizationContext.class, false);
     }
 
+    /**
+     * Set the context lookup strategy.
+     * 
+     * @param strategy  lookup strategy function for {@link SubjectCanonicalizationContext}.
+     */
+    public void setLookupStrategy(
+            @Nonnull final Function<ProfileRequestContext, SubjectCanonicalizationContext> strategy) {
+        scCtxLookupStrategy = Constraint.isNotNull(strategy, "Strategy cannot be null");
+    }
+    
     /** {@inheritDoc} */
     protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) throws ProfileException {
-        scContext = profileRequestContext.getSubcontext(SubjectCanonicalizationContext.class, false);
+        scContext = scCtxLookupStrategy.apply(profileRequestContext);
         if (scContext == null) {

[... 3 lines stripped ...]


More information about the commits mailing list