Skip to content

Commit

Permalink
Remove okhttp from Pinot connector
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Mar 8, 2024
1 parent 66eede0 commit fdb124e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
12 changes: 0 additions & 12 deletions plugin/trino-pinot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@
<artifactId>protobuf-java</artifactId>
</dependency>

<!-- Used for basic authentication only -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<exclusions>
<exclusion>
<groupId>org.codehaus.mojo</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
package io.trino.plugin.pinot.auth.password;

import io.trino.plugin.pinot.auth.PinotAuthenticationProvider;
import okhttp3.Credentials;

import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Optional;

import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.util.Objects.requireNonNull;

public class PinotPasswordAuthenticationProvider
Expand All @@ -39,8 +39,8 @@ public Optional<String> getAuthenticationToken()
return authToken;
}

private String encode(String username, String password)
public static String encode(String username, String password)
{
return Credentials.basic(username, password, StandardCharsets.ISO_8859_1);
return "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes(ISO_8859_1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io.airlift.http.client.StaticBodyGenerator;
import io.airlift.http.client.jetty.JettyHttpClient;
import io.airlift.json.JsonCodec;
import okhttp3.Credentials;
import io.trino.plugin.pinot.auth.password.PinotPasswordAuthenticationProvider;
import org.apache.http.Header;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicHeader;
Expand All @@ -45,7 +45,6 @@
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
Expand Down Expand Up @@ -308,7 +307,7 @@ private static <T> T doWithRetries(Supplier<T> supplier, int retries)
private static String controllerAuthToken()
{
// Secrets defined in pinot-controller-secured.conf
return Credentials.basic("admin", "verysecret", StandardCharsets.ISO_8859_1);
return PinotPasswordAuthenticationProvider.encode("admin", "verysecret");
}

public static class PinotSuccessResponse
Expand Down

0 comments on commit fdb124e

Please sign in to comment.