public class PerThreadCipherProvider extends Object implements CipherProvider
CipherProvider that caches ciphers in per-thread storage. To avoid using an actual thread-local
(and polluting any thread pools that may touch this), we instead maintain our own map from thread id to cipher
instances. As this is just a normal (concurrent) map, then it can be garbage collected as normal so there is no
memory leak on hot-redeploy.| Constructor and Description |
|---|
PerThreadCipherProvider(CipherProvider delegate)
Constructs a new PerThreadCipherProvider instance.
|
PerThreadCipherProvider(CipherProvider delegate,
int maxSize)
Initialises the thread-local cipher cache, delegating to the supplied cipher provider for actual ciphers.
|
| Modifier and Type | Method and Description |
|---|---|
Cipher |
getCipher()
Gets a cipher from the thread-local storage, initialising to the delegate cipher provider if not already
initialised for this thread.
|
public PerThreadCipherProvider(CipherProvider delegate, int maxSize)
delegate - the non-null provider to get ciphers from.maxSize - the maximum size of the thread-local cache.NullPointerException - if the delegate is nullIllegalArgumentException - if maxSize is not a positive integer (> 0).public PerThreadCipherProvider(CipherProvider delegate)
delegate - The CipherProvider delegate.public Cipher getCipher()
Cipher.init(int, java.security.Key, java.security.AlgorithmParameters)
before making use of the cipher to ensure it is properly initialised.getCipher in interface CipherProviderCopyright © 2010–2023 Open Identity Platform Community. All rights reserved.