Package org.apache.synapse.transport.certificatevalidation.ocsp

## Class OCSPCache

- java.lang.Object
- - org.apache.synapse.transport.certificatevalidation.ocsp.OCSPCache

- All Implemented Interfaces:
    `ManageableCache`

      public class OCSPCache
      extends Object
      implements ManageableCache

  This is a cache to store OSCP responses against Certificate Serial Number since an OCSP response depends on the certificate. This is a singleton since more than one cache of this kind should not be allowed. This cache can be shared by many transports which need SSL validation through OCSP.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static OCSPCache` | `getCache​(int cacheSize, int cacheDelayMins)` |
    `int` | `getCacheSize()` |
    `org.bouncycastle.cert.ocsp.SingleResp` | `getCacheValue​(BigInteger serialNumber)` |
    `ManageableCacheValue` | `getNextCacheValue()` | This method is needed by the cache Manager to go through the cache entries to remove invalid values or to remove LRU cache values if the cache has reached its max size.
    `void` | `init​(int size, int delay)` | This lazy initializes the Cache with a CacheManager.
    `void` | `removeCacheValue​(BigInteger serialNumber)` |
    `void` | `resetIterator()` |
    `void` | `setCacheValue​(BigInteger serialNumber, org.bouncycastle.cert.ocsp.SingleResp singleResp, org.bouncycastle.cert.ocsp.OCSPReq request, String serviceUrl)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getCache

          public static OCSPCache getCache​(int cacheSize,
                                           int cacheDelayMins)

    - #### init

          public void init​(int size,
                           int delay)

      This lazy initializes the Cache with a CacheManager. If this method is not called, a cache manager will not be used.
      Parameters:
        `size` - max size of the cache
        `delay` - defines how frequently the CacheManager will be started

    - #### getNextCacheValue

          public ManageableCacheValue getNextCacheValue()

      This method is needed by the cache Manager to go through the cache entries to remove invalid values or to remove LRU cache values if the cache has reached its max size. Todo: Can move to an abstract class.
      Specified by:
        `getNextCacheValue` in interface `ManageableCache`
      Returns:
        next cache value of the cache.

    - #### getCacheSize

          public int getCacheSize()

      Specified by:
        `getCacheSize` in interface `ManageableCache`
      Returns:
        the current cache size (size of the hash map)

    - #### resetIterator

          public void resetIterator()

      Specified by:
        `resetIterator` in interface `ManageableCache`

    - #### getCacheValue

          public org.bouncycastle.cert.ocsp.SingleResp getCacheValue​(BigInteger serialNumber)

    - #### setCacheValue

          public void setCacheValue​(BigInteger serialNumber,
                                    org.bouncycastle.cert.ocsp.SingleResp singleResp,
                                    org.bouncycastle.cert.ocsp.OCSPReq request,
                                    String serviceUrl)

    - #### removeCacheValue

          public void removeCacheValue​(BigInteger serialNumber)