Class VaultBytesKeyGenerator
java.lang.Object
org.springframework.vault.security.VaultBytesKeyGenerator
- All Implemented Interfaces:
BytesKeyGenerator
Random byte generator using Vault's
transit
backend to generate high-quality
random bytes of the configured length.
Using Vault ensures to use a high-entropy source preventing to consume entropy of the local machine.
- Since:
- 2.0
- Author:
- Mark Paluch
-
Constructor Summary
ConstructorDescriptionVaultBytesKeyGenerator
(VaultOperations vaultOperations) Creates a newVaultBytesKeyGenerator
initialized to generate32
random bytes usingtransit
for transit mount path.VaultBytesKeyGenerator
(VaultOperations vaultOperations, String transitPath, int length) Creates a newVaultBytesKeyGenerator
initialized to generatelength
random bytes. -
Method Summary
-
Constructor Details
-
VaultBytesKeyGenerator
Creates a newVaultBytesKeyGenerator
initialized to generate32
random bytes usingtransit
for transit mount path.- Parameters:
vaultOperations
- must not be null.
-
VaultBytesKeyGenerator
Creates a newVaultBytesKeyGenerator
initialized to generatelength
random bytes.- Parameters:
vaultOperations
- must not be null.transitPath
- path of the transit backend, must not be null or empty.length
- number of random bytes to generate. Must be greater than zero.
-
-
Method Details
-
getKeyLength
public int getKeyLength()- Specified by:
getKeyLength
in interfaceBytesKeyGenerator
-
generateKey
public byte[] generateKey()- Specified by:
generateKey
in interfaceBytesKeyGenerator
-