Skip to content

Commit

Permalink
remove all jedis config and dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
atakavci committed Dec 12, 2024
1 parent 457d4af commit 2ab345f
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 273 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/entraid_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ jobs:
working-directory: ./entraid
steps:
- uses: actions/checkout@v2
- name: Checkout Jedis repository (tba_draft branch)
uses: actions/checkout@v2
with:
repository: atakavci/jedis # Replace with the actual jedis repository URL
ref: ali/authx2
path: jedis # Check out into a subdirectory named `jedis` so it's isolated

- name: Set up publishing to maven central
uses: actions/setup-java@v2
Expand All @@ -56,15 +50,6 @@ jobs:
mvn clean install -DskipTests # Skip tests for faster builds, but you can remove the flag if needed
working-directory: ./core

- name: Maven offline-jedis
run: |
mvn -q dependency:go-offline
working-directory: ./jedis
- name: Build and install Jedis supports TBA into local repo
run: |
mvn clean install -DskipTests # Skip tests for faster builds, but you can remove the flag if needed
working-directory: ./jedis

- name: Build docs
run: |
mvn javadoc:jar
Expand Down
8 changes: 1 addition & 7 deletions entraid/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,7 @@
<artifactId>msal4j</artifactId>
<version>1.17.2</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>5.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,140 +1 @@
package redis.clients.authentication;

import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

import redis.clients.jedis.DefaultJedisClientConfig;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.util.JedisURIHelper;

import java.io.FileReader;
import java.net.URI;
import java.util.*;

public class EndpointConfig {

private final boolean tls;
private final String username;
private final String password;
private final int bdbId;
private final List<URI> endpoints;

public EndpointConfig(HostAndPort hnp, String username, String password, boolean tls) {
this.tls = tls;
this.username = username;
this.password = password;
this.bdbId = 0;
this.endpoints = Collections.singletonList(
URI.create(getURISchema(tls) + hnp.getHost() + ":" + hnp.getPort()));
}

public HostAndPort getHostAndPort() {
return JedisURIHelper.getHostAndPort(endpoints.get(0));
}

public HostAndPort getHostAndPort(int index) {
return JedisURIHelper.getHostAndPort(endpoints.get(index));
}

public String getPassword() {
return password;
}

public String getUsername() {
return username == null? "default" : username;
}

public String getHost() {
return getHostAndPort().getHost();
}

public int getPort() {
return getHostAndPort().getPort();
}

public int getBdbId() { return bdbId; }

public URI getURI() {
return endpoints.get(0);
}

public class EndpointURIBuilder {
private boolean tls;

private String username;

private String password;

private String path;

public EndpointURIBuilder() {
this.username = "";
this.password = "";
this.path = "";
this.tls = EndpointConfig.this.tls;
}

public EndpointURIBuilder defaultCredentials() {
this.username = EndpointConfig.this.username == null ? "" : getUsername();
this.password = EndpointConfig.this.getPassword();
return this;
}

public EndpointURIBuilder tls(boolean v) {
this.tls = v;
return this;
}

public EndpointURIBuilder path(String v) {
this.path = v;
return this;
}

public EndpointURIBuilder credentials(String u, String p) {
this.username = u;
this.password = p;
return this;
}

public URI build() {
String userInfo = !(this.username.isEmpty() && this.password.isEmpty()) ?
this.username + ':' + this.password + '@' :
"";
return URI.create(
getURISchema(this.tls) + userInfo + getHost() + ":" + getPort() + this.path);
}
}

public EndpointURIBuilder getURIBuilder() {
return new EndpointURIBuilder();
}

public DefaultJedisClientConfig.Builder getClientConfigBuilder() {
DefaultJedisClientConfig.Builder builder = DefaultJedisClientConfig.builder()
.password(password).ssl(tls);

if (username != null) {
return builder.user(username);
}

return builder;
}

protected String getURISchema(boolean tls) {
return (tls ? "rediss" : "redis") + "://";
}

public static HashMap<String, EndpointConfig> loadFromJSON(String filePath) throws Exception {
Gson gson = new GsonBuilder().setFieldNamingPolicy(
FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();

HashMap<String, EndpointConfig> configs;
try (FileReader reader = new FileReader(filePath)) {
configs = gson.fromJson(reader, new TypeToken<HashMap<String, EndpointConfig>>() {
}.getType());
}
return configs;
}
}
//
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@
import redis.clients.authentication.entraid.ServicePrincipalInfo;
import redis.clients.authentication.entraid.ManagedIdentityInfo.UserManagedIdentityType;

// import redis.clients.jedis.DefaultJedisClientConfig;
// import redis.clients.jedis.HostAndPort;
// import redis.clients.jedis.JedisPooled;

public class EntraIDUnitTests {

private static final float EXPIRATION_REFRESH_RATIO = 0.7F;
Expand Down
107 changes: 0 additions & 107 deletions entraid/src/test/resources/endpoints.json

This file was deleted.

0 comments on commit 2ab345f

Please sign in to comment.