use of xades4j.properties.QualifyingProperty in project xades4j by luisgoncalves.
the class PropertiesDataObjectsGeneratorImpl method doGenPropsData.
private <TProp extends QualifyingProperty> Collection<PropertyDataObject> doGenPropsData(Collection<TProp> props, PropertiesDataGenerationContext ctx) throws PropertyDataGenerationException, PropertyDataStructureException {
Collection<PropertyDataObject> propsData = new ArrayList<PropertyDataObject>(props.size());
for (TProp p : props) {
PropertyDataObjectGenerator<TProp> dataGen = this.propsDataGensMapper.getGenerator(p);
PropertyDataObject pData = dataGen.generatePropertyData(p, ctx);
if (null == pData)
throw new PropertyDataGeneratorErrorException((QualifyingProperty) p);
propsData.add(pData);
}
dataObjectsStructureVerifier.verifiyPropertiesDataStructure(propsData);
return propsData;
}
use of xades4j.properties.QualifyingProperty in project xades4j by luisgoncalves.
the class TestElemDOMVerifier method testVerify.
@Test
public void testVerify() throws Exception {
GenericDOMData propData = new GenericDOMData(testDocument.createElementNS("http://test.generic.dom", "Elem"));
QualifyingPropertyVerificationContext ctx = null;
GenericDOMDataVerifier instance = new GenericDOMDataVerifier(customElemVerifiers);
QualifyingProperty result = instance.verify(propData, ctx);
assertEquals(result.getName(), "Elem");
}
use of xades4j.properties.QualifyingProperty in project xades4j by luisgoncalves.
the class TimeStampVerifierBase method verify.
@Override
public final QualifyingProperty verify(TData propData, QualifyingPropertyVerificationContext ctx) throws InvalidPropertyException {
try {
TimeStampDigestInput digestInput = this.tsInputFactory.newTimeStampDigestInput(propData.getCanonicalizationAlgorithm());
QualifyingProperty prop = addPropSpecificTimeStampInputAndCreateProperty(propData, digestInput, ctx);
byte[] data = digestInput.getBytes();
/**
* Verify the time-stamp tokens on a time-stamp property data object. All
* the tokens are verified, but the returned time-stamp is from the last token.
*/
List<byte[]> tokens = propData.getTimeStampTokens();
Date ts = null;
for (byte[] tkn : tokens) {
ts = this.tsVerifier.verifyToken(tkn, data);
}
// By convention all timestamp property types have a setTime(Date) method
Method setTimeMethod = prop.getClass().getMethod("setTime", Date.class);
setTimeMethod.invoke(prop, ts);
return prop;
} catch (UnsupportedAlgorithmException ex) {
throw getEx(ex, this.propName);
} catch (CannotAddDataToDigestInputException ex) {
throw new TimeStampDigestInputException(this.propName, ex);
} catch (TimeStampTokenVerificationException ex) {
throw getEx(ex, this.propName);
} catch (Exception ex) {
// Exceptions related to setTimeMethod.invoke(...)
throw getEx(ex, this.propName);
}
}
use of xades4j.properties.QualifyingProperty in project xades4j by luisgoncalves.
the class XAdESVerificationResult method createQualifProps.
private QualifyingProperties createQualifProps() {
Collection<QualifyingProperty> props = this.propertiesGetter.getAll();
Collection<SignedSignatureProperty> ssp = CollectionUtils.filterByType(props, SignedSignatureProperty.class);
Collection<SignedDataObjectProperty> sdop = CollectionUtils.filterByType(props, SignedDataObjectProperty.class);
Collection<UnsignedSignatureProperty> usp = CollectionUtils.filterByType(props, UnsignedSignatureProperty.class);
Collection<UnsignedDataObjectProperty> udop = CollectionUtils.filterByType(props, UnsignedDataObjectProperty.class);
return new QualifyingProperties(new SignedProperties(ssp, sdop), new UnsignedProperties(usp, udop));
}
use of xades4j.properties.QualifyingProperty in project xades4j by luisgoncalves.
the class TimeStampCoherenceVerifier method verify.
@Override
public void verify(XAdESVerificationResult verificationData, QualifyingPropertyVerificationContext ctx) throws TimeStampCoherenceException {
DataGetter<QualifyingProperty> propsGetter = verificationData.getPropertiesFilter();
Collection<SignatureTimeStampProperty> sigTimeStamps = propsGetter.getOfType(SignatureTimeStampProperty.class);
Collection<AllDataObjsTimeStampProperty> allDataObjsTimeStamps = propsGetter.getOfType(AllDataObjsTimeStampProperty.class);
Collection<IndividualDataObjsTimeStampProperty> indivDataObjsTimeStamps = propsGetter.getOfType(IndividualDataObjsTimeStampProperty.class);
for (SignatureTimeStampProperty sigTs : sigTimeStamps) {
for (IndividualDataObjsTimeStampProperty indivDObjTs : indivDataObjsTimeStamps) {
if (sigTs.getTime().before(indivDObjTs.getTime()))
throw new TimeStampCoherenceException(SignatureTimeStampProperty.PROP_NAME, "time-stamp not posterior to data objects time-stamps");
}
for (AllDataObjsTimeStampProperty allDObjTs : allDataObjsTimeStamps) {
if (sigTs.getTime().before(allDObjTs.getTime()))
throw new TimeStampCoherenceException(SignatureTimeStampProperty.PROP_NAME, "time-stamp not posterior to data objects time-stamps");
}
}
}
Aggregations