Class VaultSecretBackend
java.lang.Object
com.atlassian.secrets.service.vault.VaultSecretBackend
- All Implemented Interfaces:
SecretServiceBackend
This class is an implementation of
SecretServiceBackend for
interacting with HashiCorp Vault. It provides methods to seal and unseal secrets.- Since:
- 5.0.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionVaultSecretBackend(String backendId, VaultConfig config) Constructs a new VaultSecretService with the provided configuration.VaultSecretBackend(String backendId, VaultConfig vaultConfig, VaultTemplateFactory templateFactory, VaultAuthenticationProvider authenticationProvider) Constructs a new VaultSecretService with the provided configuration, template factory, and authentication provider. -
Method Summary
Modifier and TypeMethodDescriptionvoidgetType()Seals a secret in HashiCorp Vault.unseal(SealedSecret sealedSecret) Unseals a secret from HashiCorp Vault.
-
Field Details
-
SECRET_KEY
- See Also:
-
-
Constructor Details
-
VaultSecretBackend
Constructs a new VaultSecretService with the provided configuration. Uses default implementations for the template factory and authentication provider.- Parameters:
config- the configuration for the HashiCorp Vault
-
VaultSecretBackend
public VaultSecretBackend(String backendId, VaultConfig vaultConfig, VaultTemplateFactory templateFactory, VaultAuthenticationProvider authenticationProvider) Constructs a new VaultSecretService with the provided configuration, template factory, and authentication provider. This constructor is useful for testing purposes.- Parameters:
vaultConfig- the configuration for the HashiCorp VaulttemplateFactory- the factory to create VaultTemplatesauthenticationProvider- the provider for Vault authentication
-
-
Method Details
-
seal
Seals a secret in HashiCorp Vault. The secret is stored at a path constructed from the identifier and the config.- Specified by:
sealin interfaceSecretServiceBackend- Parameters:
identifier- the identifier for the secretplainTextToSecure- the secret to be sealed- Returns:
- a SealedSecret representing the sealed secret
- Throws:
SecretServiceException- if there is an error sealing the secret
-
unseal
Unseals a secret from HashiCorp Vault. The secret is retrieved from a path constructed from the identifier of the sealed secret. This method only works with IdentifierBasedSecret.- Specified by:
unsealin interfaceSecretServiceBackend- Parameters:
sealedSecret- the sealed secret to be unsealed- Returns:
- the unsealed secret
- Throws:
SecretServiceException- if there is an error unsealing the secret
-
delete
- Specified by:
deletein interfaceSecretServiceBackend- Throws:
SecretServiceException
-
getType
- Specified by:
getTypein interfaceSecretServiceBackend
-