private static SFPair < OcspResponseCacheKey , SFPair < Long , String > > decodeCacheFromJSON ( Map . Entry < String , JsonNode > elem ) throws IOException { long currentTimeSecond = new Date ( ) . getTime ( ) / 1000 ; byte [ ] certIdDer = Base64 . decodeBase64 ( elem . getKey ( ) ) ; DLSequence rawCertId = ( DLSequence ) ASN1ObjectIdentifier . fromByteArray ( certIdDer ) ; ASN1Encodable [ ] rawCertIdArray = rawCertId . toArray ( ) ; byte [ ] issuerNameHashDer = ( ( DEROctetString ) rawCertIdArray [ 1 ] ) . getEncoded ( ) ; byte [ ] issuerKeyHashDer = ( ( DEROctetString ) rawCertIdArray [ 2 ] ) . getEncoded ( ) ; BigInteger serialNumber = ( ( ASN1Integer ) rawCertIdArray [ 3 ] ) . getValue ( ) ; OcspResponseCacheKey k = new OcspResponseCacheKey ( issuerNameHashDer , issuerKeyHashDer , serialNumber ) ; JsonNode ocspRespBase64 = elem . getValue ( ) ; if ( ! ocspRespBase64 . isArray ( ) || ocspRespBase64 . size ( ) != 2 ) { LOGGER . debug ( "Invalid cache file format." ) ; return null ; } long producedAt = ocspRespBase64 . get ( 0 ) . asLong ( ) ; String ocspResp = ocspRespBase64 . get ( 1 ) . asText ( ) ; if ( currentTimeSecond - CACHE_EXPIRATION_IN_SECONDS <= producedAt ) { // add cache return SFPair . of ( k , SFPair . of ( producedAt , ocspResp ) ) ; } else { // delete cache return SFPair . of ( k , SFPair . of ( producedAt , ( String ) null ) ) ; } }
Decodes OCSP Response Cache key from JSON