aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2021-12-14 12:12:11 +0000
committerefiacor <fiachra.corcoran@est.tech>2021-12-14 12:12:16 +0000
commit1e0b9be28b9b4a06a5fb322c7c014dbb2705cdd1 (patch)
tree264a218a48d6a0d87f01b8128da14c1eeb7fc14b
parent58a6137c826c7b2127f16ed2c916d0a27cff29a8 (diff)
[DMAAP-CLIENT] Package upgrades for Jjakarta
Signed-off-by: efiacor <fiachra.corcoran@est.tech> Change-Id: I92977c4a940cb164708a7baef53e384b54838370 Issue-ID: DMAAP-1691
-rw-r--r--pom.xml6
-rw-r--r--src/main/java/org/onap/dmaap/mr/client/impl/MRBaseClient.java16
-rw-r--r--src/test/java/org/onap/dmaap/mr/client/impl/MRBaseClientTest.java35
3 files changed, 30 insertions, 27 deletions
diff --git a/pom.xml b/pom.xml
index b07244a..7e1aa54 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,7 +39,7 @@
</parent>
<properties>
- <jersey.version>2.27</jersey.version>
+ <jersey.version>2.34</jersey.version>
<version.jackson.core>2.6.7.1</version.jackson.core>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
@@ -171,7 +171,7 @@
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-apache-connector</artifactId>
- <version>2.29.1</version>
+ <version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
@@ -311,7 +311,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
+ <version>3.3.1</version>
<configuration>
<failOnError>false</failOnError>
<detectJavaApiLink>false</detectJavaApiLink>
diff --git a/src/main/java/org/onap/dmaap/mr/client/impl/MRBaseClient.java b/src/main/java/org/onap/dmaap/mr/client/impl/MRBaseClient.java
index 9522c90..f45895a 100644
--- a/src/main/java/org/onap/dmaap/mr/client/impl/MRBaseClient.java
+++ b/src/main/java/org/onap/dmaap/mr/client/impl/MRBaseClient.java
@@ -27,17 +27,17 @@ package org.onap.dmaap.mr.client.impl;
import com.att.nsa.apiClient.http.CacheUse;
import com.att.nsa.apiClient.http.HttpClient;
import java.net.MalformedURLException;
+import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
-
+import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpException;
import org.apache.http.HttpStatus;
import org.glassfish.jersey.client.ClientConfig;
-import org.glassfish.jersey.internal.util.Base64;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -120,7 +120,8 @@ public class MRBaseClient extends HttpClient implements MRClient {
WebTarget target = null;
Response response = null;
target = DmaapClientUtil.getTarget(clientConfig, path, username, password);
- String encoding = Base64.encodeAsString(username + ":" + password);
+ Base64 base64 = new Base64();
+ String encoding = base64.encodeAsString((username + ":" + password).getBytes(StandardCharsets.UTF_8));
response = DmaapClientUtil.postResponsewtBasicAuth(target, encoding, data, contentType);
@@ -152,7 +153,8 @@ public class MRBaseClient extends HttpClient implements MRClient {
WebTarget target = null;
Response response = null;
target = DmaapClientUtil.getTarget(clientConfig, path, username, password);
- String encoding = Base64.encodeAsString(username + ":" + password);
+ Base64 base64 = new Base64();
+ String encoding = base64.encodeAsString((username + ":" + password).getBytes(StandardCharsets.UTF_8));
response = DmaapClientUtil.postResponsewtBasicAuth(target, encoding, data, contentType);
@@ -222,7 +224,8 @@ public class MRBaseClient extends HttpClient implements MRClient {
response = DmaapClientUtil.getResponsewtCambriaAuth(target, username, password);
} else {
target = DmaapClientUtil.getTarget(clientConfig, path, username, password);
- String encoding = Base64.encodeAsString(username + ":" + password);
+ Base64 base64 = new Base64();
+ String encoding = base64.encodeAsString((username + ":" + password).getBytes(StandardCharsets.UTF_8));
response = DmaapClientUtil.getResponsewtBasicAuth(target, encoding);
@@ -244,7 +247,8 @@ public class MRBaseClient extends HttpClient implements MRClient {
response = DmaapClientUtil.getResponsewtCambriaAuth(target, username, password);
} else {
target = DmaapClientUtil.getTarget(clientConfig, path, username, password);
- String encoding = Base64.encodeAsString(username + ":" + password);
+ Base64 base64 = new Base64();
+ String encoding = base64.encodeAsString((username + ":" + password).getBytes(StandardCharsets.UTF_8));
response = DmaapClientUtil.getResponsewtBasicAuth(target, encoding);
}
MRClientFactory.setHTTPHeadersMap(response.getHeaders());
diff --git a/src/test/java/org/onap/dmaap/mr/client/impl/MRBaseClientTest.java b/src/test/java/org/onap/dmaap/mr/client/impl/MRBaseClientTest.java
index 9d47192..fdb91ba 100644
--- a/src/test/java/org/onap/dmaap/mr/client/impl/MRBaseClientTest.java
+++ b/src/test/java/org/onap/dmaap/mr/client/impl/MRBaseClientTest.java
@@ -24,9 +24,10 @@
package org.onap.dmaap.mr.client.impl;
+import java.nio.charset.StandardCharsets;
import org.apache.http.HttpException;
import org.glassfish.jersey.client.ClientConfig;
-import org.glassfish.jersey.internal.util.Base64;
+import org.apache.commons.codec.binary.Base64;
import org.glassfish.jersey.internal.util.collection.StringKeyIgnoreCaseMultivaluedMap;
import org.json.JSONException;
import org.json.JSONObject;
@@ -115,9 +116,9 @@ public class MRBaseClientTest {
Mockito.when(response.getStatus()).thenReturn(200);
Mockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
Mockito.when(response.getHeaders()).thenReturn(map);
-
+ Base64 base64 = new Base64();
Mockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(), "/path"),
- Base64.encodeAsString("username:password"))).thenReturn(response);
+ base64.encodeAsString(("username:password").getBytes(StandardCharsets.UTF_8)))).thenReturn(response);
JSONObject result = mrBaseClient.get("/path", "username", "password", "HTTPAAF");
assertEquals(200, result.getInt("status"));
@@ -190,9 +191,9 @@ public class MRBaseClientTest {
Mockito.when(response.getStatus()).thenReturn(200);
Mockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
Mockito.when(response.getHeaders()).thenReturn(map);
-
+ Base64 base64 = new Base64();
Mockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(), "/path"),
- Base64.encodeAsString("username:password"))).thenReturn(response);
+ base64.encodeAsString(("username:password").getBytes(StandardCharsets.UTF_8)))).thenReturn(response);
mrBaseClient.getResponse("/path", "username", "password", "HTTPAAF");
assertTrue(true);
@@ -322,9 +323,9 @@ public class MRBaseClientTest {
Mockito.when(response.getStatus()).thenReturn(200);
Mockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
Mockito.when(response.getHeaders()).thenReturn(map);
-
+ Base64 base64 = new Base64();
Mockito.when(DmaapClientUtil.postResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(), "/path"),
- Base64.encodeAsString("username:password"), ("{\"test\":\"test\"}").getBytes(), "application/json")).thenReturn(response);
+ base64.encodeAsString(("username:password").getBytes(StandardCharsets.UTF_8)), ("{\"test\":\"test\"}").getBytes(), "application/json")).thenReturn(response);
mrBaseClient.post("/path", ("{\"test\":\"test\"}").getBytes(), "application/json", "username",
"password", "HTTPAUTH");
@@ -338,10 +339,9 @@ public class MRBaseClientTest {
public void testPost_error() throws JSONException, HttpException {
ResponseBuilder responseBuilder = Response.ok();
- Mockito
- .when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(), "/path"),
- Base64.encodeAsString("username:password")))
- .thenReturn(
+ Base64 base64 = new Base64();
+ Mockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(), "/path"),
+ base64.encodeAsString(("username:password").getBytes(StandardCharsets.UTF_8)))).thenReturn(
responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
mrBaseClient.post("/path", ("{\"test\":\"test\"}").getBytes(), "application/json", null, null,
@@ -396,9 +396,9 @@ public class MRBaseClientTest {
Mockito.when(response.getStatus()).thenReturn(200);
Mockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}");
Mockito.when(response.getHeaders()).thenReturn(map);
-
+ Base64 base64 = new Base64();
Mockito.when(DmaapClientUtil.postResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(), "/path"),
- Base64.encodeAsString("username:password"), ("{\"test\":\"test\"}").getBytes(), "application/json")).thenReturn(response);
+ base64.encodeAsString(("username:password").getBytes(StandardCharsets.UTF_8)), ("{\"test\":\"test\"}").getBytes(), "application/json")).thenReturn(response);
mrBaseClient.postWithResponse("/path", ("{\"test\":\"test\"}").getBytes(), "application/json",
"username", "password", "HTTPAUTH");
@@ -410,11 +410,10 @@ public class MRBaseClientTest {
public void testPostWithResponse_error() throws JSONException, HttpException {
ResponseBuilder responseBuilder = Response.ok();
- Mockito
- .when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(), "/path"),
- Base64.encodeAsString("username:password")))
- .thenReturn(
- responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
+ Base64 base64 = new Base64();
+ Mockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget(getClientConfig(), "/path"),
+ base64.encodeAsString(("username:password").getBytes(StandardCharsets.UTF_8)))).thenReturn(
+ responseBuilder.header("transactionid", "transactionid").entity("{\"test\":\"test\"}").build());
mrBaseClient.postWithResponse("/path", ("{\"test\":\"test\"}").getBytes(), "application/json", null,
null, "HTTPAUTH");