Example #1
0
 private void storeCertificateInCache(X509Certificate certificate, String key, boolean validated) {
   // Store in the cache
   if (certificate != null && xkmsClientCache != null) {
     XKMSCacheToken cacheToken = new XKMSCacheToken(certificate);
     cacheToken.setXkmsValidated(validated);
     // Store using a custom key (if any)
     if (key != null) {
       xkmsClientCache.put(key, cacheToken);
     }
     // Store it using IssuerSerial as well
     String issuerSerialKey =
         getKeyForIssuerSerial(
             certificate.getIssuerX500Principal().getName(), certificate.getSerialNumber());
     if (!issuerSerialKey.equals(key)) {
       xkmsClientCache.put(issuerSerialKey, cacheToken);
     }
     // Store it using the Subject DN as well
     String subjectDNKey = certificate.getSubjectX500Principal().getName();
     if (!subjectDNKey.equals(key)) {
       xkmsClientCache.put(subjectDNKey, cacheToken);
     }
   }
 }