I noticed in my document countersigned with xades4j there is no Type="..CountersignedSignature" in the Reference of countersigned signature. The same is in xades4j unit test in document.signed.bes.cs.xml.
On the other hand, in xades4j.properties.CounterSignatureProperty
I can see the following property defined:
public String COUNTER_SIGNATURE_TYPE_URI = "http://uri.etsi.org/01903#CountersignedSignature";
How can I force xades to use that property? If the type attribute is missing I have a problem with validating the document in other 3rd party software.
I used code written in SignerBESTest.
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(final SignaturePropertiesCollector signedPropsCol) {
signedPropsCol.addCounterSignature(new CounterSignatureProperty(counterSigner));
signedPropsCol.setSignerRole(new SignerRoleProperty("CounterSignature"));
}
});
final XadesSignatureFormatExtender extender = new XadesFormatExtenderProfile().getFormatExtender();
final List<UnsignedSignatureProperty> unsignedProps = new ArrayList<UnsignedSignatureProperty>();
unsignedProps.add(new CounterSignatureProperty(counterSigner));
org.apache.xml.security.Init.init();
final Element sigElem = (Element) documentSource.getElementsByTagName("ds:Signature").item(0);
final XMLSignature xmlSig = new XMLSignature(sigElem, documentSource.getBaseURI());
extender.enrichSignature(xmlSig, new UnsignedProperties(unsignedProps));
Thanks in advance!
Edit1: I will add that I know the solution by modifying xades4j sources but I would be more interested with a solution which I can apply only in my source code.