Package org.apache.hadoop.crypto.key
Class CachingKeyProvider
java.lang.Object
org.apache.hadoop.crypto.key.KeyProvider
org.apache.hadoop.crypto.key.KeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>
org.apache.hadoop.crypto.key.CachingKeyProvider
- All Implemented Interfaces:
Closeable,AutoCloseable
public class CachingKeyProvider
extends KeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>
A
KeyProviderExtension implementation providing a short lived
cache for KeyVersions and Metadatato avoid burst
of requests to hit the underlying KeyProvider.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.crypto.key.KeyProviderExtension
KeyProviderExtension.ExtensionNested classes/interfaces inherited from class org.apache.hadoop.crypto.key.KeyProvider
KeyProvider.KeyVersion, KeyProvider.Metadata, KeyProvider.Options -
Field Summary
Fields inherited from class org.apache.hadoop.crypto.key.KeyProvider
DEFAULT_BITLENGTH, DEFAULT_BITLENGTH_NAME, DEFAULT_CIPHER, DEFAULT_CIPHER_NAME, JCEKS_KEY_SERIAL_FILTER, JCEKS_KEY_SERIALFILTER_DEFAULT -
Constructor Summary
ConstructorsConstructorDescriptionCachingKeyProvider(KeyProvider keyProvider, long keyTimeoutMillis, long currKeyTimeoutMillis) -
Method Summary
Modifier and TypeMethodDescriptionvoidDelete the given key.getCurrentKey(String name) Get the current version of the key, which should be used for encrypting new data.getKeyVersion(String versionName) Get the key material for a specific version of the key.getMetadata(String name) Get metadata about the key.voidinvalidateCache(String name) Can be used by implementing classes to invalidate the caches.rollNewVersion(String name) Roll a new version of the given key generating the material for it.rollNewVersion(String name, byte[] material) Roll a new version of the given key.Methods inherited from class org.apache.hadoop.crypto.key.KeyProviderExtension
createKey, createKey, flush, getExtension, getKeyProvider, getKeys, getKeysMetadata, getKeyVersions, isTransient, toStringMethods inherited from class org.apache.hadoop.crypto.key.KeyProvider
buildVersionName, close, findProvider, generateKey, getBaseName, getConf, needsPassword, noPasswordError, noPasswordWarning, options
-
Constructor Details
-
CachingKeyProvider
public CachingKeyProvider(KeyProvider keyProvider, long keyTimeoutMillis, long currKeyTimeoutMillis)
-
-
Method Details
-
getCurrentKey
Description copied from class:KeyProviderGet the current version of the key, which should be used for encrypting new data.- Overrides:
getCurrentKeyin classKeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>- Parameters:
name- the base name of the key- Returns:
- the version name of the current version of the key or null if the key version doesn't exist
- Throws:
IOException- raised on errors performing I/O.
-
getKeyVersion
Description copied from class:KeyProviderGet the key material for a specific version of the key. This method is used when decrypting data.- Overrides:
getKeyVersionin classKeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>- Parameters:
versionName- the name of a specific version of the key- Returns:
- the key material
- Throws:
IOException- raised on errors performing I/O.
-
deleteKey
Description copied from class:KeyProviderDelete the given key.- Overrides:
deleteKeyin classKeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>- Parameters:
name- the name of the key to delete- Throws:
IOException- raised on errors performing I/O.
-
rollNewVersion
Description copied from class:KeyProviderRoll a new version of the given key.- Overrides:
rollNewVersionin classKeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>- Parameters:
name- the basename of the keymaterial- the new key material- Returns:
- the name of the new version of the key
- Throws:
IOException- raised on errors performing I/O.
-
rollNewVersion
public KeyProvider.KeyVersion rollNewVersion(String name) throws NoSuchAlgorithmException, IOException Description copied from class:KeyProviderRoll a new version of the given key generating the material for it.This implementation generates the key material and calls the
KeyProvider.rollNewVersion(String, byte[])method.- Overrides:
rollNewVersionin classKeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>- Parameters:
name- the basename of the key- Returns:
- the name of the new version of the key
- Throws:
NoSuchAlgorithmException- This exception is thrown when a particular cryptographic algorithm is requested but is not available in the environment.IOException- raised on errors performing I/O.
-
invalidateCache
Description copied from class:KeyProviderCan be used by implementing classes to invalidate the caches. This could be used after rollNewVersion to provide a strong guarantee to return the new version of the given key.- Overrides:
invalidateCachein classKeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>- Parameters:
name- the basename of the key- Throws:
IOException- raised on errors performing I/O.
-
getMetadata
Description copied from class:KeyProviderGet metadata about the key.- Overrides:
getMetadatain classKeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>- Parameters:
name- the basename of the key- Returns:
- the key's metadata or null if the key doesn't exist
- Throws:
IOException- raised on errors performing I/O.
-