*/
public void testUsernameTokenSigning() throws Exception {
SOAPEnvelope envelope = null;
Document doc = unsignedEnvelope.getAsDocument();
WSSAddUsernameToken builder = new WSSAddUsernameToken();
builder.setPasswordType(WSConstants.PASSWORD_TEXT);
builder.preSetUsernameToken(doc, "wernerd", "verySecret");
builder.addCreated(doc);
builder.addNonce(doc);
WSSignEnvelope sign = new WSSignEnvelope(null, true);
sign.setUsernameToken(builder);
sign.setKeyIdentifierType(WSConstants.UT_SIGNING);
sign.setSignatureAlgorithm(XMLSignature.ALGO_ID_MAC_HMAC_SHA1);
log.info("Before signing....");
sign.build(doc, null);
log.info("Before adding UsernameToken PW Text....");
Document signedDoc = builder.build(doc, "wernerd", "verySecret");
Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
if (log.isDebugEnabled()) {
log.debug("Message with UserNameToken PW Text:");
XMLUtils.PrettyElementToWriter(signedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
}