Class AzureKeyVaultKeysReactiveService
This service is a kind of wrapper of
AzureKeyVaultKeysReactiveClient
which implements:
- the retrieving, caching (done by means of
AzureIdentityReactiveService
) and renewal (when it expires or when used the resource API returns 401 or 403) of the access token from Microsoft Entra ID that will be used with Azure Key Vault (by means ofAzureKeyVaultKeysReactiveClient
); - the retrying with exponential back-off in case of 429 from Azure Key Vault.
To use this service, the application.properties
should have the definition of the
following properties to control the back-off policy:
azure-key-vault-keys.backoff.initial-duration
azure-key-vault-keys.backoff.jitter
azure-key-vault-keys.backoff.number-of-attempts
- Author:
- Antonio Tarricone
-
Field Summary
Modifier and TypeFieldDescriptionprivate String
Cached access token.private AzureIdentityReactiveService
Service to retrieve the access token from Microsoft Entra ID.(package private) int
Initial back-off duration in seconds.(package private) double
Jitter of back-off policy: it must be in [0; 1](package private) AzureKeyVaultKeysReactiveClient
REST client to use Azure Key Vault.(package private) int
Number of retries. -
Constructor Summary
ConstructorDescriptionAzureKeyVaultKeysReactiveService
(AzureIdentityReactiveService identityService) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) Object
authenticate
(jakarta.interceptor.InvocationContext context) This method decorates the others:io.smallrye.mutiny.Uni
<KeyBundle> createKey
(String keyName, KeyCreateParameters keyCreateParameters) Creates a new key, stores it, then returns key parameters and attributes to the client.io.smallrye.mutiny.Uni
<KeyOperationResult> decrypt
(String keyName, String keyVersion, KeyOperationParameters keyOperationParameters) Decrypts a single block of encrypted data.io.smallrye.mutiny.Uni
<DeletedKeyBundle> Deletes a key of any type from storage in Azure Key Vault.io.smallrye.mutiny.Uni
<KeyOperationResult> encrypt
(String keyName, String keyVersion, KeyOperationParameters keyOperationParameters) Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault.io.smallrye.mutiny.Uni
<KeyBundle> Returns the public part of a stored key.io.smallrye.mutiny.Uni
<KeyListResult> getKeys()
Lists keys in the specified vault.io.smallrye.mutiny.Uni
<KeyListResult> Lists keys in the specified vault.io.smallrye.mutiny.Uni
<KeyListResult> getKeyVersions
(String keyName) Returns a list of individual key versions with the same key name.io.smallrye.mutiny.Uni
<KeyListResult> getKeyVersions
(String keyName, String skiptoken) Returns a list of individual key versions with the same key name.private io.smallrye.mutiny.Uni
<Object> proceed
(jakarta.interceptor.InvocationContext context) TransformsException
inRuntimeException
to allow handling with Mutiny.io.smallrye.mutiny.Uni
<KeyOperationResult> sign
(String keyName, String keyVersion, KeySignParameters keySignParameters) Creates a signature from a digest using the specified key.io.smallrye.mutiny.Uni
<KeyVerifyResult> verify
(String keyName, String keyVersion, KeyVerifyParameters keyVerifyParameters) Verifies a signature using a specified key.
-
Field Details
-
initialBackoff
int initialBackoffInitial back-off duration in seconds.
-
jitter
double jitterJitter of back-off policy: it must be in [0; 1]
-
numberOfAttempts
int numberOfAttemptsNumber of retries.
-
identityService
Service to retrieve the access token from Microsoft Entra ID.
- See Also:
-
keysClient
REST client to use Azure Key Vault.
- See Also:
-
accessTokenValue
Cached access token.
-
-
Constructor Details
-
AzureKeyVaultKeysReactiveService
Constructor.
- Parameters:
identityService
-AzureIdentityReactiveService
-
-
Method Details
-
proceed
Transforms
Exception
inRuntimeException
to allow handling with Mutiny.- Parameters:
context
-InvocationContext
- Returns:
- Object returned by the target method.
-
authenticate
This method decorates the others:
- retrieving the access token from Microsoft Entra ID by means of
AzureIdentityReactiveService
; - renewing of the access token from Microsoft Entra ID the invoked target API returns 401 or 403;
- retrying with exponential back-off in case of 429 from Azure Key Vault.
- Parameters:
context
-InvocationContext
- Returns:
- Object returned by the target method.
- retrieving the access token from Microsoft Entra ID by means of
-
createKey
public io.smallrye.mutiny.Uni<KeyBundle> createKey(String keyName, KeyCreateParameters keyCreateParameters) Creates a new key, stores it, then returns key parameters and attributes to the client.
- Parameters:
keyName
- The name for the new key. Regex pattern: ^[0-9a-zA-Z-]+$keyCreateParameters
-KeyCreateParameters
- Returns:
KeyBundle
-
getKeys
Lists keys in the specified vault.
- Returns:
KeyListResult
-
getKeys
Lists keys in the specified vault.
- Parameters:
skiptoken
- Token to handle paging.- Returns:
KeyListResult
-
getKey
Returns the public part of a stored key.
- Parameters:
keyName
- The name of the key to get.keyVersion
- The version of the key.- Returns:
KeyBundle
-
getKeyVersions
Returns a list of individual key versions with the same key name.
- Parameters:
keyName
- The name of the key.- Returns:
KeyListResult
-
getKeyVersions
Returns a list of individual key versions with the same key name.
- Parameters:
keyName
- The name of the key.skiptoken
- Token to handle paging.- Returns:
KeyListResult
-
sign
public io.smallrye.mutiny.Uni<KeyOperationResult> sign(String keyName, String keyVersion, KeySignParameters keySignParameters) Creates a signature from a digest using the specified key.
- Parameters:
keyName
- The name of the key.keyVersion
- The version of the key.keySignParameters
-KeySignParameters
- Returns:
KeyOperationResult
-
verify
public io.smallrye.mutiny.Uni<KeyVerifyResult> verify(String keyName, String keyVersion, KeyVerifyParameters keyVerifyParameters) Verifies a signature using a specified key.
- Parameters:
keyName
- The name of the key.keyVersion
- The version of the key.keyVerifyParameters
-KeyVerifyParameters
- Returns:
KeyVerifyResult
-
encrypt
public io.smallrye.mutiny.Uni<KeyOperationResult> encrypt(String keyName, String keyVersion, KeyOperationParameters keyOperationParameters) Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault.
- Parameters:
keyName
- The name of the key.keyVersion
- The version of the key.keyOperationParameters
-KeyOperationParameters
- Returns:
KeyOperationResult
-
decrypt
public io.smallrye.mutiny.Uni<KeyOperationResult> decrypt(String keyName, String keyVersion, KeyOperationParameters keyOperationParameters) Decrypts a single block of encrypted data.
- Parameters:
keyName
- The name of the key.keyVersion
- The version of the key.keyOperationParameters
-KeyOperationParameters
- Returns:
KeyOperationResult
-
deleteKey
Deletes a key of any type from storage in Azure Key Vault.
- Parameters:
keyName
- The name of the key to delete.- Returns:
DeletedKeyBundle
-