Class InMemoryCryptoEngine
- java.lang.Object
-
- io.axoniq.dataprotection.cryptoengine.DatabaseBackedCryptoEngine
-
- io.axoniq.dataprotection.cryptoengine.InMemoryCryptoEngine
-
- All Implemented Interfaces:
CryptoEngine
public class InMemoryCryptoEngine extends DatabaseBackedCryptoEngine
Implementation ofCryptoEnginethat extends fromDatabaseBackedCryptoEngineand simply keeps all its data in an in-memoryConcurrentHashMap. This is useful for (unit) testing purposes.
-
-
Constructor Summary
Constructors Constructor Description InMemoryCryptoEngine()Constructs anInMemoryCryptoEngine.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteKey(String id)Deletes the key for a given id.SecretKeygetKey(String id)Retrieves the key for a given id.protected SecretKeyputKeyIfAbsent(String id, SecretKeySpec secretKeySpec)Stores the key for the given id, if no key is currently registered for this id.-
Methods inherited from class io.axoniq.dataprotection.cryptoengine.DatabaseBackedCryptoEngine
createCipher, createDigestCipher, getKeyType, getOrCreateKey, setKeyType
-
-
-
-
Constructor Detail
-
InMemoryCryptoEngine
public InMemoryCryptoEngine()
Constructs anInMemoryCryptoEngine. There are no parameters to configure.
-
-
Method Detail
-
getKey
public SecretKey getKey(String id)
Description copied from interface:CryptoEngineRetrieves the key for a given id.
-
putKeyIfAbsent
protected SecretKey putKeyIfAbsent(String id, SecretKeySpec secretKeySpec)
Description copied from class:DatabaseBackedCryptoEngineStores the key for the given id, if no key is currently registered for this id. Returns the new key belonging to id, which is either the key that was already registered or the key provided as the 2nd argument if no key was registered yet. (Please note that this is different behaviour fromConcurrentHashMap.putIfAbsent(Object, Object), which always returns the prior value belonging to key.)- Specified by:
putKeyIfAbsentin classDatabaseBackedCryptoEngine- Parameters:
id- the id for which to store/retrieve the secret keysecretKeySpec- theSecretKeySpecto store if none has been stored yet for id- Returns:
- the effective
SecretKeySpecfor id
-
deleteKey
public void deleteKey(String id)
Description copied from interface:CryptoEngineDeletes the key for a given id. Does nothing if the key doesn't exist.- Parameters:
id- the id of theSecretKey
-
-