use of javax.xml.crypto.URIDereferencer in project santuario-java by apache.
the class CreatePhaosXMLDSig3Test method test_create_hmac_sha1_exclusive_c14n_comments_detached.
private void test_create_hmac_sha1_exclusive_c14n_comments_detached(boolean fortyBit) throws Exception {
// create reference
Reference ref = fac.newReference("http://www.ietf.org/rfc/rfc3161.txt", fac.newDigestMethod(DigestMethod.SHA1, null));
// create SignedInfo
HMACParameterSpec spec = null;
if (fortyBit) {
spec = new HMACParameterSpec(40);
}
SignedInfo si = fac.newSignedInfo(fac.newCanonicalizationMethod(CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS, (C14NMethodParameterSpec) null), fac.newSignatureMethod(SignatureMethod.HMAC_SHA1, spec), Collections.singletonList(ref));
// create XMLSignature
XMLSignature sig = fac.newXMLSignature(si, null);
Document doc = db.newDocument();
DOMSignContext dsc = new DOMSignContext(new KeySelectors.SecretKeySelector("test".getBytes(StandardCharsets.US_ASCII)), doc);
dsc.putNamespacePrefix(XMLSignature.XMLNS, "dsig");
URIDereferencer ud = new LocalHttpCacheURIDereferencer();
dsc.setURIDereferencer(ud);
sig.sign(dsc);
TestUtils.validateSecurityOrEncryptionElement(doc.getDocumentElement());
DOMValidateContext dvc = new DOMValidateContext(new KeySelectors.SecretKeySelector("test".getBytes(StandardCharsets.US_ASCII)), doc);
dvc.setURIDereferencer(ud);
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
Aggregations