Search in sources :

Example 1 with IndividualDataObjsTimeStampProperty

use of xades4j.properties.IndividualDataObjsTimeStampProperty 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);
}
Also used : DefaultAlgorithmsProviderEx(xades4j.providers.impl.DefaultAlgorithmsProviderEx) AlgorithmsProviderEx(xades4j.providers.AlgorithmsProviderEx) SignaturePolicyIdentifierProperty(xades4j.properties.SignaturePolicyIdentifierProperty) SigAndRefsTimeStampProperty(xades4j.properties.SigAndRefsTimeStampProperty) TSAHttpData(xades4j.providers.impl.TSAHttpData) SigningCertificateProperty(xades4j.properties.SigningCertificateProperty) CompleteCertificateRefsProperty(xades4j.properties.CompleteCertificateRefsProperty) DefaultSignaturePropertiesProvider(xades4j.providers.impl.DefaultSignaturePropertiesProvider) SignaturePropertiesProvider(xades4j.providers.SignaturePropertiesProvider) DataObjectDesc(xades4j.properties.DataObjectDesc) RevocationValuesProperty(xades4j.properties.RevocationValuesProperty) SignatureProductionPlaceProperty(xades4j.properties.SignatureProductionPlaceProperty) TypeLiteral(com.google.inject.TypeLiteral) CertificateValuesProperty(xades4j.properties.CertificateValuesProperty) MessageDigestEngineProvider(xades4j.providers.MessageDigestEngineProvider) AllDataObjsCommitmentTypeProperty(xades4j.properties.AllDataObjsCommitmentTypeProperty) CommitmentTypeProperty(xades4j.properties.CommitmentTypeProperty) DataObjectPropertiesProvider(xades4j.providers.DataObjectPropertiesProvider) SignatureTimeStampProperty(xades4j.properties.SignatureTimeStampProperty) AlgorithmsProvider(xades4j.providers.AlgorithmsProvider) AllDataObjsTimeStampProperty(xades4j.properties.AllDataObjsTimeStampProperty) ArchiveTimeStampProperty(xades4j.properties.ArchiveTimeStampProperty) SigningTimeProperty(xades4j.properties.SigningTimeProperty) SignerRoleProperty(xades4j.properties.SignerRoleProperty) SignaturePolicyImpliedProperty(xades4j.properties.SignaturePolicyImpliedProperty) DataObjectFormatProperty(xades4j.properties.DataObjectFormatProperty) TimeStampTokenProvider(xades4j.providers.TimeStampTokenProvider) HttpTimeStampTokenProvider(xades4j.providers.impl.HttpTimeStampTokenProvider) AllDataObjsCommitmentTypeProperty(xades4j.properties.AllDataObjsCommitmentTypeProperty) CompleteRevocationRefsProperty(xades4j.properties.CompleteRevocationRefsProperty) CounterSignatureProperty(xades4j.properties.CounterSignatureProperty) DefaultBasicSignatureOptionsProvider(xades4j.providers.impl.DefaultBasicSignatureOptionsProvider) BasicSignatureOptionsProvider(xades4j.providers.BasicSignatureOptionsProvider) IndividualDataObjsTimeStampProperty(xades4j.properties.IndividualDataObjsTimeStampProperty)

Example 2 with IndividualDataObjsTimeStampProperty

use of xades4j.properties.IndividualDataObjsTimeStampProperty 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 3 with IndividualDataObjsTimeStampProperty

use of xades4j.properties.IndividualDataObjsTimeStampProperty 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");
        }
    }
}
Also used : SignatureTimeStampProperty(xades4j.properties.SignatureTimeStampProperty) AllDataObjsTimeStampProperty(xades4j.properties.AllDataObjsTimeStampProperty) QualifyingProperty(xades4j.properties.QualifyingProperty) IndividualDataObjsTimeStampProperty(xades4j.properties.IndividualDataObjsTimeStampProperty)

Example 4 with IndividualDataObjsTimeStampProperty

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

the class SignerBESTest method testSignBESExtrnlRes.

@Test
public void testSignBESExtrnlRes() throws Exception {
    System.out.println("signBESExtrnlRes");
    Document doc = getNewDocument();
    SignerBES signer = (SignerBES) new XadesBesSigningProfile(keyingProviderNist).newSigner();
    DataObjectDesc obj1 = new DataObjectReference("rfc3161.txt").withDataObjectFormat(new DataObjectFormatProperty("text/plain").withDescription("Internet X.509 Public Key Infrastructure Time-Stamp Protocol (TSP)")).withDataObjectTimeStamp(new IndividualDataObjsTimeStampProperty());
    signer.sign(new SignedDataObjects(obj1).withBaseUri("http://www.ietf.org/rfc/"), doc);
    outputDocument(doc, "document.signed.bes.extres.xml");
}
Also used : DataObjectFormatProperty(xades4j.properties.DataObjectFormatProperty) Document(org.w3c.dom.Document) DataObjectDesc(xades4j.properties.DataObjectDesc) IndividualDataObjsTimeStampProperty(xades4j.properties.IndividualDataObjsTimeStampProperty) Test(org.junit.Test)

Example 5 with IndividualDataObjsTimeStampProperty

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

the class SignerBESTest method testSignBES.

@Test
public void testSignBES() throws Exception {
    System.out.println("signBES");
    Document doc1 = getTestDocument();
    Document doc2 = getDocument("content.xml");
    Node objectContent = doc1.importNode(doc2.getDocumentElement(), true);
    Element elemToSign = doc1.getDocumentElement();
    SignerBES signer = (SignerBES) new XadesBesSigningProfile(keyingProviderMy).newSigner();
    IndividualDataObjsTimeStampProperty dataObjsTimeStamp = new IndividualDataObjsTimeStampProperty();
    AllDataObjsCommitmentTypeProperty globalCommitment = AllDataObjsCommitmentTypeProperty.proofOfApproval();
    CommitmentTypeProperty commitment = (CommitmentTypeProperty) CommitmentTypeProperty.proofOfCreation().withQualifier("MyQualifier");
    DataObjectDesc obj1 = new DataObjectReference('#' + elemToSign.getAttribute("Id")).withTransform(new EnvelopedSignatureTransform()).withDataObjectFormat(new DataObjectFormatProperty("text/xml", "MyEncoding").withDescription("Isto é uma descrição do elemento raiz").withDocumentationUri("http://doc1.txt").withDocumentationUri("http://doc2.txt").withIdentifier("http://elem.root")).withCommitmentType(commitment).withDataObjectTimeStamp(dataObjsTimeStamp);
    DataObjectDesc obj2 = new EnvelopedXmlObject(objectContent, "text/xml", null).withDataObjectFormat(new DataObjectFormatProperty("text/xml", "MyEncoding").withDescription("Isto é uma descrição do elemento dentro do object").withDocumentationUri("http://doc3.txt").withDocumentationUri("http://doc4.txt").withIdentifier("http://elem.in.object")).withCommitmentType(commitment).withDataObjectTimeStamp(dataObjsTimeStamp);
    SignedDataObjects dataObjs = new SignedDataObjects(obj1, obj2).withCommitmentType(globalCommitment).withDataObjectsTimeStamp();
    signer.sign(dataObjs, elemToSign);
    outputDocument(doc1, "document.signed.bes.xml");
}
Also used : Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) DataObjectFormatProperty(xades4j.properties.DataObjectFormatProperty) EnvelopedSignatureTransform(xades4j.algorithms.EnvelopedSignatureTransform) Document(org.w3c.dom.Document) DataObjectDesc(xades4j.properties.DataObjectDesc) AllDataObjsCommitmentTypeProperty(xades4j.properties.AllDataObjsCommitmentTypeProperty) AllDataObjsCommitmentTypeProperty(xades4j.properties.AllDataObjsCommitmentTypeProperty) CommitmentTypeProperty(xades4j.properties.CommitmentTypeProperty) IndividualDataObjsTimeStampProperty(xades4j.properties.IndividualDataObjsTimeStampProperty) Test(org.junit.Test)

Aggregations

IndividualDataObjsTimeStampProperty (xades4j.properties.IndividualDataObjsTimeStampProperty)5 DataObjectDesc (xades4j.properties.DataObjectDesc)3 DataObjectFormatProperty (xades4j.properties.DataObjectFormatProperty)3 Test (org.junit.Test)2 Document (org.w3c.dom.Document)2 AllDataObjsCommitmentTypeProperty (xades4j.properties.AllDataObjsCommitmentTypeProperty)2 AllDataObjsTimeStampProperty (xades4j.properties.AllDataObjsTimeStampProperty)2 CommitmentTypeProperty (xades4j.properties.CommitmentTypeProperty)2 SignatureTimeStampProperty (xades4j.properties.SignatureTimeStampProperty)2 TypeLiteral (com.google.inject.TypeLiteral)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1 EnvelopedSignatureTransform (xades4j.algorithms.EnvelopedSignatureTransform)1 ArchiveTimeStampProperty (xades4j.properties.ArchiveTimeStampProperty)1 CertificateValuesProperty (xades4j.properties.CertificateValuesProperty)1 CompleteCertificateRefsProperty (xades4j.properties.CompleteCertificateRefsProperty)1 CompleteRevocationRefsProperty (xades4j.properties.CompleteRevocationRefsProperty)1 CounterSignatureProperty (xades4j.properties.CounterSignatureProperty)1 QualifyingProperty (xades4j.properties.QualifyingProperty)1 RevocationValuesProperty (xades4j.properties.RevocationValuesProperty)1