Skip to content
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
15 changes: 11 additions & 4 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,19 @@
</configuration>
</plugin>
<plugin>
<groupId>com.googlecode.maven-java-formatter-plugin</groupId>
<artifactId>maven-java-formatter-plugin</artifactId>
<version>0.4</version>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.16.0</version>
<configuration>
<configFile>${project.basedir}/hbase-formatter.xml</configFile>
<configFile>${project.basedir}/../hbase-formatter.xml</configFile>
</configuration>
<executions>
<execution>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
package redis.clients.authentication.core;

public interface IdentityProvider {

Token requestToken();
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public RenewalScheduler(Supplier<Token> renewToken) {
*/
public RenewalTask scheduleNext(long delay) {
// Schedule the task to run after the given delay
lastTask = new RenewalTask(
scheduler.schedule(() -> renewToken.get(), delay, TimeUnit.MILLISECONDS));
lastTask = new RenewalTask(scheduler.schedule(() -> renewToken.get(), delay, TimeUnit.MILLISECONDS));
return lastTask;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public class SimpleToken implements Token {
private long receivedAt;
private Map<String, ?> claims;

public SimpleToken(String user, String value, long expiresAt, long receivedAt,
Map<String, ?> claims) {
public SimpleToken(String user, String value, long expiresAt, long receivedAt, Map<String, ?> claims) {
this.user = user;
this.value = value;
this.expiresAt = expiresAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public class TokenAuthConfig {
private TokenManagerConfig tokenManagerConfig;
private IdentityProviderConfig identityProviderConfig;

public TokenAuthConfig(TokenManagerConfig tokenManagerConfig,
IdentityProviderConfig identityProviderConfig) {
public TokenAuthConfig(TokenManagerConfig tokenManagerConfig, IdentityProviderConfig identityProviderConfig) {
this.tokenManagerConfig = tokenManagerConfig;
this.identityProviderConfig = identityProviderConfig;
}
Expand Down Expand Up @@ -68,18 +67,17 @@ public T identityProviderConfig(IdentityProviderConfig identityProviderConfig) {
}

public TokenAuthConfig build() {
return new TokenAuthConfig(new TokenManagerConfig(expirationRefreshRatio,
lowerRefreshBoundMillis, tokenRequestExecTimeoutInMs,
new TokenManagerConfig.RetryPolicy(maxAttemptsToRetry, delayInMsToRetry)),
return new TokenAuthConfig(
new TokenManagerConfig(expirationRefreshRatio, lowerRefreshBoundMillis, tokenRequestExecTimeoutInMs,
new TokenManagerConfig.RetryPolicy(maxAttemptsToRetry, delayInMsToRetry)),
identityProviderConfig);
}

public static Builder from(Builder sample) {
return new Builder().expirationRefreshRatio(sample.expirationRefreshRatio)
.lowerRefreshBoundMillis(sample.lowerRefreshBoundMillis)
.tokenRequestExecTimeoutInMs(sample.tokenRequestExecTimeoutInMs)
.maxAttemptsToRetry(sample.maxAttemptsToRetry)
.delayInMsToRetry(sample.delayInMsToRetry)
.maxAttemptsToRetry(sample.maxAttemptsToRetry).delayInMsToRetry(sample.delayInMsToRetry)
.identityProviderConfig(sample.identityProviderConfig);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package redis.clients.authentication.core;

public interface TokenListener {

void onTokenRenewed(Token newToken);

void onError(Exception reason);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public TokenManager(IdentityProvider identityProvider, TokenManagerConfig tokenM
maxRetries = tokenManagerConfig.getRetryPolicy().getMaxAttempts();
retryDelay = tokenManagerConfig.getRetryPolicy().getdelayInMs();
renewalScheduler = new RenewalScheduler(this::renewToken);
dispatcher = new Dispatcher(identityProvider,
tokenManagerConfig.getTokenRequestExecTimeoutInMs());
dispatcher = new Dispatcher(identityProvider, tokenManagerConfig.getTokenRequestExecTimeoutInMs());
}

/**
Expand Down Expand Up @@ -158,8 +157,7 @@ protected long ttlForLowerRefresh(long expireDate) {
*/
protected long ttlForRatioRefresh(long expireDate, long issueDate) {
long totalLifetime = expireDate - issueDate;
long intendedUsageDuration = (long) (totalLifetime
* tokenManagerConfig.getExpirationRefreshRatio());
long intendedUsageDuration = (long) (totalLifetime * tokenManagerConfig.getExpirationRefreshRatio());
long startOfRenewalZone = issueDate + intendedUsageDuration;
return startOfRenewalZone - System.currentTimeMillis(); // TTL to renewal zone
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ private static String getMessage(Exception identityProviderFailedWith) {
if (identityProviderFailedWith == null) {
return msg;
}
return msg + " Identity provider request failed!"
+ identityProviderFailedWith.getMessage();
return msg + " Identity provider request failed!" + identityProviderFailedWith.getMessage();
}

}
Loading
Loading