Search in sources :

Example 1 with SecretException

use of co.com.bancolombia.secretsmanager.api.exceptions.SecretException in project secrets-manager by bancolombia.

the class AWSParameterStoreConnector method getSecret.

private String getSecret(String secretName, SsmClient client) throws SecretException {
    GetParameterRequest getParameterRequest = GetParameterRequest.builder().name(secretName).build();
    GetParameterResponse getParameterResponse = client.getParameter(getParameterRequest);
    if (getParameterResponse == null) {
        throw new SecretException("Secret value is null");
    } else {
        if (getParameterResponse.parameter().value() != null) {
            return getParameterResponse.parameter().value();
        }
        throw new SecretException("Secret value is not a String");
    }
}
Also used : GetParameterRequest(software.amazon.awssdk.services.ssm.model.GetParameterRequest) GetParameterResponse(software.amazon.awssdk.services.ssm.model.GetParameterResponse) SecretException(co.com.bancolombia.secretsmanager.api.exceptions.SecretException)

Example 2 with SecretException

use of co.com.bancolombia.secretsmanager.api.exceptions.SecretException in project secrets-manager by bancolombia.

the class AWSSecretManagerConnector method getSecret.

private String getSecret(String secretName, SecretsManagerClient client) throws SecretException {
    GetSecretValueRequest getSecretValueRequest = GetSecretValueRequest.builder().secretId(secretName).build();
    GetSecretValueResponse getSecretValueResult = client.getSecretValue(getSecretValueRequest);
    if (getSecretValueResult == null) {
        throw new SecretException("Secret value is null");
    } else {
        if (getSecretValueResult.secretString() != null) {
            return getSecretValueResult.secretString();
        }
        throw new SecretException("Secret value is not a String");
    }
}
Also used : SecretException(co.com.bancolombia.secretsmanager.api.exceptions.SecretException) GetSecretValueRequest(software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest) GetSecretValueResponse(software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse)

Example 3 with SecretException

use of co.com.bancolombia.secretsmanager.api.exceptions.SecretException in project secrets-manager by bancolombia.

the class exceptionsTest method generateExpetion.

@Test
public void generateExpetion() {
    SecretException ex = new SecretException("My error");
    assertEquals("My error", ex.getMessage());
}
Also used : SecretException(co.com.bancolombia.secretsmanager.api.exceptions.SecretException) Test(org.junit.Test)

Aggregations

SecretException (co.com.bancolombia.secretsmanager.api.exceptions.SecretException)3 Test (org.junit.Test)1 GetSecretValueRequest (software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest)1 GetSecretValueResponse (software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse)1 GetParameterRequest (software.amazon.awssdk.services.ssm.model.GetParameterRequest)1 GetParameterResponse (software.amazon.awssdk.services.ssm.model.GetParameterResponse)1