Skip to content

Commit

Permalink
fix: use Java's Base64 instead of jersey's (#6702)
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
  • Loading branch information
niteshmor authored Dec 2, 2020
1 parent dd9449f commit f9fb523
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,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.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand All @@ -53,7 +55,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 @@ -203,7 +204,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 @@ -168,6 +168,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 @@ -37,6 +37,8 @@
import io.confluent.ksql.test.util.secure.Credentials;
import io.confluent.rest.validation.JacksonMessageBodyProvider;
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 @@ -49,7 +51,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 @@ -232,7 +233,8 @@ 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
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,13 @@
<artifactId>wiremock-jre8</artifactId>
<version>${wiremock.version}</version>
<scope>test</scope>
<exclusions>
<!-- To avoid multiple versions of jetty -->
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>
Expand Down

0 comments on commit f9fb523

Please sign in to comment.