reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
actions.add(new Integer(WSConstants.SIGN));
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
handler.send(
WSConstants.SIGN, doc, reqData, actions, true
);
if (LOG.isDebugEnabled()) {
LOG.debug("After Signing....");
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
LOG.debug(outputString);
}
//
// Verify the inbound request, and create a response with a Signature Confirmation
//
List<WSSecurityEngineResult> results = verify(doc);
actions.clear();
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(
WSConstants.NO_SECURITY, doc, reqData, actions, false
);
String outputString =
org.apache.ws.security.util.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);
}