Skip to content

Commit 2e09ae9

Browse files
committed
Time properties renamed
1 parent 5fb2006 commit 2e09ae9

12 files changed

Lines changed: 45 additions & 46 deletions

File tree

vertx-auth-common/src/main/generated/io/vertx/ext/auth/JWTOptionsConverter.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import io.vertx.core.json.JsonObject;
44
import io.vertx.core.json.JsonArray;
55
import io.vertx.core.json.impl.JsonUtil;
6-
import java.time.Instant;
7-
import java.time.format.DateTimeFormatter;
6+
87
import java.util.Base64;
98

109
/**
@@ -50,7 +49,7 @@ public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json,
5049
break;
5150
case "expiresInSeconds":
5251
if (member.getValue() instanceof Number) {
53-
obj.setExpiresInSeconds(((Number)member.getValue()).intValue());
52+
obj.setExpires(((Number)member.getValue()).intValue());
5453
}
5554
break;
5655
case "header":
@@ -115,7 +114,7 @@ public static void toJson(JWTOptions obj, java.util.Map<String, Object> json) {
115114
obj.getAudience().forEach(item -> array.add(item));
116115
json.put("audience", array);
117116
}
118-
json.put("expiresInSeconds", obj.getExpiresInSeconds());
117+
json.put("expiresInSeconds", obj.getExpires());
119118
if (obj.getHeader() != null) {
120119
json.put("header", obj.getHeader());
121120
}

vertx-auth-common/src/main/java/io/vertx/ext/auth/JWTOptions.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class JWTOptions {
1717
private String algorithm = "HS256";
1818
private JsonObject header = EMPTY;
1919
private boolean noTimestamp;
20-
private int expiresInSeconds;
20+
private int expires;
2121
private List<String> audience;
2222
private String issuer;
2323
private String subject;
@@ -33,7 +33,7 @@ public JWTOptions(JWTOptions other) {
3333
this.algorithm = other.algorithm;
3434
this.header = other.header;
3535
this.noTimestamp = other.noTimestamp;
36-
this.expiresInSeconds = other.expiresInSeconds;
36+
this.expires = other.expires;
3737
this.audience = other.audience;
3838
this.issuer = other.issuer;
3939
this.subject = other.subject;
@@ -96,17 +96,17 @@ public JWTOptions setNoTimestamp(boolean noTimestamp) {
9696
return this;
9797
}
9898

99-
public int getExpiresInSeconds() {
100-
return expiresInSeconds;
99+
public int getExpires() {
100+
return expires;
101101
}
102102

103-
public JWTOptions setExpiresInSeconds(int expiresInSeconds) {
104-
this.expiresInSeconds = expiresInSeconds;
103+
public JWTOptions setExpires(int expires) {
104+
this.expires = expires;
105105
return this;
106106
}
107107

108108
public JWTOptions setExpiresInMinutes(int expiresInMinutes) {
109-
this.expiresInSeconds = expiresInMinutes * 60;
109+
this.expires = expiresInMinutes * 60;
110110
return this;
111111
}
112112

vertx-auth-common/src/main/java/io/vertx/ext/auth/impl/jose/JWT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ public String sign(JsonObject payload, JWTOptions options) {
363363
payload.put("iat", payload.getValue("iat", timestamp));
364364
}
365365

366-
if (options.getExpiresInSeconds() > 0) {
367-
payload.put("exp", timestamp + options.getExpiresInSeconds());
366+
if (options.getExpires() > 0) {
367+
payload.put("exp", timestamp + options.getExpires());
368368
}
369369

370370
if (options.getAudience() != null && options.getAudience().size() >= 1) {

vertx-auth-jwt/src/test/java/io/vertx/ext/auth/test/jwt/JWTAuthProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public void testExpiration(TestContext should) {
232232
.put("sub", "Paulo");
233233

234234
final String token = authProvider.generateToken(payload,
235-
new JWTOptions().setExpiresInSeconds(1).setNoTimestamp(true));
235+
new JWTOptions().setExpires(1).setNoTimestamp(true));
236236

237237
should.assertNotNull(token);
238238

@@ -628,7 +628,7 @@ public void testValidateTokenWithIgnoreExpired(TestContext should) throws Interr
628628
.generateToken(
629629
new JsonObject(),
630630
new JWTOptions()
631-
.setExpiresInSeconds(1)
631+
.setExpires(1)
632632
.setSubject("subject")
633633
.setAlgorithm("HS256"));
634634

vertx-auth-oauth2/src/main/generated/io/vertx/ext/auth/oauth2/OAuth2OptionsConverter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json,
7575
obj.setIntrospectionPath((String)member.getValue());
7676
}
7777
break;
78-
case "jwkMaxAgeInSeconds":
78+
case "jwkMaxAge":
7979
if (member.getValue() instanceof Number) {
80-
obj.setJwkMaxAgeInSeconds(((Number)member.getValue()).longValue());
80+
obj.setJwkMaxAge(((Number)member.getValue()).longValue());
8181
}
8282
break;
8383
case "jwkPath":
@@ -207,7 +207,7 @@ public static void toJson(OAuth2Options obj, java.util.Map<String, Object> json)
207207
if (obj.getIntrospectionPath() != null) {
208208
json.put("introspectionPath", obj.getIntrospectionPath());
209209
}
210-
json.put("jwkMaxAgeInSeconds", obj.getJwkMaxAgeInSeconds());
210+
json.put("jwkMaxAge", obj.getJwkMaxAge());
211211
if (obj.getJwkPath() != null) {
212212
json.put("jwkPath", obj.getJwkPath());
213213
}

vertx-auth-oauth2/src/main/java/io/vertx/ext/auth/oauth2/OAuth2Options.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class OAuth2Options {
7070
// JWK path RFC7517
7171
private String jwkPath;
7272
//seconds of JWKs lifetime
73-
private long jwkMaxAgeInSeconds;
73+
private long jwkMaxAge;
7474
// OpenID non standard
7575
private String tenant;
7676

@@ -146,7 +146,7 @@ public OAuth2Options(OAuth2Options other) {
146146
headers = null;
147147
}
148148
jwkPath = other.getJwkPath();
149-
jwkMaxAgeInSeconds = other.getJwkMaxAgeInSeconds();
149+
jwkMaxAge = other.getJwkMaxAge();
150150
httpClientOptions = other.getHttpClientOptions();
151151
userAgent = other.getUserAgent();
152152
supportedGrantTypes = other.getSupportedGrantTypes();
@@ -163,7 +163,7 @@ private void init() {
163163
revocationPath = REVOCATION_PATH;
164164
scopeSeparator = SCOPE_SEPARATOR;
165165
jwtOptions = JWT_OPTIONS;
166-
jwkMaxAgeInSeconds = JWK_DEFAULT_AGE;
166+
jwkMaxAge = JWK_DEFAULT_AGE;
167167
}
168168

169169
/**
@@ -557,15 +557,15 @@ public OAuth2Options setTenant(String tenant) {
557557

558558
@Deprecated
559559
public boolean isRotateJWKs() {
560-
return jwkMaxAgeInSeconds != -1L;
560+
return jwkMaxAge != -1L;
561561
}
562562

563563
/**
564564
* Enable/Disable the JWKs rotation.
565565
*
566566
* @param rotateJWKs {@code true} to rotate keys as described in {@link OAuth2Auth#jWKSet(Handler)}.
567567
* @return self
568-
* @deprecated use {@link #setJwkMaxAgeInSeconds(long)} instead
568+
* @deprecated use {@link #setJwkMaxAge(long)} instead
569569
*/
570570
@Deprecated
571571
public OAuth2Options setRotateJWKs(boolean rotateJWKs) {
@@ -703,16 +703,16 @@ public OAuth2Options setHttpClientOptions(HttpClientOptions httpClientOptions) {
703703
return this;
704704
}
705705

706-
public long getJwkMaxAgeInSeconds() {
707-
return jwkMaxAgeInSeconds;
706+
public long getJwkMaxAge() {
707+
return jwkMaxAge;
708708
}
709709

710710
/**
711711
* -1 means no rotation for JWKs
712712
*
713-
* @param jwkMaxAgeInSeconds timeout of JWKs rotation
713+
* @param jwkMaxAge timeout of JWKs rotation
714714
*/
715-
public void setJwkMaxAgeInSeconds(long jwkMaxAgeInSeconds) {
716-
this.jwkMaxAgeInSeconds = jwkMaxAgeInSeconds;
715+
public void setJwkMaxAge(long jwkMaxAge) {
716+
this.jwkMaxAge = jwkMaxAge;
717717
}
718718
}

vertx-auth-oauth2/src/main/java/io/vertx/ext/auth/oauth2/impl/OAuth2AuthProviderImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public Future<Void> jWKSet() {
137137
// ensure that leeway is never negative
138138
int leeway = max(0, config.getJWTOptions().getLeeway());
139139
// delay is in ms, while cache max age is sec
140-
final long delay = json.getLong("maxAge", config.getJwkMaxAgeInSeconds()) * 1000 - leeway;
140+
final long delay = json.getLong("maxAge", config.getJwkMaxAge()) * 1000 - leeway;
141141
// salesforce (for example) sometimes disables the max-age as setting it to 0
142142
// for these cases we just cancel
143143
if (delay > 0) {

vertx-auth-webauthn/src/main/generated/io/vertx/ext/auth/webauthn/WebAuthnOptionsConverter.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import io.vertx.core.json.JsonObject;
44
import io.vertx.core.json.JsonArray;
55
import io.vertx.core.json.impl.JsonUtil;
6-
import java.time.Instant;
7-
import java.time.format.DateTimeFormatter;
6+
87
import java.util.Base64;
98

109
/**
@@ -82,7 +81,7 @@ public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json,
8281
break;
8382
case "timeout":
8483
if (member.getValue() instanceof Number) {
85-
obj.setTimeout(((Number)member.getValue()).longValue());
84+
obj.setTimeoutInMilliseconds(((Number)member.getValue()).longValue());
8685
}
8786
break;
8887
case "transports":
@@ -128,8 +127,8 @@ public static void toJson(WebAuthnOptions obj, java.util.Map<String, Object> jso
128127
json.put("relyingParty", obj.getRelyingParty().toJson());
129128
}
130129
json.put("requireResidentKey", obj.getRequireResidentKey());
131-
if (obj.getTimeout() != null) {
132-
json.put("timeout", obj.getTimeout());
130+
if (obj.getTimeoutInMilliseconds() != null) {
131+
json.put("timeout", obj.getTimeoutInMilliseconds());
133132
}
134133
if (obj.getTransports() != null) {
135134
JsonArray array = new JsonArray();

vertx-auth-webauthn/src/main/java/io/vertx/ext/auth/webauthn/WebAuthnOptions.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public class WebAuthnOptions {
191191
private boolean requireResidentKey;
192192
private UserVerification userVerification;
193193

194-
private Long timeout;
194+
private Long timeoutInMilliseconds;
195195
private Attestation attestation;
196196

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

223-
timeout = 60_000L;
223+
timeoutInMilliseconds = 60_000L;
224224
challengeLength = 64;
225225
// Support FIDO2 devices, MACOSX, default
226226
addPubKeyCredParam(ES256);
@@ -361,17 +361,18 @@ public WebAuthnOptions setUserVerification(UserVerification userVerification) {
361361
return this;
362362
}
363363

364-
public Long getTimeout() {
365-
return timeout;
364+
//ms
365+
public Long getTimeoutInMilliseconds() {
366+
return timeoutInMilliseconds;
366367
}
367368

368-
public WebAuthnOptions setTimeout(Long timeout) {
369-
if (timeout != null) {
370-
if (timeout < 0) {
369+
public WebAuthnOptions setTimeoutInMilliseconds(Long timeoutInMilliseconds) {
370+
if (timeoutInMilliseconds != null) {
371+
if (timeoutInMilliseconds < 0) {
371372
throw new IllegalArgumentException("Timeout must be >= 0");
372373
}
373374
}
374-
this.timeout = timeout;
375+
this.timeoutInMilliseconds = timeoutInMilliseconds;
375376
return this;
376377
}
377378

vertx-auth-webauthn/src/main/java/io/vertx/ext/auth/webauthn/impl/WebAuthnImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public Future<JsonObject> createCredentialsOptions(JsonObject user) {
190190
.put("type", "public-key"));
191191
}
192192
// optional timeout
193-
putOpt(json, "timeout", options.getTimeout());
193+
putOpt(json, "timeout", options.getTimeoutInMilliseconds());
194194
// optional excluded credentials
195195
if (!authenticators.isEmpty()) {
196196
JsonArray transports = new JsonArray();
@@ -231,7 +231,7 @@ public Future<JsonObject> getCredentialsOptions(String name) {
231231
// https://w3c.github.io/webauthn/#dictionary-assertion-options
232232
JsonObject json = new JsonObject()
233233
.put("challenge", randomBase64URLBuffer(options.getChallengeLength()));
234-
putOpt(json, "timeout", options.getTimeout());
234+
putOpt(json, "timeout", options.getTimeoutInMilliseconds());
235235
putOpt(json, "rpId", options.getRelyingParty().getId());
236236
putOpt(json, "userVerification", options.getUserVerification());
237237
putOpt(json, "extensions", options.getExtensions());

0 commit comments

Comments
 (0)