Package org.apache.hadoop.crypto.key
Class KeyProviderExtension<E extends KeyProviderExtension.Extension>
java.lang.Object
org.apache.hadoop.crypto.key.KeyProvider
org.apache.hadoop.crypto.key.KeyProviderExtension<E>
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
CachingKeyProvider,KeyProviderCryptoExtension,KeyProviderDelegationTokenExtension
public abstract class KeyProviderExtension<E extends KeyProviderExtension.Extension>
extends KeyProvider
This is a utility class used to extend the functionality of KeyProvider, that
takes a KeyProvider and an Extension. It implements all the required methods
of the KeyProvider by delegating it to the provided KeyProvider.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA marker interface for the KeyProviderExtension subclass implement.Nested 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateKey(String name, byte[] material, KeyProvider.Options options) Create a new key.createKey(String name, KeyProvider.Options options) Create a new key generating the material for it.voidDelete the given key.voidflush()Ensures that any changes to the keys are written to persistent store.getCurrentKey(String name) Get the current version of the key, which should be used for encrypting new data.protected Eprotected KeyProvidergetKeys()Get the key names for all keys.getKeysMetadata(String... names) Get key metadata in bulk.getKeyVersion(String versionName) Get the key material for a specific version of the key.getKeyVersions(String name) Get the key material for all versions of a specific key name.getMetadata(String name) Get metadata about the key.voidinvalidateCache(String name) Can be used by implementing classes to invalidate the caches.booleanIndicates whether this provider represents a store that is intended for transient use - such as the UserProvider is.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.toString()Methods inherited from class org.apache.hadoop.crypto.key.KeyProvider
buildVersionName, close, findProvider, generateKey, getBaseName, getConf, needsPassword, noPasswordError, noPasswordWarning, options
-
Constructor Details
-
KeyProviderExtension
-
-
Method Details
-
getExtension
-
getKeyProvider
-
isTransient
public boolean isTransient()Description copied from class:KeyProviderIndicates whether this provider represents a store that is intended for transient use - such as the UserProvider is. These providers are generally used to provide access to keying material rather than for long term storage.- Overrides:
isTransientin classKeyProvider- Returns:
- true if transient, false otherwise
-
getKeysMetadata
Description copied from class:KeyProviderGet key metadata in bulk.- Overrides:
getKeysMetadatain classKeyProvider- Parameters:
names- the names of the keys to get- Returns:
- Metadata Array.
- Throws:
IOException- raised on errors performing I/O.
-
getCurrentKey
Description copied from class:KeyProviderGet the current version of the key, which should be used for encrypting new data.- Overrides:
getCurrentKeyin classKeyProvider- 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.
-
createKey
public KeyProvider.KeyVersion createKey(String name, KeyProvider.Options options) throws NoSuchAlgorithmException, IOException Description copied from class:KeyProviderCreate a new key generating the material for it. The given key must not already exist.This implementation generates the key material and calls the
KeyProvider.createKey(String, byte[], Options)method.- Overrides:
createKeyin classKeyProvider- Parameters:
name- the base name of the keyoptions- the options for the new key.- Returns:
- the version name of the first version of the key.
- Throws:
NoSuchAlgorithmException- no such algorithm exception.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 classKeyProvider- 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.
-
getKeyVersion
Description copied from class:KeyProviderGet the key material for a specific version of the key. This method is used when decrypting data.- Specified by:
getKeyVersionin classKeyProvider- Parameters:
versionName- the name of a specific version of the key- Returns:
- the key material
- Throws:
IOException- raised on errors performing I/O.
-
getKeys
Description copied from class:KeyProviderGet the key names for all keys.- Specified by:
getKeysin classKeyProvider- Returns:
- the list of key names
- Throws:
IOException- raised on errors performing I/O.
-
getKeyVersions
Description copied from class:KeyProviderGet the key material for all versions of a specific key name.- Specified by:
getKeyVersionsin classKeyProvider- Parameters:
name- the base name of the key.- Returns:
- the list of key material
- Throws:
IOException- raised on errors performing I/O.
-
getMetadata
Description copied from class:KeyProviderGet metadata about the key.- Specified by:
getMetadatain classKeyProvider- 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.
-
createKey
public KeyProvider.KeyVersion createKey(String name, byte[] material, KeyProvider.Options options) throws IOException Description copied from class:KeyProviderCreate a new key. The given key must not already exist.- Specified by:
createKeyin classKeyProvider- Parameters:
name- the base name of the keymaterial- the key material for the first version of the key.options- the options for the new key.- Returns:
- the version name of the first version of the key.
- Throws:
IOException- raised on errors performing I/O.
-
deleteKey
Description copied from class:KeyProviderDelete the given key.- Specified by:
deleteKeyin classKeyProvider- 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.- Specified by:
rollNewVersionin classKeyProvider- 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.
-
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 classKeyProvider- Parameters:
name- the basename of the key- Throws:
IOException- raised on errors performing I/O.
-
flush
Description copied from class:KeyProviderEnsures that any changes to the keys are written to persistent store.- Specified by:
flushin classKeyProvider- Throws:
IOException- raised on errors performing I/O.
-
toString
-