Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
// Load the keystore
Crypto crypto = new Merlin();
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
ClassLoader loader = Loader.getClassLoader(CryptoTest.class);
InputStream input = Merlin.loadInputStream(loader, "keys/wss40.jks");
keyStore.load(input, "security".toCharArray());
((Merlin)crypto).setKeyStore(keyStore);
Document signedDoc = builder.build(doc, crypto, secHeader);
// Load the truststore
Crypto processCrypto = new Merlin();
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
input = Merlin.loadInputStream(loader, "keys/wss40CA.jks");
trustStore.load(input, "security".toCharArray());
((Merlin)processCrypto).setTrustStore(trustStore);
WSSecurityEngine secEngine = new WSSecurityEngine();
secEngine.processSecurityHeader(signedDoc, null, null, processCrypto);
// Load a (bad) truststore
processCrypto = new Merlin();
trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
input = Merlin.loadInputStream(loader, "keys/wss40badca.jks");
trustStore.load(input, "security".toCharArray());
((Merlin)processCrypto).setTrustStore(trustStore);