Class OcspHelper


  • public class OcspHelper
    extends java.lang.Object
    Helper Class for OCSP-Operations with bouncy castle.
    Author:
    Alexis Suter
    • Constructor Summary

      Constructors 
      Constructor Description
      OcspHelper​(java.security.cert.X509Certificate checkCertificate, java.util.Date signDate, java.security.cert.X509Certificate issuerCertificate, java.util.Set<java.security.cert.X509Certificate> additionalCerts, java.lang.String ocspUrl)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.security.cert.X509Certificate getOcspResponderCertificate()
      Get responder certificate.
      org.bouncycastle.cert.ocsp.OCSPResp getResponseOcsp()
      Performs and verifies the OCSP-Request
      void verifyRespStatus​(org.bouncycastle.cert.ocsp.OCSPResp resp)
      Helper method to verify response status.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OcspHelper

        public OcspHelper​(java.security.cert.X509Certificate checkCertificate,
                          java.util.Date signDate,
                          java.security.cert.X509Certificate issuerCertificate,
                          java.util.Set<java.security.cert.X509Certificate> additionalCerts,
                          java.lang.String ocspUrl)
        Parameters:
        checkCertificate - Certificate to be OCSP-checked
        signDate - the date when the signing took place
        issuerCertificate - Certificate of the issuer
        additionalCerts - Set of trusted root CA certificates that will be used as "trust anchors" and intermediate CA certificates that will be used as part of the certification chain. All self-signed certificates are considered to be trusted root CA certificates. All the rest are considered to be intermediate CA certificates.
        ocspUrl - where to fetch for OCSP
    • Method Detail

      • getResponseOcsp

        public org.bouncycastle.cert.ocsp.OCSPResp getResponseOcsp()
                                                            throws java.io.IOException,
                                                                   org.bouncycastle.cert.ocsp.OCSPException,
                                                                   RevokedCertificateException,
                                                                   java.net.URISyntaxException
        Performs and verifies the OCSP-Request
        Returns:
        the OCSPResp, when the request was successful, else a corresponding exception will be thrown. Never returns null.
        Throws:
        java.io.IOException
        org.bouncycastle.cert.ocsp.OCSPException
        RevokedCertificateException
        java.net.URISyntaxException
      • getOcspResponderCertificate

        public java.security.cert.X509Certificate getOcspResponderCertificate()
        Get responder certificate. This is available after getResponseOcsp() has been called. This method should be used instead of basicResponse.getCerts()[0]
        Returns:
        The certificate of the responder.
      • verifyRespStatus

        public void verifyRespStatus​(org.bouncycastle.cert.ocsp.OCSPResp resp)
                              throws org.bouncycastle.cert.ocsp.OCSPException
        Helper method to verify response status.
        Parameters:
        resp - OCSP response
        Throws:
        org.bouncycastle.cert.ocsp.OCSPException - if the response status is not ok