I'm trying to sign a XML document using XADES-BES and the smart card. I made some changes in the class SignerBES.java according to my needs and the signature creation is working well !
My question: How can I add UnsignedProperties to get something like this :
<SignerRole>
<ClaimedRoles>
<ClaimedRole>EST</ClaimedRole>
</ClaimedRoles>
</SignerRole>
</SignedSignatureProperties>
<SignedDataObjectProperties>
<DataObjectFormat ObjectReference="#sigId">
<Description>des</Description>
<MimeType>text/xml</MimeType>
<Encoding>base64</Encoding>
</DataObjectFormat>
<CommitmentTypeIndication>
<CommitmentTypeId>
<Identifier/>
</CommitmentTypeId>
<AllSignedDataObjects/>
<CommitmentTypeQualifiers>
<CommitmentTypeQualifier>commitment</CommitmentTypeQualifier>
</CommitmentTypeQualifiers>
</CommitmentTypeIndication>
</SignedDataObjectProperties>
</SignedProperties>
<UnsignedProperties>
<UnsignedSignatureProperties>
<SignatureTimeStamp>
<EncapsulatedTimeStamp>noTimStampToken</EncapsulatedTimeStamp>
</SignatureTimeStamp>
<CounterSignature/>
<CompleteCertificateRefs/>
<CompleteRevocationRefs/>
<SigAndRefsTimeStamp/>
<RefsOnlyTimeStamp/>
<CertificatesValues/>
<RevocationValues/>
<ArchiveTimeStamp/>
</UnsignedSignatureProperties>
</UnsignedProperties>
</QualifyingProperties>
</ds:Object>
this is a code snippet SignerBES.java:
Collection<SignedSignatureProperty> fsssp = new ArrayList<SignedSignatureProperty>(2);
Collection<UnsignedSignatureProperty> fsusp = new ArrayList<UnsignedSignatureProperty>(2);
getFormatSpecificSignatureProperties(fsssp, fsusp, signingCertificateChain);
// Gather all the signature and data objects properties.
QualifyingProperties qualifProps = qualifPropsProcessor.getQualifyingProperties(
signedDataObjects, fsssp, fsusp);
// LOG
System.out.println("fsusp"+fsusp.size());
I tried to add it at SignerBES.java and DefaultSignaturePropertiesProvider.java but I do not know how I can add it :
public class DefaultSignaturePropertiesProvider implements SignaturePropertiesProvider
{
@Override
public void provideProperties(SignaturePropertiesCollector signaturePropsCol)
{
signaturePropsCol.setSigningTime(new SigningTimeProperty());
signaturePropsCol.setSignerRole(new SignerRoleProperty("EST"));
// UnsignedProperty
// OtherUnsignedSignatureProperty otherUnsignedProp=null;
// signaturePropsCol.addOtherSignatureProperty(otherUnsignedProp);
}}
I don't think I understand completely what you're trying, since it seems you're messing around the lib source code. Anyway, check out this page on the project docs.
Many of the unsigned qualifying properties are added automatically by xades4j when you use one of the signing profiles (e.g. if you use XAdesCSigningProfile
, CompleteCertificateRefs/CompleteRevocationRefs are added).
Other properties are part of advanced forms and can only be added during validation of an existing signature. Refer to this wiki page and [this javadocs page](http://luisgoncalves.github.io/xades4j/javadocs/1.4.0/reference/xades4j/verification/XadesVerifier.html#verify(org.w3c.dom.Element, xades4j.verification.SignatureSpecificVerificationOptions, xades4j.production.XadesSignatureFormatExtender, xades4j.verification.XAdESForm)) for additional info.
Finally, some properties (e.g. CounterSignature) are not tied to any specific form, and can be added to any signature using a custom SignaturePropertiesProvider
, registered on the signing profile that you are using.