use of com.amazonaws.services.simplesystemsmanagement.model.GetParameterRequest in project aws-java-serverless by hermanlintvelt.
the class SecureParameterService method getParameterValue.
public static String getParameterValue(String name, boolean withDecryption) {
final AWSSimpleSystemsManagement client = AWSSimpleSystemsManagementClientBuilder.defaultClient();
GetParameterRequest request = new GetParameterRequest();
request.withName(name).setWithDecryption(withDecryption);
GetParameterResult result = client.getParameter(request);
LOG.debug("SSM result for param " + name + ": " + result);
if (result.getParameter() != null) {
return result.getParameter().getValue();
} else {
return null;
}
}
use of com.amazonaws.services.simplesystemsmanagement.model.GetParameterRequest in project di-authentication-api by alphagov.
the class ConfigurationServiceTest method getDocAppCredentialSigningPublicKeyShouldGetECPublicKeyObjectFromParameterStorePEM.
@Test
void getDocAppCredentialSigningPublicKeyShouldGetECPublicKeyObjectFromParameterStorePEM() throws JOSEException {
var privateKey = new ECKeyGenerator(Curve.P_256).keyID("my-key-id").generate();
var publicKey = privateKey.toPublicJWK();
var pem = publicKeyToPem(publicKey);
var ssmClient = mock(AWSSimpleSystemsManagement.class);
var request = new GetParameterRequest().withWithDecryption(true).withName("test-doc-app-public-signing-key");
when(ssmClient.getParameter(eq(request))).thenReturn(new GetParameterResult().withParameter(new Parameter().withName("test-doc-app-public-signing-key").withValue(pem)));
ConfigurationService configurationService = new ConfigurationService(ssmClient);
var result = configurationService.getDocAppCredentialSigningPublicKey();
assertThat(result, equalTo(publicKey.toECPublicKey(new BouncyCastleProvider())));
}
Aggregations