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
public class CachingKeyProvider
- extends KeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>
A KeyProviderExtension
implementation providing a short lived
cache for KeyVersions
and Metadata
to avoid burst
of requests to hit the underlying KeyProvider
.
CachingKeyProvider
public CachingKeyProvider(KeyProvider keyProvider,
long keyTimeoutMillis,
long currKeyTimeoutMillis)
getCurrentKey
public KeyProvider.KeyVersion getCurrentKey(String name)
throws IOException
- Description copied from class:
KeyProvider
- Get the current version of the key, which should be used for encrypting new
data.
- Overrides:
getCurrentKey
in class KeyProviderExtension<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
getKeyVersion
public KeyProvider.KeyVersion getKeyVersion(String versionName)
throws IOException
- Description copied from class:
KeyProvider
- Get the key material for a specific version of the key. This method is used
when decrypting data.
- Overrides:
getKeyVersion
in class KeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>
- Parameters:
versionName
- the name of a specific version of the key
- Returns:
- the key material
- Throws:
IOException
deleteKey
public void deleteKey(String name)
throws IOException
- Description copied from class:
KeyProvider
- Delete the given key.
- Overrides:
deleteKey
in class KeyProviderExtension<org.apache.hadoop.crypto.key.CachingKeyProvider.CacheExtension>
- Parameters:
name
- the name of the key to delete
- Throws:
IOException
rollNewVersion
public KeyProvider.KeyVersion rollNewVersion(String name,
byte[] material)
throws IOException
- Description copied from class:
KeyProvider
- Roll a new version of the given key.
- Overrides:
rollNewVersion
in class KeyProviderExtension<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
rollNewVersion
public KeyProvider.KeyVersion rollNewVersion(String name)
throws NoSuchAlgorithmException,
IOException
- Description copied from class:
KeyProvider
- Roll 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:
rollNewVersion
in class KeyProviderExtension<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:
IOException
NoSuchAlgorithmException
getMetadata
public KeyProvider.Metadata getMetadata(String name)
throws IOException
- Description copied from class:
KeyProvider
- Get metadata about the key.
- Overrides:
getMetadata
in class KeyProviderExtension<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
Copyright © 2014 Apache Software Foundation. All Rights Reserved.