final WSSConfig cfg = WSSConfig.getNewInstance();
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
java.util.Map<String, Object> messageContext = new java.util.TreeMap<String, Object>();
messageContext.put(
WSHandlerConstants.PW_CALLBACK_REF, new KeystoreCallbackHandler()
);
reqData.setMsgContext(messageContext);
EncryptionActionToken actionToken = new EncryptionActionToken();
actionToken.setUser("wss40");
actionToken.setCryptoProperties("wss40.properties");
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
List<HandlerAction> actions = new ArrayList<HandlerAction>();
actions.add(new HandlerAction(WSConstants.ENCR, actionToken));
handler.send(
doc,
reqData,
actions,
true
);
if (LOG.isDebugEnabled()) {
String outputString =
XMLUtils.PrettyDocumentToString(doc);
LOG.debug(outputString);
}
verify(doc, new KeystoreCallbackHandler());
}