use of xades4j.properties.SignatureTimeStampProperty in project xades4j by luisgoncalves.
the class DefaultProductionBindingsModule method configure.
@Override
protected void configure() {
// Defaults for configurable components.
bind(SignaturePropertiesProvider.class).to(DefaultSignaturePropertiesProvider.class);
bind(DataObjectPropertiesProvider.class).toInstance(new DataObjectPropertiesProvider() {
@Override
public void provideProperties(DataObjectDesc dataObj) {
// By default no properties are specified for a data object.
}
});
bind(AlgorithmsProviderEx.class).to(DefaultAlgorithmsProviderEx.class);
// Will wrap the AlgorithmsProviderEx in use
bind(AlgorithmsProvider.class).to(AlgorithmsProvider_ExToDeprecated_Adapter.class);
bind(BasicSignatureOptionsProvider.class).to(DefaultBasicSignatureOptionsProvider.class);
bind(MessageDigestEngineProvider.class).to(DefaultMessageDigestProvider.class);
bind(TimeStampTokenProvider.class).to(HttpTimeStampTokenProvider.class);
// Backwards compatibility
bind(TSAHttpData.class).toInstance(new TSAHttpData("http://tss.accv.es:8318/tsa"));
// PropertiesDataObjectsGenerator is not configurable but the individual
// generators may have dependencies.
bind(PropertiesDataObjectsGenerator.class).to(PropertiesDataObjectsGeneratorImpl.class);
bind(PropertyDataGeneratorsMapper.class).to(PropertyDataGeneratorsMapperImpl.class);
// Ensure empty set when no bindings are defined
Multibinder.newSetBinder(binder(), CustomPropertiesDataObjsStructureVerifier.class);
// PropertyDataGeneratorsMapperImpl relies on the injector to get
// the individual generators, so they need to be bound.
// - SignedSignatureProperties
bind(new TypeLiteral<PropertyDataObjectGenerator<SigningTimeProperty>>() {
}).to(DataGenSigningTime.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SignerRoleProperty>>() {
}).to(DataGenSignerRole.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SigningCertificateProperty>>() {
}).to(DataGenSigningCertificate.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SignatureProductionPlaceProperty>>() {
}).to(DataGenSigProdPlace.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SignaturePolicyIdentifierProperty>>() {
}).to(DataGenSigPolicy.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SignaturePolicyImpliedProperty>>() {
}).to(DataGenSigPolicyImplied.class);
// - SignedDataObjectProperties
bind(new TypeLiteral<PropertyDataObjectGenerator<DataObjectFormatProperty>>() {
}).to(DataGenDataObjFormat.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<CommitmentTypeProperty>>() {
}).to(DataGenCommitmentType.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<AllDataObjsCommitmentTypeProperty>>() {
}).to(DataGenCommitmentTypeAllDataObjs.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<IndividualDataObjsTimeStampProperty>>() {
}).to(DataGenIndivDataObjsTimeStamp.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<AllDataObjsTimeStampProperty>>() {
}).to(DataGenAllDataObjsTimeStamp.class);
// - UnsignedSignatureProperties
bind(new TypeLiteral<PropertyDataObjectGenerator<CounterSignatureProperty>>() {
}).to(DataGenCounterSig.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SignatureTimeStampProperty>>() {
}).to(DataGenSigTimeStamp.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<CompleteCertificateRefsProperty>>() {
}).to(DataGenCompleteCertRefs.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<CompleteRevocationRefsProperty>>() {
}).to(DataGenCompleteRevocRefs.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SigAndRefsTimeStampProperty>>() {
}).to(DataGenSigAndRefsTimeStamp.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<CertificateValuesProperty>>() {
}).to(DataGenCertificateValues.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<RevocationValuesProperty>>() {
}).to(DataGenRevocationValues.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<ArchiveTimeStampProperty>>() {
}).to(DataGenArchiveTimeStamp.class);
}
use of xades4j.properties.SignatureTimeStampProperty in project xades4j by luisgoncalves.
the class SignatureTimeStampVerifier method addPropSpecificTimeStampInputAndCreateProperty.
@Override
protected QualifyingProperty addPropSpecificTimeStampInputAndCreateProperty(SignatureTimeStampData propData, TimeStampDigestInput digestInput, QualifyingPropertyVerificationContext ctx) throws CannotAddDataToDigestInputException {
Element sigValueElem = DOMHelper.getFirstDescendant(ctx.getSignature().getElement(), Constants.SignatureSpecNS, Constants._TAG_SIGNATUREVALUE);
digestInput.addNode(sigValueElem);
return new SignatureTimeStampProperty();
}
use of xades4j.properties.SignatureTimeStampProperty 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");
}
}
}
use of xades4j.properties.SignatureTimeStampProperty in project xades4j by luisgoncalves.
the class XadesSignatureFormatExtenderImplTest method testEnrichSignatureWithT.
@Test
public void testEnrichSignatureWithT() throws Exception {
System.out.println("enrichSignatureWithT");
Document doc = getDocument("document.signed.bes.xml");
Element signatureNode = (Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature").item(0);
XadesSignatureFormatExtenderImpl instance = (XadesSignatureFormatExtenderImpl) new XadesFormatExtenderProfile().getFormatExtender();
XMLSignature sig = new XMLSignature(signatureNode, "");
Collection<UnsignedSignatureProperty> usp = new ArrayList<UnsignedSignatureProperty>(1);
usp.add(new SignatureTimeStampProperty());
instance.enrichSignature(sig, new UnsignedProperties(usp));
outputDocument(doc, "document.signed.bes.enriched.t.xml");
}
use of xades4j.properties.SignatureTimeStampProperty in project xades4j by luisgoncalves.
the class XadesVerifierImpl method getValidationDate.
/**
**********************************************************************************
*/
private Date getValidationDate(Collection<PropertyDataObject> qualifPropsData, XMLSignature signature, SignatureSpecificVerificationOptions verificationOptions) throws XAdES4jException {
List sigTsData = CollectionUtils.filterByType(qualifPropsData, SignatureTimeStampData.class);
// If no signature time-stamp is present, use the current date.
if (sigTsData.isEmpty()) {
return verificationOptions.getDefaultVerificationDate();
}
// TODO support multiple SignatureTimeStamps (section 7.3 last paragraph of Standard v.1.4.2)
// This is a temporary solution.
// - Properties should probably be verified in two stages (before and after cert path creation).
// - Had to remove the custom structure verifier that checked if the SigningCertificate data was present.
QualifyingPropertyVerificationContext ctx = new QualifyingPropertyVerificationContext(signature, new QualifyingPropertyVerificationContext.CertificationChainData(new ArrayList<X509Certificate>(0), new ArrayList<X509CRL>(0), null), /**/
new QualifyingPropertyVerificationContext.SignedObjectsData(new ArrayList<RawDataObjectDesc>(0), signature));
Collection<PropertyInfo> props = this.qualifyingPropertiesVerifier.verifyProperties(sigTsData, ctx);
QualifyingProperty sigTs = props.iterator().next().getProperty();
return ((SignatureTimeStampProperty) sigTs).getTime();
}
Aggregations