[java-identity-provider COMMIT] /trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction....
noreply at shibboleth.net
noreply at shibboleth.net
Wed Mar 19 16:55:34 EDT 2014
Author: scantor
Date: Wed Mar 19 16:55:34 2014
New Revision: 5611
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5611&view=rev
Log:
IDP-383 - set requester/responder after logins when prepping c14n context
Modified:
trunk/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractValidationAction.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=5611&r1=5610&r2=5611&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 Wed Mar 19 16:55:34 2014
@@ -35,6 +35,8 @@
import net.shibboleth.idp.authn.principal.PrincipalEvalPredicate;
import net.shibboleth.idp.authn.principal.PrincipalEvalPredicateFactory;
import net.shibboleth.idp.authn.principal.PrincipalSupportingComponent;
+import net.shibboleth.idp.profile.context.navigate.RelyingPartyIdLookupFunction;
+import net.shibboleth.idp.profile.context.navigate.ResponderIdLookupFunction;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.annotation.constraint.NotLive;
@@ -47,6 +49,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.base.Strings;
@@ -86,12 +89,20 @@
/** Predicate to apply when setting AuthenticationResult cacheability. */
@Nullable private Predicate<ProfileRequestContext> resultCachingPredicate;
+
+ /** Function used to obtain the requester ID. */
+ @Nullable private Function<ProfileRequestContext,String> requesterLookupStrategy;
+
+ /** Function used to obtain the responder ID. */
+ @Nullable private Function<ProfileRequestContext,String> responderLookupStrategy;
/** Constructor. */
public AbstractValidationAction() {
authenticatedSubject = new Subject();
clearErrorContext = true;
classifiedMessages = Collections.emptyMap();
+ requesterLookupStrategy = new RelyingPartyIdLookupFunction();
+ responderLookupStrategy = new ResponderIdLookupFunction();
}
/**
@@ -141,6 +152,30 @@
resultCachingPredicate = predicate;
}
+
+ /**
+ * Set the strategy used to locate the requester ID for canonicalization.
+ *
+ * @param strategy lookup strategy
+ */
+ public synchronized void setRequesterLookupStrategy(
+ @Nullable final Function<ProfileRequestContext,String> strategy) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ requesterLookupStrategy = strategy;
+ }
+
+ /**
+ * Set the strategy used to locate the responder ID for canonicalization.
+ *
+ * @param strategy lookup strategy
+ */
+ public synchronized void setResponderLookupStrategy(
+ @Nullable final Function<ProfileRequestContext,String> strategy) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ responderLookupStrategy = strategy;
+ }
/** {@inheritDoc} */
@Override
@@ -164,7 +199,7 @@
authenticatedSubject.getPrincipals().clear();
authenticatedSubject.getPrincipals().addAll(Collections2.filter(principals, Predicates.notNull()));
}
-
+
/**
* Get the subject to be produced by successful execution of this action.
*
@@ -240,7 +275,7 @@
authenticationContext.getAttemptedFlow().getSupportedPrincipals());
}
- AuthenticationResult result = new AuthenticationResult(authenticationContext.getAttemptedFlow().getId(),
+ final AuthenticationResult result = new AuthenticationResult(authenticationContext.getAttemptedFlow().getId(),
populateSubject(authenticatedSubject));
authenticationContext.setAuthenticationResult(result);
@@ -252,7 +287,15 @@
}
// Transfer the subject to a new c14n context.
- profileRequestContext.getSubcontext(SubjectCanonicalizationContext.class, true).setSubject(result.getSubject());
+ final SubjectCanonicalizationContext c14n = new SubjectCanonicalizationContext();
+ c14n.setSubject(result.getSubject());
+ if (requesterLookupStrategy != null) {
+ c14n.setRequesterId(requesterLookupStrategy.apply(profileRequestContext));
+ }
+ if (responderLookupStrategy != null) {
+ c14n.setResponderId(responderLookupStrategy.apply(profileRequestContext));
+ }
+ profileRequestContext.addSubcontext(c14n, true);
}
[... 2 lines stripped ...]
More information about the commits
mailing list