[java-identity-provider COMMIT] in /trunk/idp-saml-impl/src: main/java/net/shibboleth/idp/saml/impl/profile/Initializ...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Feb 20 23:40:26 EST 2014
Author: scantor
Date: Thu Feb 20 23:40:26 2014
New Revision: 5431
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5431&view=rev
Log:
Base outbound context construction on relying party's reference to inbound tree.
Modified:
trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/InitializeOutboundMessageContext.java
trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/impl/profile/InitializeOutboundMessageContextTest.java
Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/InitializeOutboundMessageContext.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/InitializeOutboundMessageContext.java?rev=5431&r1=5430&r2=5431&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/InitializeOutboundMessageContext.java (original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/impl/profile/InitializeOutboundMessageContext.java Thu Feb 20 23:40:26 2014
@@ -20,11 +20,16 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import net.shibboleth.idp.profile.AbstractProfileAction;
+import net.shibboleth.idp.profile.IdPEventIds;
+import net.shibboleth.idp.profile.context.RelyingPartyContext;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+
+import org.opensaml.messaging.context.BaseContext;
import org.opensaml.messaging.context.MessageContext;
+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.action.EventIds;
import org.opensaml.profile.context.ProfileRequestContext;
import org.opensaml.saml.common.messaging.context.SAMLMetadataContext;
import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
@@ -39,14 +44,17 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
+import com.google.common.base.Function;
+
/**
- * Action that adds an outbound {@link MessageContext} to the current {@link ProfileRequestContext}.
+ * Action that adds an outbound {@link MessageContext} and related SAML contexts to the
+ * {@link ProfileRequestContext} based on the identity of a relying party accessed via
+ * a lookup strategy, by default an immediate child of the profile request context.
*
* @event {@link org.opensaml.profile.action.EventIds#PROCEED_EVENT_ID}
- * @event {@link EventIds#INVALID_MSG_CTX}
+ * @event {@link IdPEventIds#INVALID_RELYING_PARTY_CTX}
*/
// TODO Finish Javadoc.
-// I think this is going to be an OpenSAML action, assuming we're not setting any security related info here.
public class InitializeOutboundMessageContext extends AbstractProfileAction {
/** Class logger. */
@@ -56,35 +64,54 @@
/** Test signing credential. */
@Autowired @Qualifier("idp.Credential") private Credential testSigningCredential;
- /** Inbound {@link SAMLPeerEntityContext}. */
- @Nullable private SAMLPeerEntityContext inboundPeerEntityCtx;
+ /** Relying party context lookup strategy. */
+ @Nonnull private Function<ProfileRequestContext,RelyingPartyContext> relyingPartyContextLookupStrategy;
+
+ /** The {@link SAMLPeerEntityContext} to base the outbound context on. */
+ @Nullable private SAMLPeerEntityContext peerEntityCtx;
+
+ /** Constructor. */
+ public InitializeOutboundMessageContext() {
+ relyingPartyContextLookupStrategy = new ChildContextLookup<>(RelyingPartyContext.class);
+ }
+
+ /**
+ * Set the relying party context lookup strategy.
+ *
+ * @param strategy lookup strategy
+ */
+ public void setRelyingPartyContextLookupStrategy(
+ @Nonnull final Function<ProfileRequestContext,RelyingPartyContext> strategy) {
+ relyingPartyContextLookupStrategy =
+ Constraint.isNotNull(strategy, "RelyingPartyContext lookup strategy cannot be null");
+ }
/** {@inheritDoc} */
- @Override protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext)
- throws ProfileException {
+ @Override
+ protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) throws ProfileException {
- final MessageContext inboundMessageContext = profileRequestContext.getInboundMessageContext();
- if (inboundMessageContext == null) {
- log.debug("{} No inbound message context", getLogPrefix());
- ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
+ final RelyingPartyContext relyingPartyCtx = relyingPartyContextLookupStrategy.apply(profileRequestContext);
+ if (relyingPartyCtx == null) {
+ log.debug("{} No relying party context", getLogPrefix());
[... 157 lines stripped ...]
More information about the commits
mailing list