use of com.amazonaws.services.secretsmanager.model.PutSecretValueRequest in project fernet-java8 by l0s.
the class SecretsManagerTest method verifyPutSecretValueStoresKeys.
@Test
public final void verifyPutSecretValueStoresKeys() throws IOException {
// given
final String expected = "expected";
final Key key0 = mock(Key.class);
final Key key1 = mock(Key.class);
final Answer<?> answer = new Answer<Void>() {
public Void answer(final InvocationOnMock invocation) throws Throwable {
final OutputStream stream = invocation.getArgument(0);
stream.write(expected.getBytes("UTF-8"));
return null;
}
};
doAnswer(answer).when(key0).writeTo(any(OutputStream.class));
doAnswer(answer).when(key1).writeTo(any(OutputStream.class));
// when
manager.putSecretValue("secret", "version", asList(key0, key1), PREVIOUS);
// then
final PutSecretValueRequest request = new PutSecretValueRequest();
request.setSecretId("secret");
request.setClientRequestToken("version");
request.setVersionStages(singleton("AWSPREVIOUS"));
request.setSecretBinary(ByteBuffer.wrap((expected + expected).getBytes("UTF-8")));
verify(delegate).putSecretValue(eq(request));
}
use of com.amazonaws.services.secretsmanager.model.PutSecretValueRequest in project fernet-java8 by l0s.
the class MemoryOverwritingRequestHandler method afterError.
public void afterError(final Request<?> request, final Response<?> response, final Exception exception) {
final Object requestObject = request.getOriginalRequestObject();
if (requestObject instanceof PutSecretValueRequest) {
final PutSecretValueRequest putRequest = (PutSecretValueRequest) requestObject;
overwriteSecret(putRequest);
}
}
use of com.amazonaws.services.secretsmanager.model.PutSecretValueRequest in project JAQU-CAZ-Payments-API by InformedSolutions.
the class SecretsManagerInitialisation method createSecret.
@SneakyThrows
public void createSecret(String secretName, String apiKey, String... cleanAirZoneId) {
Map<String, String> apiKeysMap = Arrays.asList(cleanAirZoneId).stream().map(cazId -> cazId.replace("-", "")).collect(Collectors.toMap(Function.identity(), string -> apiKey));
String secretString = objectMapper.writeValueAsString(apiKeysMap);
try {
CreateSecretRequest createSecretRequest = new CreateSecretRequest().withName(secretName).withSecretString(secretString);
secretsManager.createSecret(createSecretRequest);
} catch (ResourceExistsException e) {
PutSecretValueRequest putSecretValueRequest = new PutSecretValueRequest();
putSecretValueRequest.withSecretId(secretName).withSecretString(secretString);
secretsManager.putSecretValue(putSecretValueRequest);
}
}
Aggregations