java.io.Closeable, java.lang.AutoCloseableJavaKeyStoreProvider, KeyProviderExtension, KMSClientProvider, LoadBalancingKMSClientProvider, UserProvider@Public
@Stable
public abstract class KeyProvider
extends java.lang.Object
implements java.io.Closeable
KeyProvider implementations must be thread safe.
| Modifier and Type | Class | Description |
|---|---|---|
static class |
KeyProvider.KeyVersion |
The combination of both the key version name and the key material.
|
static class |
KeyProvider.Metadata |
Key metadata that is associated with the key.
|
static class |
KeyProvider.Options |
Options when creating key objects.
|
| Modifier and Type | Field | Description |
|---|---|---|
static int |
DEFAULT_BITLENGTH |
|
static java.lang.String |
DEFAULT_BITLENGTH_NAME |
|
static java.lang.String |
DEFAULT_CIPHER |
|
static java.lang.String |
DEFAULT_CIPHER_NAME |
|
static java.lang.String |
JCEKS_KEY_SERIAL_FILTER |
|
static java.lang.String |
JCEKS_KEY_SERIALFILTER_DEFAULT |
| Constructor | Description |
|---|---|
KeyProvider(Configuration conf) |
Constructor.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected static java.lang.String |
buildVersionName(java.lang.String name,
int version) |
Build a version string from a basename and version number.
|
void |
close() |
Can be used by implementing classes to close any resources
that require closing
|
abstract KeyProvider.KeyVersion |
createKey(java.lang.String name,
byte[] material,
KeyProvider.Options options) |
Create a new key.
|
KeyProvider.KeyVersion |
createKey(java.lang.String name,
KeyProvider.Options options) |
Create a new key generating the material for it.
|
abstract void |
deleteKey(java.lang.String name) |
Delete the given key.
|
static KeyProvider |
findProvider(java.util.List<KeyProvider> providerList,
java.lang.String keyName) |
Find the provider with the given key.
|
abstract void |
flush() |
Ensures that any changes to the keys are written to persistent store.
|
protected byte[] |
generateKey(int size,
java.lang.String algorithm) |
Generates a key material.
|
static java.lang.String |
getBaseName(java.lang.String versionName) |
Split the versionName in to a base name.
|
Configuration |
getConf() |
Return the provider configuration.
|
KeyProvider.KeyVersion |
getCurrentKey(java.lang.String name) |
Get the current version of the key, which should be used for encrypting new
data.
|
abstract java.util.List<java.lang.String> |
getKeys() |
Get the key names for all keys.
|
KeyProvider.Metadata[] |
getKeysMetadata(java.lang.String... names) |
Get key metadata in bulk.
|
abstract KeyProvider.KeyVersion |
getKeyVersion(java.lang.String versionName) |
Get the key material for a specific version of the key.
|
abstract java.util.List<KeyProvider.KeyVersion> |
getKeyVersions(java.lang.String name) |
Get the key material for all versions of a specific key name.
|
abstract KeyProvider.Metadata |
getMetadata(java.lang.String name) |
Get metadata about the key.
|
void |
invalidateCache(java.lang.String name) |
Can be used by implementing classes to invalidate the caches.
|
boolean |
isTransient() |
Indicates whether this provider represents a store
that is intended for transient use - such as the UserProvider
is.
|
boolean |
needsPassword() |
Does this provider require a password? This means that a password is
required for normal operation, and it has not been found through normal
means.
|
java.lang.String |
noPasswordError() |
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.
|
java.lang.String |
noPasswordWarning() |
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.
|
static KeyProvider.Options |
options(Configuration conf) |
A helper function to create an options object.
|
KeyProvider.KeyVersion |
rollNewVersion(java.lang.String name) |
Roll a new version of the given key generating the material for it.
|
abstract KeyProvider.KeyVersion |
rollNewVersion(java.lang.String name,
byte[] material) |
Roll a new version of the given key.
|
public static final java.lang.String DEFAULT_CIPHER_NAME
public static final java.lang.String DEFAULT_CIPHER
public static final java.lang.String DEFAULT_BITLENGTH_NAME
public static final int DEFAULT_BITLENGTH
public static final java.lang.String JCEKS_KEY_SERIALFILTER_DEFAULT
public static final java.lang.String JCEKS_KEY_SERIAL_FILTER
public KeyProvider(Configuration conf)
conf - configuration for the providerpublic Configuration getConf()
public static KeyProvider.Options options(Configuration conf)
conf - the configuration to usepublic boolean isTransient()
public abstract KeyProvider.KeyVersion getKeyVersion(java.lang.String versionName) throws java.io.IOException
versionName - the name of a specific version of the keyjava.io.IOException - raised on errors performing I/O.public abstract java.util.List<java.lang.String> getKeys()
throws java.io.IOException
java.io.IOException - raised on errors performing I/O.public KeyProvider.Metadata[] getKeysMetadata(java.lang.String... names) throws java.io.IOException
names - the names of the keys to getjava.io.IOException - raised on errors performing I/O.public abstract java.util.List<KeyProvider.KeyVersion> getKeyVersions(java.lang.String name) throws java.io.IOException
name - the base name of the key.java.io.IOException - raised on errors performing I/O.public KeyProvider.KeyVersion getCurrentKey(java.lang.String name) throws java.io.IOException
name - the base name of the keyjava.io.IOException - raised on errors performing I/O.public abstract KeyProvider.Metadata getMetadata(java.lang.String name) throws java.io.IOException
name - the basename of the keyjava.io.IOException - raised on errors performing I/O.public abstract KeyProvider.KeyVersion createKey(java.lang.String name, byte[] material, KeyProvider.Options options) throws java.io.IOException
name - the base name of the keymaterial - the key material for the first version of the key.options - the options for the new key.java.io.IOException - raised on errors performing I/O.protected byte[] generateKey(int size,
java.lang.String algorithm)
throws java.security.NoSuchAlgorithmException
size - length of the key.algorithm - algorithm to use for generating the key.java.security.NoSuchAlgorithmException - no such algorithm exception.public KeyProvider.KeyVersion createKey(java.lang.String name, KeyProvider.Options options) throws java.security.NoSuchAlgorithmException, java.io.IOException
This implementation generates the key material and calls the
createKey(String, byte[], Options) method.
name - the base name of the keyoptions - the options for the new key.java.io.IOException - raised on errors performing I/O.java.security.NoSuchAlgorithmException - no such algorithm exception.public abstract void deleteKey(java.lang.String name)
throws java.io.IOException
name - the name of the key to deletejava.io.IOException - raised on errors performing I/O.public abstract KeyProvider.KeyVersion rollNewVersion(java.lang.String name, byte[] material) throws java.io.IOException
name - the basename of the keymaterial - the new key materialjava.io.IOException - raised on errors performing I/O.public void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOExceptionpublic KeyProvider.KeyVersion rollNewVersion(java.lang.String name) throws java.security.NoSuchAlgorithmException, java.io.IOException
This implementation generates the key material and calls the
rollNewVersion(String, byte[]) method.
name - the basename of the keyjava.io.IOException - raised on errors performing I/O.java.security.NoSuchAlgorithmException - This exception is thrown when a particular
cryptographic algorithm is requested
but is not available in the environment.public void invalidateCache(java.lang.String name)
throws java.io.IOException
name - the basename of the keyjava.io.IOException - raised on errors performing I/O.public abstract void flush()
throws java.io.IOException
java.io.IOException - raised on errors performing I/O.public static java.lang.String getBaseName(java.lang.String versionName)
throws java.io.IOException
versionName - the version name to splitjava.io.IOException - raised on errors performing I/O.protected static java.lang.String buildVersionName(java.lang.String name,
int version)
name - the basename of the keyversion - the version of the keypublic static KeyProvider findProvider(java.util.List<KeyProvider> providerList, java.lang.String keyName) throws java.io.IOException
providerList - the list of providerskeyName - the key name we are looking for.java.io.IOException - raised on errors performing I/O.public boolean needsPassword()
throws java.io.IOException
java.io.IOException - raised on errors performing I/O.public java.lang.String noPasswordWarning()
public java.lang.String noPasswordError()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.