diff --git a/src/main/java/redis/clients/jedis/authentication/AuthXManager.java b/src/main/java/redis/clients/jedis/authentication/AuthXManager.java index a4363e712e..eba5d8428f 100644 --- a/src/main/java/redis/clients/jedis/authentication/AuthXManager.java +++ b/src/main/java/redis/clients/jedis/authentication/AuthXManager.java @@ -47,6 +47,7 @@ public void start() { try { safeStarter.get(); } catch (InterruptedException | ExecutionException e) { + log.error("AuthXManager failed to start!", e); throw new JedisAuthenticationException("AuthXManager failed to start!", (e instanceof ExecutionException) ? e.getCause() : e); } diff --git a/src/main/java/redis/clients/jedis/authentication/TokenCredentials.java b/src/main/java/redis/clients/jedis/authentication/TokenCredentials.java index 471c34bc40..143ee60b9d 100644 --- a/src/main/java/redis/clients/jedis/authentication/TokenCredentials.java +++ b/src/main/java/redis/clients/jedis/authentication/TokenCredentials.java @@ -8,7 +8,7 @@ class TokenCredentials implements RedisCredentials { private final char[] password; public TokenCredentials(Token token) { - user = token.tryGet("oid"); + user = token.getUser(); password = token.getValue().toCharArray(); } diff --git a/src/test/java/redis/clients/jedis/authentication/RedisEntraIDIntegrationTests.java b/src/test/java/redis/clients/jedis/authentication/RedisEntraIDIntegrationTests.java index d57e0da3d2..fa920e1daa 100644 --- a/src/test/java/redis/clients/jedis/authentication/RedisEntraIDIntegrationTests.java +++ b/src/test/java/redis/clients/jedis/authentication/RedisEntraIDIntegrationTests.java @@ -18,7 +18,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.UUID; @@ -96,8 +95,8 @@ public void testJedisConfig() { assertNotNull(mock); doAnswer(invocation -> { counter.incrementAndGet(); - return new SimpleToken("token1", System.currentTimeMillis() + 5 * 60 * 1000, - System.currentTimeMillis(), Collections.singletonMap("oid", "default")); + return new SimpleToken("default", "token1", System.currentTimeMillis() + 5 * 60 * 1000, + System.currentTimeMillis(), null); }).when(mock).requestToken(); })) { @@ -312,9 +311,8 @@ public void connectionAuthWithExpiredTokenTest() { jedis.del(key); } - token - .set(new SimpleToken("token1", System.currentTimeMillis() - 1, System.currentTimeMillis(), - Collections.singletonMap("oid", idp.requestToken().tryGet("oid")))); + token.set(new SimpleToken(idp.requestToken().getUser(), "token1", + System.currentTimeMillis() - 1, System.currentTimeMillis(), null)); JedisAccessControlException aclException = assertThrows(JedisAccessControlException.class, () -> { diff --git a/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationClusterIntegrationTests.java b/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationClusterIntegrationTests.java index 2b6e4e3256..cd7e8eb6f4 100644 --- a/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationClusterIntegrationTests.java +++ b/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationClusterIntegrationTests.java @@ -45,9 +45,9 @@ public IdentityProvider getProvider() { return new IdentityProvider() { @Override public Token requestToken() { - return new SimpleToken("cluster", System.currentTimeMillis() + 5 * 1000, - System.currentTimeMillis(), - Collections.singletonMap("oid", "default")); + return new SimpleToken("default", "cluster", + System.currentTimeMillis() + 5 * 1000, System.currentTimeMillis(), + null); } }; } @@ -77,9 +77,9 @@ public IdentityProvider getProvider() { return new IdentityProvider() { @Override public Token requestToken() { - return new SimpleToken("cluster", System.currentTimeMillis() + 5 * 1000, - System.currentTimeMillis(), - Collections.singletonMap("oid", "default")); + return new SimpleToken("default", "cluster", + System.currentTimeMillis() + 5 * 1000, System.currentTimeMillis(), + null); } }; } diff --git a/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationIntegrationTests.java b/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationIntegrationTests.java index 780c82c781..b9fcfa8218 100644 --- a/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationIntegrationTests.java +++ b/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationIntegrationTests.java @@ -8,7 +8,6 @@ import static org.hamcrest.Matchers.contains; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.StreamSupport; @@ -64,8 +63,8 @@ public void testJedisPooledForInitialAuth() { IdentityProvider idProvider = mock(IdentityProvider.class); when(idProvider.requestToken()) - .thenReturn(new SimpleToken(password, System.currentTimeMillis() + 100000, - System.currentTimeMillis(), Collections.singletonMap("oid", user))); + .thenReturn(new SimpleToken(user, password, System.currentTimeMillis() + 100000, + System.currentTimeMillis(), null)); IdentityProviderConfig idProviderConfig = mock(IdentityProviderConfig.class); when(idProviderConfig.getProvider()).thenReturn(idProvider); diff --git a/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationUnitTests.java b/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationUnitTests.java index 699dc47f31..eb345fffc6 100644 --- a/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationUnitTests.java +++ b/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationUnitTests.java @@ -63,7 +63,7 @@ public void withExpirationRefreshRatio_testJedisAuthXManagerTriggersEvict() thro IdentityProvider idProvider = mock(IdentityProvider.class); when(idProvider.requestToken()) - .thenReturn(new SimpleToken("password", System.currentTimeMillis() + 1000, + .thenReturn(new SimpleToken("default","password", System.currentTimeMillis() + 1000, System.currentTimeMillis(), Collections.singletonMap("oid", "default"))); TokenManager tokenManager = new TokenManager(idProvider, @@ -88,7 +88,7 @@ public void withLowerRefreshBounds_testJedisAuthXManagerTriggersEvict() throws E IdentityProvider idProvider = mock(IdentityProvider.class); when(idProvider.requestToken()) - .thenReturn(new SimpleToken("password", System.currentTimeMillis() + 1000, + .thenReturn(new SimpleToken("default","password", System.currentTimeMillis() + 1000, System.currentTimeMillis(), Collections.singletonMap("oid", "default"))); TokenManager tokenManager = new TokenManager(idProvider, @@ -205,7 +205,7 @@ public void testCalculateRenewalDelay() { public void testAuthXManagerReceivesNewToken() throws InterruptedException, ExecutionException, TimeoutException { - IdentityProvider identityProvider = () -> new SimpleToken("tokenVal", + IdentityProvider identityProvider = () -> new SimpleToken("user1","tokenVal", System.currentTimeMillis() + 5 * 1000, System.currentTimeMillis(), Collections.singletonMap("oid", "user1")); @@ -277,7 +277,7 @@ public void testTokenManagerWithFailingTokenRequest() if (requesLatch.getCount() > 0) { throw new RuntimeException("Test exception from identity provider!"); } - return new SimpleToken("tokenValX", System.currentTimeMillis() + 50 * 1000, + return new SimpleToken("user1","tokenValX", System.currentTimeMillis() + 50 * 1000, System.currentTimeMillis(), Collections.singletonMap("oid", "user1")); }); @@ -313,7 +313,7 @@ public void testTokenManagerWithHangingTokenRequest() } return null; } - return new SimpleToken("tokenValX", System.currentTimeMillis() + tokenLifetime, + return new SimpleToken("user1","tokenValX", System.currentTimeMillis() + tokenLifetime, System.currentTimeMillis(), Collections.singletonMap("oid", "user1")); };