summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/http/provider/pom.xml6
-rw-r--r--base/http/provider/src/main/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapter.java17
-rw-r--r--base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapterTest.java13
3 files changed, 22 insertions, 14 deletions
diff --git a/base/http/provider/pom.xml b/base/http/provider/pom.xml
index 56728be61..e6061ed62 100644
--- a/base/http/provider/pom.xml
+++ b/base/http/provider/pom.xml
@@ -31,5 +31,11 @@
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.onap.logging-analytics</groupId>
+ <artifactId>logging-filter-base</artifactId>
+ <version>1.5.0</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/base/http/provider/src/main/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapter.java b/base/http/provider/src/main/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapter.java
index 92e64b6dd..cc6f06a4d 100644
--- a/base/http/provider/src/main/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapter.java
+++ b/base/http/provider/src/main/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapter.java
@@ -4,13 +4,13 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.util.Base64;
import java.util.Properties;
-
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.ws.rs.client.ClientBuilder;
-import javax.xml.bind.DatatypeConverter;
-
+import org.onap.logging.filter.base.MetricLogClientFilter;
+import org.onap.logging.filter.base.PayloadLoggingClientFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -26,7 +26,6 @@ public abstract class AbstractHttpAdapter {
public AbstractHttpAdapter() {
clientBuilder = ClientBuilder.newBuilder();
setTimeouts();
- registerLoggingFilter();
defaultHostNameVerifier();
}
@@ -39,7 +38,13 @@ public abstract class AbstractHttpAdapter {
});
}
- protected abstract void registerLoggingFilter();
+ protected void enableMetricLogging() {
+ clientBuilder.register(new MetricLogClientFilter());
+ }
+
+ protected void enablePayloadLogging() {
+ clientBuilder.register(new PayloadLoggingClientFilter());
+ }
private void setTimeouts() {
Integer httpReadTimeout = readOptionalInteger("HTTP_READ_TIMEOUT_MS", DEFAULT_HTTP_READ_TIMEOUT_MS);
@@ -83,7 +88,7 @@ public abstract class AbstractHttpAdapter {
protected String getBasicAuthValue(String userName, String password) {
String token = userName + ":" + password;
try {
- return "Basic " + DatatypeConverter.printBase64Binary(token.getBytes("UTF-8"));
+ return "Basic " + Base64.getEncoder().encodeToString(token.getBytes());
} catch (Exception e) {
logger.error("getBasicAuthValue threw an exception, credentials will be null", e);
}
diff --git a/base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapterTest.java b/base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapterTest.java
index ee2d223d3..d0973d90e 100644
--- a/base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapterTest.java
+++ b/base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapterTest.java
@@ -12,16 +12,13 @@ import org.junit.Test;
public class AbstractHttpAdapterTest {
- public class NonLoggingHttpAdapter extends AbstractHttpAdapter {
- @Override
- protected void registerLoggingFilter() {
- // nonlogging, do nothing
- }
+ public class TestAdapter extends AbstractHttpAdapter {
+
}
@Test
public void checkTimeouts() throws Exception {
- NonLoggingHttpAdapter adapter = new NonLoggingHttpAdapter();
+ TestAdapter adapter = new TestAdapter();
Client client = adapter.getClientBuilder().build();
assertNotNull(client.getConfiguration().getProperty("jersey.config.client.readTimeout"));
assertNotNull(client.getConfiguration().getProperty("jersey.config.client.connectTimeout"));
@@ -30,7 +27,7 @@ public class AbstractHttpAdapterTest {
@Test
public void propertiesTest() throws Exception {
System.setProperty(AbstractHttpAdapter.SDNC_CONFIG_DIR, "src/test/resources/");
- NonLoggingHttpAdapter adapter = new NonLoggingHttpAdapter();
+ TestAdapter adapter = new TestAdapter();
Properties props = adapter.getProperties("testprops.properties");
assertNotNull(props);
assertEquals("world", props.get("hello"));
@@ -38,7 +35,7 @@ public class AbstractHttpAdapterTest {
@Test
public void basicAuthFilter() throws Exception {
- NonLoggingHttpAdapter adapter = new NonLoggingHttpAdapter();
+ TestAdapter adapter = new TestAdapter();
adapter.addBasicAuthCredentials("hello", "world");
Set<Object> objs = adapter.getClientBuilder().getConfiguration().getInstances();
assertEquals(BasicAuthFilter.class,objs.iterator().next().getClass());