use of xades4j.providers.SignaturePropertiesProvider in project xades4j by luisgoncalves.
the class SignerBESTest method testSignBESWithCounterSig.
@Test
public void testSignBESWithCounterSig() throws Exception {
System.out.println("signBESWithCounterSig");
Document doc = getTestDocument();
Element elemToSign = doc.getDocumentElement();
XadesBesSigningProfile profile = new XadesBesSigningProfile(keyingProviderMy);
final XadesSigner counterSigner = profile.newSigner();
profile.withSignaturePropertiesProvider(new SignaturePropertiesProvider() {
@Override
public void provideProperties(SignaturePropertiesCollector signedPropsCol) {
signedPropsCol.addCounterSignature(new CounterSignatureProperty(counterSigner));
signedPropsCol.setSignerRole(new SignerRoleProperty("CounterSignature maniac"));
}
});
SignerBES signer = (SignerBES) profile.newSigner();
DataObjectDesc obj1 = new DataObjectReference('#' + elemToSign.getAttribute("Id")).withTransform(new EnvelopedSignatureTransform());
SignedDataObjects dataObjs = new SignedDataObjects().withSignedDataObject(obj1);
signer.sign(dataObjs, elemToSign);
outputDocument(doc, "document.signed.bes.cs.xml");
}
Aggregations