[java-opensaml2 COMMIT] in /branches/REL_2: doc/RELEASE-NOTES.txt src/main/java/org/opensaml/saml1/binding/encoding/H...

noreply at shibboleth.net noreply at shibboleth.net
Fri Jan 11 20:13:35 EST 2013


Author: putmanb
Date: Fri Jan 11 20:13:35 2013
New Revision: 1608

URL: http://svn.shibboleth.net/view/java-opensaml2?rev=1608&view=rev
Log:
JOST-199: SAML SOAP encoders should use the supplied outbound SOAP Envelope from the message context, if it exists 

Modified:
    branches/REL_2/doc/RELEASE-NOTES.txt
    branches/REL_2/src/main/java/org/opensaml/saml1/binding/encoding/HTTPSOAP11Encoder.java
    branches/REL_2/src/main/java/org/opensaml/saml2/binding/encoding/HTTPSOAP11Encoder.java
    branches/REL_2/src/test/java/org/opensaml/saml1/binding/encoding/HTTPSOAP11EncoderTest.java
    branches/REL_2/src/test/java/org/opensaml/saml2/binding/encoding/HTTPSOAP11EncoderTest.java

Modified: branches/REL_2/doc/RELEASE-NOTES.txt
URL: http://svn.shibboleth.net/view/java-opensaml2/branches/REL_2/doc/RELEASE-NOTES.txt?rev=1608&r1=1607&r2=1608&view=diff
==============================================================================
--- branches/REL_2/doc/RELEASE-NOTES.txt (original)
+++ branches/REL_2/doc/RELEASE-NOTES.txt Fri Jan 11 20:13:35 2013
@@ -13,6 +13,7 @@
 [JOST-196] - On MetadataProviderCredentialResolver, expose the MetadataProvider used to construct the resolver
 [JOST-197] - XML providers for Async Logout extensions
 [JOST-198] - Configuration files for XMLObject providers often missing Type registrations
+[JOST-199] - SAML SOAP encoders should use the supplied outbound SOAP Envelope from the message context, if it exists 
 
 Changes in Release 2.5.3
 =============================================

Modified: branches/REL_2/src/main/java/org/opensaml/saml1/binding/encoding/HTTPSOAP11Encoder.java
URL: http://svn.shibboleth.net/view/java-opensaml2/branches/REL_2/src/main/java/org/opensaml/saml1/binding/encoding/HTTPSOAP11Encoder.java?rev=1608&r1=1607&r2=1608&view=diff
==============================================================================
--- branches/REL_2/src/main/java/org/opensaml/saml1/binding/encoding/HTTPSOAP11Encoder.java (original)
+++ branches/REL_2/src/main/java/org/opensaml/saml1/binding/encoding/HTTPSOAP11Encoder.java Fri Jan 11 20:13:35 2013
@@ -86,8 +86,7 @@
         }
 
         signMessage(samlMsgCtx);
-        Envelope envelope = buildSOAPMessage(samlMessage);
-        samlMsgCtx.setOutboundMessage(envelope);
+        Envelope envelope = buildSOAPMessage(samlMsgCtx, samlMessage);
 
         Element envelopeElem = marshallMessage(envelope);
         try {
@@ -109,6 +108,47 @@
         }
     }
 
+    /**
+     * Builds the SOAP message to be encoded.
+     * 
+     * <p>If {@link SAMLMessageContext#getOutboundMessage()} contains
+     * a pre-existing SOAP envelope, it will be used.  Any existing body content will be removed
+     * before the SAML protocol message is added.
+     * </p>
+     * 
+     * <p>
+     * Otherwise, a new Envelope will be constructed.
+     * </p>
+     * 
+     * @param samlMsgCtx the SAML message context
+     * @param samlMessage body of the SOAP message
+     * 
+     * @return the SOAP message
+     */
+    @SuppressWarnings("unchecked")
+    protected Envelope buildSOAPMessage(SAMLMessageContext samlMsgCtx, SAMLObject samlMessage) {
+        Envelope envelope = null;
+        if (samlMsgCtx.getOutboundMessage() != null && samlMsgCtx.getOutboundMessage() instanceof Envelope) {
+            envelope = (Envelope) samlMsgCtx.getOutboundMessage();
+            Body body = envelope.getBody();
+            if (body == null) {
+                XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
+                SOAPObjectBuilder<Body> bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory
+                        .getBuilder(Body.DEFAULT_ELEMENT_NAME);
+                body = bodyBuilder.buildObject();
+                envelope.setBody(body);
+            } else if (!body.getUnknownXMLObjects().isEmpty()) {
+                log.warn("Supplied SOAP Envelope Body was not empty. Existing contents will be removed.");
+                body.getUnknownXMLObjects().clear();
+            }
+            body.getUnknownXMLObjects().add(samlMessage);
+        } else {
+            envelope = buildSOAPMessage(samlMessage);
+            samlMsgCtx.setOutboundMessage(envelope);
+        }
+        return envelope;
+    }
+    
     /**
      * Builds the SOAP message to be encoded.
      * 

Modified: branches/REL_2/src/main/java/org/opensaml/saml2/binding/encoding/HTTPSOAP11Encoder.java
URL: http://svn.shibboleth.net/view/java-opensaml2/branches/REL_2/src/main/java/org/opensaml/saml2/binding/encoding/HTTPSOAP11Encoder.java?rev=1608&r1=1607&r2=1608&view=diff
==============================================================================
--- branches/REL_2/src/main/java/org/opensaml/saml2/binding/encoding/HTTPSOAP11Encoder.java (original)
+++ branches/REL_2/src/main/java/org/opensaml/saml2/binding/encoding/HTTPSOAP11Encoder.java Fri Jan 11 20:13:35 2013
@@ -97,8 +97,7 @@
         }
 
         signMessage(samlMsgCtx);
-        Envelope envelope = buildSOAPMessage(samlMessage);
-        samlMsgCtx.setOutboundMessage(envelope);

[... 216 lines stripped ...]


More information about the commits mailing list