use of xades4j.properties.data.CommitmentTypeData in project xades4j by luisgoncalves.
the class DataGenCommitmentTypeAllDataObjs method generatePropertyData.
@Override
public PropertyDataObject generatePropertyData(AllDataObjsCommitmentTypeProperty prop, PropertiesDataGenerationContext ctx) {
CommitmentTypeData commTypeData = new CommitmentTypeData(prop.getUri(), prop.getDescription());
commTypeData.setQualifiers(prop.getQualifiers());
return commTypeData;
}
use of xades4j.properties.data.CommitmentTypeData in project xades4j by luisgoncalves.
the class FromXmlCommitmentTypeConverter method convertFromObjectTree.
@Override
public void convertFromObjectTree(XmlSignedDataObjectPropertiesType xmlProps, QualifyingPropertiesDataCollector propertyDataCollector) throws PropertyUnmarshalException {
List<XmlCommitmentTypeIndicationType> xmlCommitments = xmlProps.getCommitmentTypeIndication();
if (xmlCommitments.isEmpty()) {
return;
}
for (XmlCommitmentTypeIndicationType xmlCommitment : xmlCommitments) {
List<String> objsRefs = xmlCommitment.getObjectReference();
Object allDataObjs = xmlCommitment.getAllSignedDataObjects();
if (objsRefs.isEmpty()) {
// Should be AllSignedDataObjects.
objsRefs = null;
if (null == allDataObjs) {
throw new PropertyUnmarshalException("ObjectReference or AllSignedDataObjects have to be present", CommitmentTypePropertyBase.PROP_NAME);
}
} else if (allDataObjs != null) {
throw new PropertyUnmarshalException("Both ObjectReference and AllSignedDataObjects are present", CommitmentTypePropertyBase.PROP_NAME);
}
CommitmentTypeData commTypeData = new CommitmentTypeData(xmlCommitment.getCommitmentTypeId().getIdentifier().getValue(), xmlCommitment.getCommitmentTypeId().getDescription());
commTypeData.setObjReferences(objsRefs);
XmlCommitmentTypeQualifiersListType xmlQualifiers = xmlCommitment.getCommitmentTypeQualifiers();
if (xmlQualifiers != null) {
Collection qualifiers = new ArrayList();
for (XmlAnyType xmlQualifier : xmlQualifiers.getCommitmentTypeQualifier()) {
if (!xmlQualifier.getContent().isEmpty()) {
if (xmlQualifier.getContent().size() > 1) {
throw new PropertyUnmarshalException("Qualifiers with multiple children are not support", CommitmentTypePropertyBase.PROP_NAME);
}
qualifiers.add(xmlQualifier.getContent().get(0));
}
}
commTypeData.setQualifiers(qualifiers);
}
propertyDataCollector.addCommitmentType(commTypeData);
}
}
use of xades4j.properties.data.CommitmentTypeData in project xades4j by luisgoncalves.
the class DataGenCommitmentType method generatePropertyData.
@Override
public PropertyDataObject generatePropertyData(CommitmentTypeProperty prop, PropertiesDataGenerationContext ctx) {
CommitmentTypeData commTypeData = new CommitmentTypeData(prop.getUri(), prop.getDescription());
/* One ObjectReference element refers to one ds:Reference element of the
* ds:SignedInfo corresponding with one data object qualified by this
* property. If some but not all the signed data objects share the same
* commitment, one ObjectReference element MUST appear for each one of
* them. However, if all the signed data objects share the same commitment,
* the AllSignedDataObjects empty element MUST be present.
*/
Collection<DataObjectDesc> targets = prop.getTargetDataObjects();
Map<DataObjectDesc, Reference> referencesMappings = ctx.getReferencesMappings();
for (DataObjectDesc obj : targets) {
// The ObjectReference refers the Reference element. This assumes
// that the QualifyingProperties are in the signature's document.
commTypeData.addObjReferences('#' + referencesMappings.get(obj).getId());
}
commTypeData.setQualifiers(prop.getQualifiers());
return commTypeData;
}
use of xades4j.properties.data.CommitmentTypeData in project xades4j by luisgoncalves.
the class ToXmlCommitmentTypeConverter method convertIntoObjectTree.
@Override
public void convertIntoObjectTree(PropertyDataObject propData, XmlSignedPropertiesType xmlProps, Document doc) {
CommitmentTypeData commitmentTypeData = (CommitmentTypeData) propData;
// Create the JAXB CommitmentTypeIndication and add it to SignedDataObjectProperties.
XmlCommitmentTypeIndicationType xmlCommitmentTypeProp = new XmlCommitmentTypeIndicationType();
xmlProps.getSignedDataObjectProperties().getCommitmentTypeIndication().add(xmlCommitmentTypeProp);
XmlIdentifierType xmlIdentifier = new XmlIdentifierType();
xmlIdentifier.setValue(commitmentTypeData.getUri());
XmlObjectIdentifierType xmlObjectId = new XmlObjectIdentifierType();
xmlObjectId.setDescription(commitmentTypeData.getDescription());
xmlObjectId.setIdentifier(xmlIdentifier);
xmlCommitmentTypeProp.setCommitmentTypeId(xmlObjectId);
Collection<String> refsUris = commitmentTypeData.getObjReferences();
if (null == refsUris) {
xmlCommitmentTypeProp.setAllSignedDataObjects();
} else {
xmlCommitmentTypeProp.getObjectReference().addAll(refsUris);
}
Collection qualifiers = commitmentTypeData.getQualifiers();
if (!qualifiers.isEmpty()) {
XmlCommitmentTypeQualifiersListType xmlQualifiers = new XmlCommitmentTypeQualifiersListType();
for (Object q : qualifiers) {
XmlAnyType xmlQualifier = new XmlAnyType();
xmlQualifier.getContent().add(q);
xmlQualifiers.getCommitmentTypeQualifier().add(xmlQualifier);
}
xmlCommitmentTypeProp.setCommitmentTypeQualifiers(xmlQualifiers);
}
}
Aggregations