Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use Java's Base64 instead of jersey's #6702

Merged
merged 2 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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