Search in sources :

Example 1 with SignedObjectsData

use of xades4j.verification.QualifyingPropertyVerificationContext.SignedObjectsData in project xades4j by luisgoncalves.

the class IndivDataObjsTimeStampVerifier method addPropSpecificTimeStampInputAndCreateProperty.

@Override
protected QualifyingProperty addPropSpecificTimeStampInputAndCreateProperty(IndividualDataObjsTimeStampData propData, TimeStampDigestInput digestInput, QualifyingPropertyVerificationContext ctx) throws CannotAddDataToDigestInputException, TimeStampVerificationException {
    SignedObjectsData dataObjsData = ctx.getSignedObjectsData();
    IndividualDataObjsTimeStampProperty prop = new IndividualDataObjsTimeStampProperty();
    for (String objRef : propData.getIncludes()) {
        RawDataObjectDesc o = dataObjsData.findSignedDataObject(objRef);
        if (null == o) {
            throw new TimeStampDigestInputException(IndividualDataObjsTimeStampProperty.PROP_NAME);
        }
        digestInput.addReference(o.getReference());
        // No problem because when an exception is thrown the data
        // structures in the verification process are not reused.
        o.withDataObjectTimeStamp(prop);
    }
    return prop;
}
Also used : SignedObjectsData(xades4j.verification.QualifyingPropertyVerificationContext.SignedObjectsData) IndividualDataObjsTimeStampProperty(xades4j.properties.IndividualDataObjsTimeStampProperty)

Example 2 with SignedObjectsData

use of xades4j.verification.QualifyingPropertyVerificationContext.SignedObjectsData 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

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