Search in sources :

Example 1 with CommitmentTypePropertyBase

use of xades4j.properties.CommitmentTypePropertyBase in project xades4j by luisgoncalves.

the class CommitmentTypeVerifier method verify.

@Override
public QualifyingProperty verify(CommitmentTypeData propData, QualifyingPropertyVerificationContext ctx) throws CommitmentTypeVerificationException {
    String uri = propData.getUri(), desc = propData.getDescription();
    Collection<String> objsReferences = propData.getObjReferences();
    CommitmentTypePropertyBase property;
    if (objsReferences != null) {
        // "Check that all the ObjectReference elements actually reference
        // ds:Reference elements from the signature."
        SignedObjectsData signedObjsData = ctx.getSignedObjectsData();
        CommitmentTypeProperty commitmentTypeProperty = new CommitmentTypeProperty(uri, desc);
        for (String objRef : objsReferences) {
            RawDataObjectDesc dataObj = signedObjsData.findSignedDataObject(objRef);
            if (null == dataObj)
                throw new CommitmentTypeVerificationException(objRef);
            // Associate the property to the data object.
            dataObj.withCommitmentType(commitmentTypeProperty);
        }
        property = commitmentTypeProperty;
    } else {
        property = new AllDataObjsCommitmentTypeProperty(uri, desc);
    }
    if (propData.getQualifiers() != null) {
        for (Object q : propData.getQualifiers()) {
            if (q instanceof String) {
                property.withQualifier((String) q);
            } else if (q instanceof Element) {
                property.withQualifier((Element) q);
            }
        }
    }
    return property;
}
Also used : AllDataObjsCommitmentTypeProperty(xades4j.properties.AllDataObjsCommitmentTypeProperty) CommitmentTypePropertyBase(xades4j.properties.CommitmentTypePropertyBase) Element(org.w3c.dom.Element) SignedObjectsData(xades4j.verification.QualifyingPropertyVerificationContext.SignedObjectsData) CommitmentTypeProperty(xades4j.properties.CommitmentTypeProperty) AllDataObjsCommitmentTypeProperty(xades4j.properties.AllDataObjsCommitmentTypeProperty)

Aggregations

Element (org.w3c.dom.Element)1 AllDataObjsCommitmentTypeProperty (xades4j.properties.AllDataObjsCommitmentTypeProperty)1 CommitmentTypeProperty (xades4j.properties.CommitmentTypeProperty)1 CommitmentTypePropertyBase (xades4j.properties.CommitmentTypePropertyBase)1 SignedObjectsData (xades4j.verification.QualifyingPropertyVerificationContext.SignedObjectsData)1