Search in sources :

Example 1 with OcspResponsesID

use of org.bouncycastle.asn1.esf.OcspResponsesID in project signer by demoiselle.

the class RevocationRefs method makeOcspResponsesID.

/**
 * make OcspResponsesID from BasicOCSPResp
 *
 * @param ocspResp
 * @return OcspResponsesID
 * @throws NoSuchAlgorithmException
 * @throws OCSPException
 * @throws IOException
 */
@SuppressWarnings("unused")
private OcspResponsesID makeOcspResponsesID(BasicOCSPResp ocspResp) throws NoSuchAlgorithmException, OCSPException, IOException {
    Digest digest = DigestFactory.getInstance().factoryDefault();
    digest.setAlgorithm(DigestAlgorithmEnum.SHA_256);
    byte[] digestValue = digest.digest(ocspResp.getEncoded());
    OtherHash hash = new OtherHash(digestValue);
    OcspResponsesID ocsprespid = new OcspResponsesID(new OcspIdentifier(ocspResp.getResponderId().toASN1Object(), new DERGeneralizedTime(ocspResp.getProducedAt())), hash);
    return ocsprespid;
}
Also used : OcspResponsesID(org.bouncycastle.asn1.esf.OcspResponsesID) DERGeneralizedTime(org.bouncycastle.asn1.DERGeneralizedTime) Digest(org.demoiselle.signer.cryptography.Digest) OcspIdentifier(org.bouncycastle.asn1.esf.OcspIdentifier) OtherHash(org.bouncycastle.asn1.esf.OtherHash)

Aggregations

DERGeneralizedTime (org.bouncycastle.asn1.DERGeneralizedTime)1 OcspIdentifier (org.bouncycastle.asn1.esf.OcspIdentifier)1 OcspResponsesID (org.bouncycastle.asn1.esf.OcspResponsesID)1 OtherHash (org.bouncycastle.asn1.esf.OtherHash)1 Digest (org.demoiselle.signer.cryptography.Digest)1