private void validateBasicOcspResponse ( Date currentTime , BasicOCSPResp basicOcspResp ) throws CertificateEncodingException { for ( SingleResp singleResps : basicOcspResp . getResponses ( ) ) { Date thisUpdate = singleResps . getThisUpdate ( ) ; Date nextUpdate = singleResps . getNextUpdate ( ) ; LOGGER . debug ( "Current Time: {}, This Update: {}, Next Update: {}" , currentTime , thisUpdate , nextUpdate ) ; CertificateStatus certStatus = singleResps . getCertStatus ( ) ; if ( certStatus != CertificateStatus . GOOD ) { if ( certStatus instanceof RevokedStatus ) { RevokedStatus status = ( RevokedStatus ) certStatus ; int reason ; try { reason = status . getRevocationReason ( ) ; } catch ( IllegalStateException ex ) { reason = - 1 ; } Date revocationTime = status . getRevocationTime ( ) ; throw new CertificateEncodingException ( String . format ( "The certificate has been revoked. Reason: %d, Time: %s" , reason , DATE_FORMAT_UTC . format ( revocationTime ) ) ) ; } else { // Unknown status throw new CertificateEncodingException ( "Failed to validate the certificate for UNKNOWN reason." ) ; } } if ( ! isValidityRange ( currentTime , thisUpdate , nextUpdate ) ) { throw new CertificateEncodingException ( String . format ( "The validity is out of range: " + "Current Time: %s, This Update: %s, Next Update: %s" , DATE_FORMAT_UTC . format ( currentTime ) , DATE_FORMAT_UTC . format ( thisUpdate ) , DATE_FORMAT_UTC . format ( nextUpdate ) ) ) ; } } LOGGER . debug ( "OK. Verified the certificate revocation status." ) ; }
Validates OCSP Basic OCSP response .