String outputString =
XMLUtils.PrettyDocumentToString(doc);
LOG.debug(outputString);
}
WSSecurityEngine secEngine = new WSSecurityEngine();
secEngine.setWssConfig(WSSConfig.getNewInstance());
// Processing should fail as we have no ValueType attribute
try {
secEngine.processSecurityHeader(doc, null, null, crypto);
fail("Expected failure on no ValueType");
} catch (WSSecurityException ex) {
// expected
}
doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
bst = new BinarySecurity(doc);
bst.setToken("12435677".getBytes());
bst.setValueType("http://custom_value_Type");
secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
List<WSSecurityEngineResult> results =
secEngine.processSecurityHeader(doc, null, null, crypto);
WSSecurityEngineResult actionResult =
WSSecurityUtil.fetchActionResult(results, WSConstants.BST);
BinarySecurity token =
(BinarySecurity)actionResult.get(WSSecurityEngineResult.TAG_BINARY_SECURITY_TOKEN);
assertNotNull(token);