Skip to content

Commit

Permalink
Backport "fix: use Java's Base64 instead of jersey's (#6702)" (#7535)
Browse files Browse the repository at this point in the history
Using Jersey's private utility function prevent Jersey upgrades.
Also force version consistency for jetty

Co-authored-by: Dimitar Dimitrov <[email protected]>
Co-authored-by: Nitesh Mor <[email protected]>
  • Loading branch information
3 people authored May 17, 2021
1 parent b09a13f commit 4d20c7c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
10 changes: 10 additions & 0 deletions ksql-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@
<scope>test</scope>
</dependency>

<!-- Transitive dependency of wiremock-jre8 that's excluded in ksql-parent pom.xml
because it brings an older version of jetty than we'd like -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<!-- jetty.version definition comes from rest-utils -->
<version>${jetty.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4d20c7c

Please sign in to comment.