Skip to content

Commit

Permalink
Review update
Browse files Browse the repository at this point in the history
  • Loading branch information
Vorimo committed Jul 19, 2022
1 parent 2e09ae9 commit db45112
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json,
break;
case "expiresInSeconds":
if (member.getValue() instanceof Number) {
obj.setExpires(((Number)member.getValue()).intValue());
obj.setExpiresInSeconds(((Number)member.getValue()).intValue());
}
break;
case "header":
Expand Down Expand Up @@ -114,7 +114,7 @@ public static void toJson(JWTOptions obj, java.util.Map<String, Object> json) {
obj.getAudience().forEach(item -> array.add(item));
json.put("audience", array);
}
json.put("expiresInSeconds", obj.getExpires());
json.put("expiresInSeconds", obj.getExpiresInSeconds());
if (obj.getHeader() != null) {
json.put("header", obj.getHeader());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ public JWTOptions setNoTimestamp(boolean noTimestamp) {
return this;
}

public int getExpires() {
public int getExpiresInSeconds() {
return expires;
}

public JWTOptions setExpires(int expires) {
public JWTOptions setExpiresInSeconds(int expires) {
this.expires = expires;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ public String sign(JsonObject payload, JWTOptions options) {
payload.put("iat", payload.getValue("iat", timestamp));
}

if (options.getExpires() > 0) {
payload.put("exp", timestamp + options.getExpires());
if (options.getExpiresInSeconds() > 0) {
payload.put("exp", timestamp + options.getExpiresInSeconds());
}

if (options.getAudience() != null && options.getAudience().size() >= 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void testExpiration(TestContext should) {
.put("sub", "Paulo");

final String token = authProvider.generateToken(payload,
new JWTOptions().setExpires(1).setNoTimestamp(true));
new JWTOptions().setExpiresInSeconds(1).setNoTimestamp(true));

should.assertNotNull(token);

Expand Down Expand Up @@ -628,7 +628,7 @@ public void testValidateTokenWithIgnoreExpired(TestContext should) throws Interr
.generateToken(
new JsonObject(),
new JWTOptions()
.setExpires(1)
.setExpiresInSeconds(1)
.setSubject("subject")
.setAlgorithm("HS256"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json,
obj.setIntrospectionPath((String)member.getValue());
}
break;
case "jwkMaxAge":
case "jwkMaxAgeInSeconds":
if (member.getValue() instanceof Number) {
obj.setJwkMaxAge(((Number)member.getValue()).longValue());
obj.setJwkMaxAgeInSeconds(((Number)member.getValue()).longValue());
}
break;
case "jwkPath":
Expand Down Expand Up @@ -207,7 +207,7 @@ public static void toJson(OAuth2Options obj, java.util.Map<String, Object> json)
if (obj.getIntrospectionPath() != null) {
json.put("introspectionPath", obj.getIntrospectionPath());
}
json.put("jwkMaxAge", obj.getJwkMaxAge());
json.put("jwkMaxAgeInSeconds", obj.getJwkMaxAgeInSeconds());
if (obj.getJwkPath() != null) {
json.put("jwkPath", obj.getJwkPath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public OAuth2Options(OAuth2Options other) {
headers = null;
}
jwkPath = other.getJwkPath();
jwkMaxAge = other.getJwkMaxAge();
jwkMaxAge = other.getJwkMaxAgeInSeconds();
httpClientOptions = other.getHttpClientOptions();
userAgent = other.getUserAgent();
supportedGrantTypes = other.getSupportedGrantTypes();
Expand Down Expand Up @@ -565,7 +565,7 @@ public boolean isRotateJWKs() {
*
* @param rotateJWKs {@code true} to rotate keys as described in {@link OAuth2Auth#jWKSet(Handler)}.
* @return self
* @deprecated use {@link #setJwkMaxAge(long)} instead
* @deprecated use {@link #setJwkMaxAgeInSeconds(long)} instead
*/
@Deprecated
public OAuth2Options setRotateJWKs(boolean rotateJWKs) {
Expand Down Expand Up @@ -703,16 +703,16 @@ public OAuth2Options setHttpClientOptions(HttpClientOptions httpClientOptions) {
return this;
}

public long getJwkMaxAge() {
public long getJwkMaxAgeInSeconds() {
return jwkMaxAge;
}

/**
* -1 means no rotation for JWKs
*
* @param jwkMaxAge timeout of JWKs rotation
* @param jwkMaxAgeInSeconds timeout of JWKs rotation
*/
public void setJwkMaxAge(long jwkMaxAge) {
this.jwkMaxAge = jwkMaxAge;
public void setJwkMaxAgeInSeconds(long jwkMaxAgeInSeconds) {
this.jwkMaxAge = jwkMaxAgeInSeconds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public Future<Void> jWKSet() {
// ensure that leeway is never negative
int leeway = max(0, config.getJWTOptions().getLeeway());
// delay is in ms, while cache max age is sec
final long delay = json.getLong("maxAge", config.getJwkMaxAge()) * 1000 - leeway;
final long delay = json.getLong("maxAge", config.getJwkMaxAgeInSeconds()) * 1000 - leeway;
// salesforce (for example) sometimes disables the max-age as setting it to 0
// for these cases we just cancel
if (delay > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public class WebAuthnOptions {
private boolean requireResidentKey;
private UserVerification userVerification;

private Long timeoutInMilliseconds;
private Long timeout;
private Attestation attestation;

// Needs to be a list, order is important
Expand Down Expand Up @@ -220,7 +220,7 @@ private void init() {
extensions = new JsonObject()
.put("txAuthSimple", "");

timeoutInMilliseconds = 60_000L;
timeout = 60_000L;
challengeLength = 64;
// Support FIDO2 devices, MACOSX, default
addPubKeyCredParam(ES256);
Expand Down Expand Up @@ -361,9 +361,8 @@ public WebAuthnOptions setUserVerification(UserVerification userVerification) {
return this;
}

//ms
public Long getTimeoutInMilliseconds() {
return timeoutInMilliseconds;
return timeout;
}

public WebAuthnOptions setTimeoutInMilliseconds(Long timeoutInMilliseconds) {
Expand All @@ -372,7 +371,7 @@ public WebAuthnOptions setTimeoutInMilliseconds(Long timeoutInMilliseconds) {
throw new IllegalArgumentException("Timeout must be >= 0");
}
}
this.timeoutInMilliseconds = timeoutInMilliseconds;
this.timeout = timeoutInMilliseconds;
return this;
}

Expand Down

0 comments on commit db45112

Please sign in to comment.