Search in sources :

Example 1 with CompleteRevocationRefsProperty

use of xades4j.properties.CompleteRevocationRefsProperty 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 CompleteRevocationRefsProperty

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

the class CompleteRevocRefsVerifier method verify.

@Override
public QualifyingProperty verify(CompleteRevocationRefsData propData, QualifyingPropertyVerificationContext ctx) throws InvalidPropertyException {
    Collection<X509CRL> crls = ctx.getCertChainData().getCrls();
    Collection<CRLRef> crlRefs = new ArrayList<CRLRef>(propData.getCrlRefs());
    if (crls.isEmpty())
        throw new CompleteRevocRefsCRLsNotAvailableException();
    for (X509CRL crl : crls) {
        CRLRef match = null;
        for (CRLRef crlRef : crlRefs) {
            // Check issuer and issue time.
            if (!crl.getIssuerX500Principal().equals(new X500Principal(crlRef.issuerDN)) || !crl.getThisUpdate().equals(crlRef.issueTime.getTime()))
                continue;
            try {
                // Check CRL number, if present.
                if (crlRef.serialNumber != null) {
                    BigInteger crlNum = CrlExtensionsUtils.getCrlNumber(crl);
                    if (crlNum != null && !crlRef.serialNumber.equals(crlNum))
                        continue;
                }
                // Check digest value.
                MessageDigest md = this.digestEngineProvider.getEngine(crlRef.digestAlgUri);
                if (Arrays.equals(md.digest(crl.getEncoded()), crlRef.digestValue)) {
                    match = crlRef;
                    break;
                }
            } catch (IOException ex) {
                throw new CompleteRevocRefsReferenceException(crl, ex.getMessage());
            } catch (CRLException ex) {
                throw new CompleteRevocRefsReferenceException(crl, ex.getMessage());
            } catch (UnsupportedAlgorithmException ex) {
                throw new CompleteRevocRefsReferenceException(crl, ex.getMessage());
            }
        }
        if (null == match)
            throw new CompleteRevocRefsReferenceException(crl, "no matching reference");
        crlRefs.remove(match);
    }
    return new CompleteRevocationRefsProperty(crls);
}
Also used : X509CRL(java.security.cert.X509CRL) ArrayList(java.util.ArrayList) CRLRef(xades4j.properties.data.CRLRef) IOException(java.io.IOException) CompleteRevocationRefsProperty(xades4j.properties.CompleteRevocationRefsProperty) UnsupportedAlgorithmException(xades4j.UnsupportedAlgorithmException) X500Principal(javax.security.auth.x500.X500Principal) BigInteger(java.math.BigInteger) MessageDigest(java.security.MessageDigest) CRLException(java.security.cert.CRLException)

Example 3 with CompleteRevocationRefsProperty

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

the class PropertiesUtils method addXadesCProperties.

public static void addXadesCProperties(Collection<UnsignedSignatureProperty> usp, ValidationData vData) {
    // Remove the leaf certificate.
    List<X509Certificate> caCerts = vData.getCerts();
    caCerts = new ArrayList<X509Certificate>(caCerts.subList(1, caCerts.size()));
    usp.add(new CompleteCertificateRefsProperty(caCerts));
    usp.add(new CompleteRevocationRefsProperty(vData.getCrls()));
}
Also used : CompleteRevocationRefsProperty(xades4j.properties.CompleteRevocationRefsProperty) CompleteCertificateRefsProperty(xades4j.properties.CompleteCertificateRefsProperty) X509Certificate(java.security.cert.X509Certificate)

Aggregations

CompleteRevocationRefsProperty (xades4j.properties.CompleteRevocationRefsProperty)3 CompleteCertificateRefsProperty (xades4j.properties.CompleteCertificateRefsProperty)2 TypeLiteral (com.google.inject.TypeLiteral)1 IOException (java.io.IOException)1 BigInteger (java.math.BigInteger)1 MessageDigest (java.security.MessageDigest)1 CRLException (java.security.cert.CRLException)1 X509CRL (java.security.cert.X509CRL)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 X500Principal (javax.security.auth.x500.X500Principal)1 UnsupportedAlgorithmException (xades4j.UnsupportedAlgorithmException)1 AllDataObjsCommitmentTypeProperty (xades4j.properties.AllDataObjsCommitmentTypeProperty)1 AllDataObjsTimeStampProperty (xades4j.properties.AllDataObjsTimeStampProperty)1 ArchiveTimeStampProperty (xades4j.properties.ArchiveTimeStampProperty)1 CertificateValuesProperty (xades4j.properties.CertificateValuesProperty)1 CommitmentTypeProperty (xades4j.properties.CommitmentTypeProperty)1 CounterSignatureProperty (xades4j.properties.CounterSignatureProperty)1 DataObjectDesc (xades4j.properties.DataObjectDesc)1 DataObjectFormatProperty (xades4j.properties.DataObjectFormatProperty)1