}
@Test
public void testRIPEMD160() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
// Set the key up
byte[] hmacKey = "secret".getBytes("ASCII");
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-ripemd160";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
properties.setSignatureKey(key);
properties.setSignatureAlgorithm(signatureAlgorithm);
SecurePart securePart = new SecurePart(
new QName("urn:example:po", "PaymentInfo"),
SecurePart.Modifier.Content,
new String[]{"http://www.w3.org/2001/10/xml-exc-c14n#"},
"http://www.w3.org/2000/09/xmldsig#sha1");
properties.addSignaturePart(securePart);
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(sourceDocument);
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
// System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
Document document =
XMLUtils.createDocumentBuilder(false).parse(new ByteArrayInputStream(baos.toByteArray()));
// Verify using DOM
verifyUsingDOM(document, key, properties.getSignatureSecureParts());
}