aboutsummaryrefslogtreecommitdiffstats
path: root/rest-services/aai-client
diff options
context:
space:
mode:
Diffstat (limited to 'rest-services/aai-client')
-rw-r--r--rest-services/aai-client/pom.xml2
-rw-r--r--rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/AaiHttpClientFactory.java12
-rw-r--r--rest-services/aai-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/AaiClientConfigurations.java18
3 files changed, 19 insertions, 13 deletions
diff --git a/rest-services/aai-client/pom.xml b/rest-services/aai-client/pom.xml
index 5743d054..6d755c86 100644
--- a/rest-services/aai-client/pom.xml
+++ b/rest-services/aai-client/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.onap.dcaegen2.services.sdk</groupId>
<artifactId>dcaegen2-services-sdk-rest-services</artifactId>
- <version>1.1.5-SNAPSHOT</version>
+ <version>1.1.6-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
diff --git a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/AaiHttpClientFactory.java b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/AaiHttpClientFactory.java
index 9c097ef1..21d56c49 100644
--- a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/AaiHttpClientFactory.java
+++ b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/AaiHttpClientFactory.java
@@ -61,20 +61,16 @@ public class AaiHttpClientFactory {
private SslContext createSslContext() {
if (configuration.enableAaiCertAuth()) {
final SecurityKeys collectorSecurityKeys = ImmutableSecurityKeys.builder()
- .keyStore(ImmutableSecurityKeysStore.of(resource(configuration.keyStorePath()).get()))
- .keyStorePassword(Passwords.fromResource(configuration.keyStorePasswordPath()))
- .trustStore(ImmutableSecurityKeysStore.of(resource(configuration.trustStorePath()).get()))
- .trustStorePassword(Passwords.fromResource(configuration.trustStorePasswordPath()))
+ .keyStore(ImmutableSecurityKeysStore.of(Paths.get(configuration.keyStorePath())))
+ .keyStorePassword(Passwords.fromPath(Paths.get(configuration.keyStorePasswordPath())))
+ .trustStore(ImmutableSecurityKeysStore.of(Paths.get(configuration.trustStorePath())))
+ .trustStorePassword(Passwords.fromPath(Paths.get(configuration.trustStorePasswordPath())))
.build();
return sslFactory.createSecureClientContext(collectorSecurityKeys);
}
return sslFactory.createInsecureClientContext();
}
- private Try<Path> resource(String resource) {
- return Try.of(() -> Paths.get(Passwords.class.getResource(resource).toURI()));
- }
-
public static RequestDiagnosticContext createRequestDiagnosticContext() {
return ImmutableRequestDiagnosticContext.builder()
.invocationId(UUID.randomUUID()).requestId(UUID.randomUUID()).build();
diff --git a/rest-services/aai-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/AaiClientConfigurations.java b/rest-services/aai-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/AaiClientConfigurations.java
index f93bfd67..82356034 100644
--- a/rest-services/aai-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/AaiClientConfigurations.java
+++ b/rest-services/aai-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/AaiClientConfigurations.java
@@ -19,6 +19,8 @@
*/
package org.onap.dcaegen2.services.sdk.rest.services.aai.client;
+import java.net.URISyntaxException;
+import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
@@ -48,10 +50,10 @@ public final class AaiClientConfigurations {
.aaiUserName("sample-username")
.aaiUserPassword("sample-password")
.aaiIgnoreSslCertificateErrors(false)
- .trustStorePath("/trust.pkcs12")
- .trustStorePasswordPath("/trust.pass")
- .keyStorePath("/server.pkcs12")
- .keyStorePasswordPath("/server.pass")
+ .trustStorePath(testResourceToPath("/trust.pkcs12"))
+ .trustStorePasswordPath(testResourceToPath("/trust.pass"))
+ .keyStorePath(testResourceToPath("/server.pkcs12"))
+ .keyStorePasswordPath(testResourceToPath("/server.pass"))
.enableAaiCertAuth(secure)
.aaiHeaders(headers)
.aaiProtocol("sample-protocol")
@@ -61,4 +63,12 @@ public final class AaiClientConfigurations {
.aaiServiceInstancePath("sample-instance-path")
.build();
}
+
+ private static String testResourceToPath(String resource) {
+ try {
+ return Paths.get(AaiClientConfigurations.class.getResource(resource).toURI()).toString();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException("Failed resolving test resource path", e);
+ }
+ }
}