Class OpenSslCachingKeyMaterialProvider


  • final class OpenSslCachingKeyMaterialProvider
    extends OpenSslKeyMaterialProvider
    OpenSslKeyMaterialProvider that will cache the OpenSslKeyMaterial to reduce the overhead of parsing the chain and the key for generation of the material.

    Cache reads are lock-free (ConcurrentHashMap.get(java.lang.Object) + retain()); if a concurrent eviction releases the material in between, retain() detects the dead reference count and the read falls back to a cache miss. Mutations (insert, evict, destroy) use ConcurrentHashMap.compute(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>) / ConcurrentHashMap.computeIfPresent(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>) for atomicity.

    • Field Detail

      • maxCachedEntries

        private final int maxCachedEntries
      • cache

        private final java.util.concurrent.ConcurrentHashMap<java.lang.String,​OpenSslKeyMaterial> cache
      • destroyed

        private volatile boolean destroyed
    • Constructor Detail

      • OpenSslCachingKeyMaterialProvider

        OpenSslCachingKeyMaterialProvider​(javax.net.ssl.X509KeyManager keyManager,
                                          java.lang.String password,
                                          int maxEntries)
    • Method Detail

      • getAndRetain

        private OpenSslKeyMaterial getAndRetain​(java.lang.String alias)
        Lock-free cache lookup. If a concurrent eviction releases the material between get and retain, the dead reference count is detected and treated as a cache miss.
      • putIfAbsentAndRetain

        private OpenSslKeyMaterial putIfAbsentAndRetain​(java.lang.String alias,
                                                        OpenSslKeyMaterial material)
        Atomically inserts material if absent, or retains the existing entry.
      • removeAndRelease

        private void removeAndRelease​(java.lang.String alias)
        Atomically removes and releases the entry for the given alias.
      • evictStaleEntries

        private void evictStaleEntries()
      • cacheSize

        int cacheSize()
      • removeAndReleaseAllEntries

        private void removeAndReleaseAllEntries()