* <p/>
*
* @throws java.lang.Exception Thrown when there is any problem in signing or verification
*/
public void testX509SignatureSKISTR() throws Exception {
WSSecSignature builder = new WSSecSignature();
builder.setUserInfo("wss4jcert", "security");
// builder.setUserInfo("john", "keypass");
SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope.getAsDOM());
Vector parts = new Vector();
/*
* 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(), // define the body
soapConstants.getEnvelopeURI(),
"Content");
parts.add(encP);
encP =
new WSEncryptionPart(
"STRTransform", // reserved word to use STRTransform
soapConstants.getEnvelopeURI(),
"Content");
parts.add(encP);
builder.setParts(parts);
builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
LOG.info("Before Signing STR SKI....");
Document doc = unsignedEnvelope.getAsDocument();
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
Document signedDoc = builder.build(doc, crypto, secHeader);
if (LOG.isDebugEnabled()) {
LOG.debug("Signed message with STR SKI key identifier:");
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);