Class SigningKeyCache
- java.lang.Object
-
- com.axis.jenkins.plugins.eiffel.eiffelbroadcaster.signing.SigningKeyCache
-
public class SigningKeyCache extends Object
A singleton that implements a simple time-based in-memory pull-through cache of event signing keys to avoid decoding keystores and keys every time an event is sent.Even though an item in the cache is only deemed valid for a limited time (see
TTL
), items are currently never evicted from the cache so the cache will grow over time if a large number of credential objects are created and referenced by code that signs events.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SigningKeyCache.Item
An immutable cache item, containing a signing key, the associated identity, and the time when the data was extracted from theKeyStore
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the cache of all entries.SigningKeyCache.Item
get(com.cloudbees.plugins.credentials.common.CertificateCredentials cred)
Looks up a credential and returns the identity (subject) of the certificate and the private key.static SigningKeyCache
getInstance()
Returns the singleton object of this class.int
size()
Returns the current number of (possibly expired) items in the cache.
-
-
-
Method Detail
-
clear
public void clear()
Clears the cache of all entries.
-
get
@NonNull public SigningKeyCache.Item get(@NonNull com.cloudbees.plugins.credentials.common.CertificateCredentials cred) throws InvalidCertificateConfigurationException, KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException
Looks up a credential and returns the identity (subject) of the certificate and the private key.- Parameters:
cred
- the credentials from which to extract the key and identity- Returns:
- an
SigningKeyCache.Item
with the private key and identity - Throws:
InvalidCertificateConfigurationException
- if no credential with the given id was found, if the credential had the wrong type, or if theKeyStore
was entirely empty or its first item didn't contain a certificate with a private keyKeyStoreException
- if theKeyStore
hasn't been initializedNoSuchAlgorithmException
- if the algorithm needed to decrypt the key isn't availableUnrecoverableKeyException
- if the key couldn't be decrypted, e.g. because the password is wrong
-
size
public int size()
Returns the current number of (possibly expired) items in the cache.
-
getInstance
public static SigningKeyCache getInstance()
Returns the singleton object of this class.
-
-