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.SIGN);
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
//
List<WSSecurityEngineResult> results = verify(doc);
doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
msgContext = (java.util.Map<String, Object>)reqData.getMsgContext();
WSHandlerResult handlerResult = new WSHandlerResult(null, results);
List<WSHandlerResult> receivedResults = new ArrayList<WSHandlerResult>();
receivedResults.add(handlerResult);
msgContext.put(WSHandlerConstants.RECV_RESULTS, receivedResults);
handler.send(
doc,
reqData,
Collections.singletonList(action),
false
);
String outputString =
XMLUtils.PrettyDocumentToString(doc);
if (LOG.isDebugEnabled()) {
LOG.debug("Signature Confirmation response....");
LOG.debug(outputString);
}
//
// Verify the SignatureConfirmation response
//
results = verify(doc);
WSSecurityEngineResult scResult =
WSSecurityUtil.fetchActionResult(results, WSConstants.SC);
assertTrue(scResult != null);
assertTrue(scResult.get(WSSecurityEngineResult.TAG_SIGNATURE_CONFIRMATION) != null);
handler.signatureConfirmation(reqData, results);
}