You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2015/07/06 16:41:43 UTC
svn commit: r1689417 -
/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java
Author: coheigea
Date: Mon Jul 6 14:41:43 2015
New Revision: 1689417
URL: http://svn.apache.org/r1689417
Log:
[WSS-544] - Adding BinarySecurityToken test
Modified:
webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java?rev=1689417&r1=1689416&r2=1689417&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java Mon Jul 6 14:41:43 2015
@@ -206,6 +206,39 @@ public class XOPAttachmentTest extends o
assertTrue(processedDoc.contains(SOAP_BODY));
}
+ // Here we are storing the BinarySecurityToken bytes in an attachment
+ @org.junit.Test
+ public void testSignedSOAPBody() throws Exception {
+ WSSecSignature builder = new WSSecSignature();
+ builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+ builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+
+ Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+ WSSecHeader secHeader = new WSSecHeader(doc);
+ secHeader.insertSecurityHeader();
+
+ AttachmentCallbackHandler outboundAttachmentCallback = new AttachmentCallbackHandler();
+ builder.setAttachmentCallbackHandler(outboundAttachmentCallback);
+ builder.setStoreBytesInAttachment(true);
+
+ Document signedDoc = builder.build(doc, crypto, secHeader);
+
+ List<Attachment> signedAttachments = outboundAttachmentCallback.getResponseAttachments();
+ assertNotNull(signedAttachments);
+ assertTrue(signedAttachments.size() == 1);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("After Signing....");
+ String outputString =
+ XMLUtils.PrettyDocumentToString(signedDoc);
+ LOG.debug(outputString);
+ }
+
+ AttachmentCallbackHandler inboundAttachmentCallback =
+ new AttachmentCallbackHandler(signedAttachments);
+ verify(signedDoc, inboundAttachmentCallback);
+ }
+
/**
* Verifies the soap envelope.
* This method verifies all the signature generated.