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 2019/09/16 14:15:56 UTC
svn commit: r1867004 -
/webservices/wss4j/branches/2_2_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java
Author: coheigea
Date: Mon Sep 16 14:15:56 2019
New Revision: 1867004
URL: http://svn.apache.org/viewvc?rev=1867004&view=rev
Log:
Adding a SignatureConfirmation unit test
Modified:
webservices/wss4j/branches/2_2_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java
Modified: webservices/wss4j/branches/2_2_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_2_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java?rev=1867004&r1=1867003&r2=1867004&view=diff
==============================================================================
--- webservices/wss4j/branches/2_2_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java (original)
+++ webservices/wss4j/branches/2_2_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java Mon Sep 16 14:15:56 2019
@@ -205,6 +205,7 @@ public class SignatureConfirmationTest e
LOG.debug(outputString);
}
assertTrue(outputString.contains("SignatureConfirmation"));
+ assertTrue(outputString.contains("Value"));
}
@@ -310,6 +311,59 @@ public class SignatureConfirmationTest e
newEngine.processSecurityHeader(doc, data);
}
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testSignatureResponseForUnsignedRequest() throws Exception {
+ final RequestData reqData = new RequestData();
+ java.util.Map<String, Object> msgContext = new java.util.TreeMap<>();
+ msgContext.put(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
+ msgContext.put(WSHandlerConstants.SIG_PROP_FILE, "crypto.properties");
+ msgContext.put("password", "security");
+ reqData.setMsgContext(msgContext);
+ reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
+
+ Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+ CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.NO_SECURITY);
+ handler.send(
+ doc,
+ reqData,
+ Collections.singletonList(action),
+ true
+ );
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("After Signing....");
+ String outputString =
+ XMLUtils.prettyDocumentToString(doc);
+ LOG.debug(outputString);
+ }
+
+ //
+ // Verify the inbound request, and create a response with a Signature Confirmation
+ //
+ WSHandlerResult results = verify(doc);
+ doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+ msgContext = (java.util.Map<String, Object>)reqData.getMsgContext();
+ List<WSHandlerResult> receivedResults = new ArrayList<>();
+ receivedResults.add(results);
+ msgContext.put(WSHandlerConstants.RECV_RESULTS, receivedResults);
+ action = new HandlerAction(WSConstants.NO_SECURITY);
+ handler.send(
+ doc,
+ reqData,
+ Collections.singletonList(action),
+ false
+ );
+ String outputString =
+ XMLUtils.prettyDocumentToString(doc);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Signature Confirmation response....");
+ LOG.debug(outputString);
+ }
+ assertTrue(outputString.contains("SignatureConfirmation"));
+ // We should have no Value attribute
+ assertFalse(outputString.contains("Value"));
+ }
/**
* Verifies the soap envelope