Example usage for org.bouncycastle.asn1.esf CrlValidatedID CrlValidatedID

List of usage examples for org.bouncycastle.asn1.esf CrlValidatedID CrlValidatedID

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.esf CrlValidatedID CrlValidatedID.

Prototype

public CrlValidatedID(OtherHash crlHash, CrlIdentifier crlIdentifier) 

Source Link

Usage

From source file:eu.europa.ec.markt.dss.signature.cades.CAdESProfileC.java

License:Open Source License

/**
 * Create a reference to a X509CRL//  w ww . ja  v  a 2s .c o  m
 * 
 * @param crl
 * @return
 * @throws NoSuchAlgorithmException
 * @throws CRLException
 */
private CrlValidatedID makeCrlValidatedID(X509CRL crl) throws NoSuchAlgorithmException, CRLException {
    MessageDigest sha1digest = MessageDigest.getInstance(X509ObjectIdentifiers.id_SHA1.getId(),
            new BouncyCastleProvider());
    OtherHash hash = new OtherHash(sha1digest.digest(crl.getEncoded()));
    BigInteger crlnumber;
    CrlIdentifier crlid;
    if (crl.getExtensionValue("2.5.29.20") != null) {
        crlnumber = new DERInteger(crl.getExtensionValue("2.5.29.20")).getPositiveValue();
        crlid = new CrlIdentifier(new X500Name(crl.getIssuerX500Principal().getName()),
                new DERUTCTime(crl.getThisUpdate()), crlnumber);
    } else {
        crlid = new CrlIdentifier(new X500Name(crl.getIssuerX500Principal().getName()),
                new DERUTCTime(crl.getThisUpdate()));
    }

    CrlValidatedID crlvid = new CrlValidatedID(hash, crlid);

    return crlvid;
}

From source file:org.demoiselle.signer.policy.impl.cades.pkcs7.attribute.impl.RevocationRefs.java

License:Open Source License

/**
 * /*from   w  w  w  .j  a  va  2  s .co  m*/
 * 
 * @param extract
 *            CrlValidatedID from X509CRL
 * @return a CrlValidatedID
 * @throws NoSuchAlgorithmException
 * @throws CRLException
 */

private CrlValidatedID makeCrlValidatedID(X509CRL crl) throws NoSuchAlgorithmException, CRLException {

    Digest digest = DigestFactory.getInstance().factoryDefault();
    digest.setAlgorithm(DigestAlgorithmEnum.SHA_256);

    OtherHashAlgAndValue otherHashAlgAndValue = new OtherHashAlgAndValue(
            new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256),
            new DEROctetString(digest.digest(crl.getEncoded())));

    OtherHash hash = new OtherHash(otherHashAlgAndValue);

    BigInteger crlnumber;
    CrlIdentifier crlid;
    if (crl.getExtensionValue("2.5.29.20") != null) {
        ASN1Integer varASN1Integer = new ASN1Integer(crl.getExtensionValue("2.5.29.20"));
        crlnumber = varASN1Integer.getPositiveValue();

        crlid = new CrlIdentifier(new X500Name(crl.getIssuerX500Principal().getName()),
                new DERUTCTime(crl.getThisUpdate()), crlnumber);
    } else {
        crlid = new CrlIdentifier(new X500Name(crl.getIssuerX500Principal().getName()),
                new DERUTCTime(crl.getThisUpdate()));
    }

    CrlValidatedID crlvid = new CrlValidatedID(hash, crlid);

    return crlvid;
}