From 4d20c7cb81114d35922ddc29d9251d06faa5e783 Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov <30328539+dimitarndimitrov@users.noreply.github.com> Date: Mon, 17 May 2021 23:23:53 +0200 Subject: [PATCH] Backport "fix: use Java's Base64 instead of jersey's (#6702)" (#7535) Using Jersey's private utility function prevent Jersey upgrades. Also force version consistency for jetty Co-authored-by: Dimitar Dimitrov Co-authored-by: Nitesh Mor --- .../io/confluent/ksql/cli/BasicAuthFunctionalTest.java | 6 ++++-- ksql-engine/pom.xml | 10 ++++++++++ .../ksql/rest/integration/RestIntegrationTestUtil.java | 6 ++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ksql-cli/src/test/java/io/confluent/ksql/cli/BasicAuthFunctionalTest.java b/ksql-cli/src/test/java/io/confluent/ksql/cli/BasicAuthFunctionalTest.java index 46e13e4f16b5..63e78b5645a6 100644 --- a/ksql-cli/src/test/java/io/confluent/ksql/cli/BasicAuthFunctionalTest.java +++ b/ksql-cli/src/test/java/io/confluent/ksql/cli/BasicAuthFunctionalTest.java @@ -32,8 +32,10 @@ import io.confluent.rest.RestConfig; import java.io.IOException; import java.net.URI; +import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Base64; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; @@ -50,7 +52,6 @@ import org.eclipse.jetty.websocket.api.annotations.WebSocket; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; -import org.glassfish.jersey.internal.util.Base64; import org.junit.ClassRule; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -190,7 +191,8 @@ private static Code extractStatusCode(final Throwable message) { } private static String buildBasicAuthHeader(final String userName, final String password) { - return Base64.encodeAsString(userName + ":" + password); + final String creds = userName + ":" + password; + return Base64.getEncoder().encodeToString(creds.getBytes(Charset.defaultCharset())); } private static String createJaasConfigContent() { diff --git a/ksql-engine/pom.xml b/ksql-engine/pom.xml index 24d6cf8d2908..be40a282e279 100644 --- a/ksql-engine/pom.xml +++ b/ksql-engine/pom.xml @@ -144,6 +144,16 @@ test + + + org.eclipse.jetty + jetty-webapp + + ${jetty.version} + test + + diff --git a/ksql-rest-app/src/test/java/io/confluent/ksql/rest/integration/RestIntegrationTestUtil.java b/ksql-rest-app/src/test/java/io/confluent/ksql/rest/integration/RestIntegrationTestUtil.java index 0d2c9d100641..86b1f1045f41 100644 --- a/ksql-rest-app/src/test/java/io/confluent/ksql/rest/integration/RestIntegrationTestUtil.java +++ b/ksql-rest-app/src/test/java/io/confluent/ksql/rest/integration/RestIntegrationTestUtil.java @@ -29,6 +29,8 @@ import io.confluent.ksql.rest.server.TestKsqlRestApp; import io.confluent.ksql.test.util.secure.Credentials; import java.net.URI; +import java.nio.charset.Charset; +import java.util.Base64; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -40,7 +42,6 @@ import javax.ws.rs.core.Response; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; -import org.glassfish.jersey.internal.util.Base64; final class RestIntegrationTestUtil { @@ -149,7 +150,8 @@ public static WebSocketClient makeWsRequest( } private static String buildBasicAuthHeader(final Credentials credentials) { - return Base64.encodeAsString(credentials.username + ":" + credentials.password); + final String creds = credentials.username + ":" + credentials.password; + return Base64.getEncoder().encodeToString(creds.getBytes(Charset.defaultCharset())); } private static String buildStreamingRequest(final String sql) {