Search in sources :

Example 1 with InvalidParameterException

use of software.amazon.awssdk.services.secretsmanager.model.InvalidParameterException in project tessera by ConsenSys.

the class AWSKeyVaultService method getSecret.

@Override
public String getSecret(Map<String, String> getSecretData) {
    final String secretName = getSecretData.get(SECRET_NAME_KEY);
    GetSecretValueRequest getSecretValueRequest = GetSecretValueRequest.builder().secretId(secretName).build();
    GetSecretValueResponse secretValueResponse;
    try {
        secretValueResponse = secretsManager.getSecretValue(getSecretValueRequest);
    } catch (ResourceNotFoundException e) {
        throw new VaultSecretNotFoundException("The requested secret '" + secretName + "' was not found in AWS Secrets Manager");
    } catch (InvalidRequestException | InvalidParameterException e) {
        throw new AWSSecretsManagerException(e);
    }
    if (secretValueResponse != null && secretValueResponse.secretString() != null) {
        return secretValueResponse.secretString();
    }
    throw new VaultSecretNotFoundException("The requested secret '" + secretName + "' was not found in AWS Secrets Manager");
}
Also used : InvalidParameterException(software.amazon.awssdk.services.secretsmanager.model.InvalidParameterException) GetSecretValueRequest(software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest) VaultSecretNotFoundException(com.quorum.tessera.key.vault.VaultSecretNotFoundException) InvalidRequestException(software.amazon.awssdk.services.secretsmanager.model.InvalidRequestException) GetSecretValueResponse(software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse) ResourceNotFoundException(software.amazon.awssdk.services.secretsmanager.model.ResourceNotFoundException)

Aggregations

VaultSecretNotFoundException (com.quorum.tessera.key.vault.VaultSecretNotFoundException)1 GetSecretValueRequest (software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest)1 GetSecretValueResponse (software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse)1 InvalidParameterException (software.amazon.awssdk.services.secretsmanager.model.InvalidParameterException)1 InvalidRequestException (software.amazon.awssdk.services.secretsmanager.model.InvalidRequestException)1 ResourceNotFoundException (software.amazon.awssdk.services.secretsmanager.model.ResourceNotFoundException)1