Class JavaKeyStoreProvider
- All Implemented Interfaces:
Closeable,AutoCloseable
If the HADOOP_KEYSTORE_PASSWORD environment variable is set,
its value is used as the password for the keystore.
If the HADOOP_KEYSTORE_PASSWORD environment variable is not set,
the password for the keystore is read from file specified in the
KEYSTORE_PASSWORD_FILE_KEY configuration property. The password file
is looked up in Hadoop's configuration directory via the classpath.
NOTE: Make sure the password in the password file does not have an ENTER at the end, else it won't be valid for the Java KeyStore.
If the environment variable, nor the property are not set, the password used is 'none'.
It is expected for encrypted InputFormats and OutputFormats to copy the keys from the original provider into the job's Credentials object, which is accessed via the UserProvider. Therefore, this provider won't be used by MapReduce tasks.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe factory to create JksProviders, which is used by the ServiceLoader.static classAn adapter between a KeyStore Key and our Metadata.Nested classes/interfaces inherited from class org.apache.hadoop.crypto.key.KeyProvider
KeyProvider.KeyVersion, KeyProvider.Metadata, KeyProvider.Options -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char[]static final Stringstatic final Stringstatic final StringFields 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbackupToOld(Path oldPath) createKey(String name, byte[] material, KeyProvider.Options options) Create a new key.voidDelete the given key.voidflush()Ensures that any changes to the keys are written to persistent store.getKeys()Get the key names for all keys.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.booleanDoes this provider require a password?If a password for the provider is needed, but is not provided, this will return an error message and instructions for supplying said password to the provider.If a password for the provider is needed, but is not provided, this will return a warning and instructions for supplying said password to the provider.rollNewVersion(String name, byte[] material) Roll a new version of the given key.toString()protected voidwriteToNew(Path newPath) Methods inherited from class org.apache.hadoop.crypto.key.KeyProvider
buildVersionName, close, createKey, findProvider, generateKey, getBaseName, getConf, getCurrentKey, getKeysMetadata, invalidateCache, isTransient, options, rollNewVersion
-
Field Details
-
SCHEME_NAME
- See Also:
-
KEYSTORE_PASSWORD_FILE_KEY
- See Also:
-
KEYSTORE_PASSWORD_ENV_VAR
- See Also:
-
KEYSTORE_PASSWORD_DEFAULT
public static final char[] KEYSTORE_PASSWORD_DEFAULT
-
-
Method Details
-
needsPassword
Description copied from class:KeyProviderDoes this provider require a password? This means that a password is required for normal operation, and it has not been found through normal means. If true, the password should be provided by the caller using setPassword().- Overrides:
needsPasswordin classKeyProvider- Returns:
- Whether or not the provider requires a password
- Throws:
IOException- raised on errors performing I/O.
-
noPasswordWarning
Description copied from class:KeyProviderIf a password for the provider is needed, but is not provided, this will return a warning and instructions for supplying said password to the provider.- Overrides:
noPasswordWarningin classKeyProvider- Returns:
- A warning and instructions for supplying the password
-
noPasswordError
Description copied from class:KeyProviderIf a password for the provider is needed, but is not provided, this will return an error message and instructions for supplying said password to the provider.- Overrides:
noPasswordErrorin classKeyProvider- Returns:
- An error message and instructions for supplying the password
-
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.
-
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.
-
writeToNew
- Throws:
IOException
-
backupToOld
- Throws:
IOException
-
toString
-