[java-opensaml COMMIT] in /trunk/opensaml-saml-impl/src: main/java/org/opensaml/saml/saml2/binding/security/impl/Extr...
noreply at shibboleth.net
noreply at shibboleth.net
Tue Jul 15 17:19:53 EDT 2014
Author: scantor
Date: Tue Jul 15 17:19:53 2014
New Revision: 3953
URL: http://svn.shibboleth.net/view/java-opensaml?rev=3953&view=rev
Log:
IDP-414: Add actor filtering to extraction.
Modified:
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/security/impl/ExtractChannelBindingsHeadersHandler.java
trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/security/impl/ExtractChannelBindingsHeadersHandlerTest.java
Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/security/impl/ExtractChannelBindingsHeadersHandler.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/security/impl/ExtractChannelBindingsHeadersHandler.java?rev=3953&r1=3952&r2=3953&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/security/impl/ExtractChannelBindingsHeadersHandler.java (original)
+++ trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/security/impl/ExtractChannelBindingsHeadersHandler.java Tue Jul 15 17:19:53 2014
@@ -22,6 +22,8 @@
import javax.annotation.Nonnull;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.messaging.handler.AbstractMessageHandler;
@@ -29,6 +31,7 @@
import org.opensaml.saml.common.messaging.context.ChannelBindingsContext;
import org.opensaml.saml.ext.saml2cb.ChannelBindings;
import org.opensaml.soap.messaging.context.SOAP11Context;
+import org.opensaml.soap.soap11.ActorBearing;
import org.opensaml.soap.util.SOAPSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,17 +47,52 @@
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(ExtractChannelBindingsHeadersHandler.class);
+ /** Include header blocks targeted at the final destination node? */
+ private boolean finalDestination;
+
+ /** Include header blocks targeted at the next destination node? */
+ private boolean nextDestination;
+
+ /** Constructor. */
+ public ExtractChannelBindingsHeadersHandler() {
+ nextDestination = true;
+ }
+
+ /**
+ * Set whether to include header blocks targeted at the final destination node (defaults to false).
+ *
+ * @param flag flag to set
+ */
+ public void setFinalDestination(final boolean flag) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ finalDestination = flag;
+ }
+
+ /**
+ * Set whether to include header blocks targeted at the next destination node (defaults to true).
+ *
+ * @param flag flag to set
+ */
+ public void setNextDestination(final boolean flag) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ nextDestination = flag;
+ }
+
/** {@inheritDoc} */
@Override
protected void doInvoke(@Nonnull final MessageContext messageContext) throws MessageHandlerException {
final Collection<ChannelBindings> channelBindings = Lists.newArrayList();
- final List<XMLObject> headers =
- SOAPSupport.getInboundHeaderBlock(messageContext, ChannelBindings.DEFAULT_ELEMENT_NAME, null, true);
+ final List<XMLObject> headers = SOAPSupport.getInboundHeaderBlock(messageContext,
+ ChannelBindings.DEFAULT_ELEMENT_NAME, null, finalDestination);
for (final XMLObject header : headers) {
if (header instanceof ChannelBindings) {
- channelBindings.add((ChannelBindings) header);
+ if (null == ((ActorBearing) header).getSOAP11Actor() || nextDestination) {
+ channelBindings.add((ChannelBindings) header);
+ }
}
}
Modified: trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/security/impl/ExtractChannelBindingsHeadersHandlerTest.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/security/impl/ExtractChannelBindingsHeadersHandlerTest.java?rev=3953&r1=3952&r2=3953&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/security/impl/ExtractChannelBindingsHeadersHandlerTest.java (original)
+++ trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/security/impl/ExtractChannelBindingsHeadersHandlerTest.java Tue Jul 15 17:19:53 2014
@@ -103,4 +103,38 @@
Assert.assertTrue("foo".equals(array[1].getValue()) || "bar".equals(array[1].getValue()));
}
+ /** Test that the handler works with non-default actor flags. */
+ @Test public void testActor() throws MessageHandlerException, ComponentInitializationException {
[... 34 lines stripped ...]
More information about the commits
mailing list