-
Notifications
You must be signed in to change notification settings - Fork 66
DefiningQualifyingProperties
The classes that represent the signed data objects also enable the specification of the qualifying properties that apply to each data object, such as DataObjectFormat
and IndividualDataObjectTimeStamp
.
DataObjectDesc obj = new DataObjectReference("rfc3161.txt")
.withDataObjectFormat(new DataObjectFormatProperty("text/plain"))
.withDataObjectTimeStamp();
Some qualifying properties apply to all the data objects that are present on a signature. Those properties can be defined using the SignedDataObjects
class.
SignedDataObjects dataObjs = new SignedDataObjects(obj)
.withCommitmentType(AllDataObjsCommitmentTypeProperty.proofOfOrigin())
.withDataObjectsTimeStamp();
Another option to define data object properties is to use a custom DataObjectPropertiesProvider
which is invoked when no properties are explicitly specified for a given object. This can be useful when all the data objects share the same properties.
Most XAdES qualifying properties are part of the different signature forms. As such, XAdES4j always includes the properties for the form in use when creating a signature. For instance, if a XadesTSigningProfile
is used, the resulting signer will always include the SignatureTimeStamp
property.
Nevertheless, XAdES includes some optional signature properties, such as SignatureProductionPlace
and CounterSignature
, that can be used with all the forms. These properties can be included using a custom SignaturePropertiesProvider
which is configured in the signing profile, as all the other providers.
XadesSigningProfile profile = new XadesBesSigningProfile(...).withSignaturePropertiesProvider(new SignaturePropertiesProvider()
{
@Override
public void provideProperties(SignaturePropertiesCollector signedPropsCol)
{
signedPropsCol.setSignerRole(new SignerRoleProperty("CTO"));
signedPropsCol.setSignatureProductionPlace(new SignatureProductionPlaceProperty("City", "Country"));
signaturePropsCol.setSigningTime(new SigningTimeProperty());
}
});
The default SignaturePropertiesProvider
only includes the SigningTime
property.
Formats such as yyyy-MM-dd'T'HH:mm:ss'Z'
or yyyy-MM-dd'T'HH:mm:ss.fff'Z'
can be achieved by crafting the Calendar
instance provided to the SigningTimeProperty
, since time-zone information is preserved by JAXB's built-in date conversion. The following code results in "2020-05-01T22:30:00Z":
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
c.clear();
c.set(2020, 4, 1, 22, 30);
signedPropsCol.setSigningTime(new SigningTimeProperty(c));