use of software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse in project tessera by ConsenSys.
the class AWSKeyVaultServiceTest method getSecret.
@Test
public void getSecret() {
String secretName = "name";
Map<String, String> getSecretData = Map.of(AWSKeyVaultService.SECRET_NAME_KEY, secretName);
GetSecretValueResponse secretValueResponse = GetSecretValueResponse.builder().secretString("secret").build();
when(secretsManager.getSecretValue(any(GetSecretValueRequest.class))).thenReturn(secretValueResponse);
assertThat(keyVaultService.getSecret(getSecretData)).isEqualTo("secret");
verify(secretsManager).getSecretValue(any(GetSecretValueRequest.class));
}
use of software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse in project aws-doc-sdk-examples by awsdocs.
the class GetSecretValue method getValue.
// snippet-start:[secretsmanager.java2.get_secret.main]
public static void getValue(SecretsManagerClient secretsClient, String secretName) {
try {
GetSecretValueRequest valueRequest = GetSecretValueRequest.builder().secretId(secretName).build();
GetSecretValueResponse valueResponse = secretsClient.getSecretValue(valueRequest);
String secret = valueResponse.secretString();
System.out.println(secret);
} catch (SecretsManagerException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse in project spring-cloud-aws by awspring.
the class SecretsManagerPropertySource method readSecretValue.
private void readSecretValue(GetSecretValueRequest secretValueRequest) {
GetSecretValueResponse secretValueResponse = source.getSecretValue(secretValueRequest);
try {
Map<String, Object> secretMap = jsonMapper.readValue(secretValueResponse.secretString(), new TypeReference<Map<String, Object>>() {
});
for (Map.Entry<String, Object> secretEntry : secretMap.entrySet()) {
LOG.debug("Populating property retrieved from AWS Secrets Manager: " + secretEntry.getKey());
properties.put(secretEntry.getKey(), secretEntry.getValue());
}
} catch (JsonParseException e) {
// If the secret is not a JSON string, then it is a simple "plain text" string
LOG.debug("Populating property retrieved from AWS Secrets Manager: " + secretValueResponse.name());
properties.put(secretValueResponse.name(), secretValueResponse.secretString());
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
use of software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse in project cu-kfs by CU-CommunityApps.
the class AwsSecretServiceImpl method retrieveSecretFromAws.
protected String retrieveSecretFromAws(String fullAwsKey) {
SecretsManagerClient client = buildSecretsManagerClient();
try {
GetSecretValueRequest valueRequest = GetSecretValueRequest.builder().secretId(fullAwsKey).build();
GetSecretValueResponse valueResponse = client.getSecretValue(valueRequest);
return valueResponse.secretString();
} catch (SecretsManagerException e) {
LOG.error("retrieveSecretFromAws, had an error getting value for secret " + fullAwsKey, e);
throw new RuntimeException(e);
} finally {
client.close();
}
}
use of software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse in project aws-mysql-jdbc by awslabs.
the class AWSSecretsManagerPlugin method getCurrentCredentials.
Secret getCurrentCredentials() throws SecretsManagerException, JsonProcessingException {
final GetSecretValueResponse valueResponse = this.secretsManagerClient.getSecretValue(this.getSecretValueRequest);
final ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(valueResponse.secretString(), Secret.class);
}
Aggregations