WSSConfig.getNewInstance();
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
BinarySecurity bst = new BinarySecurity(doc);
bst.setValueType(AP_REQ);
bst.setEncodingType(BASE64_NS);
bst.setToken("12345678".getBytes());
bst.setID("Id-" + bst.hashCode());
WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
WSSecTimestamp timestamp = new WSSecTimestamp();
timestamp.setTimeToLive(600);
timestamp.build(doc, secHeader);
WSSecSignature sign = new WSSecSignature();
sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
Vector parts = new Vector();
parts.add(new WSEncryptionPart(bst.getID()));
parts.add(new WSEncryptionPart(timestamp.getId()));
sign.setParts(parts);
Document signedDoc = sign.build(doc, crypto, secHeader);