* This is a test for WSS-96:
* "Error when making a signature when containing a WSSecTimestamp"
* A timestamp is added to the document and signed.
*/
public void testWSS96() throws Exception {
WSSecSignature builder = new WSSecSignature();
builder.setUserInfo("wss4jcert", "security");
SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope.getAsDOM());
Vector parts = new Vector();
Document doc = unsignedEnvelope.getAsDocument();
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
/*
* Set up to sign body and use STRTransorm to sign
* the signature token (e.g. X.509 certificate)
*/
WSEncryptionPart encP =
new WSEncryptionPart(
soapConstants.getBodyQName().getLocalPart(),
soapConstants.getEnvelopeURI(),
"Content");
parts.add(encP);
encP =
new WSEncryptionPart(
"STRTransform",
soapConstants.getEnvelopeURI(),
"Content");
parts.add(encP);
WSSecTimestamp timestamp = new WSSecTimestamp();
timestamp.setTimeToLive(600);
timestamp.build(doc, secHeader);
parts.add(new WSEncryptionPart(timestamp.getId()));
builder.setParts(parts);
builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
LOG.info("Before Signing STR DirectReference....");
Document signedDoc = builder.build(doc, crypto, secHeader);
if (LOG.isDebugEnabled()) {
LOG.debug("Signed message with STR DirectReference key identifier:");
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);