Skip to content

Commit f03c05b

Browse files
committed
fix: use Long for numeric TTL fields (#103) (#104)
Mapping these fields as Integer limits the possible maximum TTL value to roughly 68 years. This may or may not be a reasonable value, but is technically a valid number in the JSON response. Convert all TTL-related fields to Long, so we can map such values.
1 parent afdad92 commit f03c05b

File tree

14 files changed

+64
-61
lines changed

14 files changed

+64
-61
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
### Dependencies
44
* Updated Jackson to 2.19.1 (#101)
55

6+
### Fix
7+
* Use `Long` for numeric TTL fields (#103) (#104)
8+
69
### Test
710
* Tested against Vault 1.2 to 1.20 (#102)
811

src/main/java/de/stklcode/jvault/connector/model/AppRole.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
@JsonIgnoreProperties(ignoreUnknown = true)
3434
public final class AppRole implements Serializable {
35-
private static final long serialVersionUID = 693228837510483448L;
35+
private static final long serialVersionUID = 1546673231280751679L;
3636

3737
@JsonProperty("role_name")
3838
private String name;
@@ -53,19 +53,19 @@ public final class AppRole implements Serializable {
5353

5454
@JsonProperty("secret_id_ttl")
5555
@JsonInclude(JsonInclude.Include.NON_NULL)
56-
private Integer secretIdTtl;
56+
private Long secretIdTtl;
5757

5858
@JsonProperty("local_secret_ids")
5959
@JsonInclude(JsonInclude.Include.NON_NULL)
6060
private Boolean localSecretIds;
6161

6262
@JsonProperty("token_ttl")
6363
@JsonInclude(JsonInclude.Include.NON_NULL)
64-
private Integer tokenTtl;
64+
private Long tokenTtl;
6565

6666
@JsonProperty("token_max_ttl")
6767
@JsonInclude(JsonInclude.Include.NON_NULL)
68-
private Integer tokenMaxTtl;
68+
private Long tokenMaxTtl;
6969

7070
private List<String> tokenPolicies;
7171

@@ -75,7 +75,7 @@ public final class AppRole implements Serializable {
7575

7676
@JsonProperty("token_explicit_max_ttl")
7777
@JsonInclude(JsonInclude.Include.NON_NULL)
78-
private Integer tokenExplicitMaxTtl;
78+
private Long tokenExplicitMaxTtl;
7979

8080
@JsonProperty("token_no_default_policy")
8181
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -255,7 +255,7 @@ public Integer getSecretIdNumUses() {
255255
/**
256256
* @return maximum TTL in seconds for secrets
257257
*/
258-
public Integer getSecretIdTtl() {
258+
public Long getSecretIdTtl() {
259259
return secretIdTtl;
260260
}
261261

@@ -271,22 +271,22 @@ public Boolean getLocalSecretIds() {
271271
/**
272272
* @return token TTL in seconds
273273
*/
274-
public Integer getTokenTtl() {
274+
public Long getTokenTtl() {
275275
return tokenTtl;
276276
}
277277

278278
/**
279279
* @return maximum token TTL in seconds, including renewals
280280
*/
281-
public Integer getTokenMaxTtl() {
281+
public Long getTokenMaxTtl() {
282282
return tokenMaxTtl;
283283
}
284284

285285
/**
286286
* @return explicit maximum token TTL in seconds, including renewals
287287
* @since 0.9
288288
*/
289-
public Integer getTokenExplicitMaxTtl() {
289+
public Long getTokenExplicitMaxTtl() {
290290
return tokenExplicitMaxTtl;
291291
}
292292

@@ -370,12 +370,12 @@ public static final class Builder {
370370
private List<String> secretIdBoundCidrs;
371371
private List<String> tokenPolicies;
372372
private Integer secretIdNumUses;
373-
private Integer secretIdTtl;
373+
private Long secretIdTtl;
374374
private Boolean localSecretIds;
375-
private Integer tokenTtl;
376-
private Integer tokenMaxTtl;
375+
private Long tokenTtl;
376+
private Long tokenMaxTtl;
377377
private List<String> tokenBoundCidrs;
378-
private Integer tokenExplicitMaxTtl;
378+
private Long tokenExplicitMaxTtl;
379379
private Boolean tokenNoDefaultPolicy;
380380
private Integer tokenNumUses;
381381
private Integer tokenPeriod;
@@ -520,7 +520,7 @@ public Builder withSecretIdNumUses(final Integer secretIdNumUses) {
520520
* @param secretIdTtl the TTL
521521
* @return self
522522
*/
523-
public Builder withSecretIdTtl(final Integer secretIdTtl) {
523+
public Builder withSecretIdTtl(final Long secretIdTtl) {
524524
this.secretIdTtl = secretIdTtl;
525525
return this;
526526
}
@@ -544,7 +544,7 @@ public Builder withLocalSecretIds(final Boolean localSecretIds) {
544544
* @param tokenTtl the TTL
545545
* @return self
546546
*/
547-
public Builder withTokenTtl(final Integer tokenTtl) {
547+
public Builder withTokenTtl(final Long tokenTtl) {
548548
this.tokenTtl = tokenTtl;
549549
return this;
550550
}
@@ -555,7 +555,7 @@ public Builder withTokenTtl(final Integer tokenTtl) {
555555
* @param tokenMaxTtl the TTL
556556
* @return self
557557
*/
558-
public Builder withTokenMaxTtl(final Integer tokenMaxTtl) {
558+
public Builder withTokenMaxTtl(final Long tokenMaxTtl) {
559559
this.tokenMaxTtl = tokenMaxTtl;
560560
return this;
561561
}
@@ -596,7 +596,7 @@ public Builder withTokenBoundCidr(final String tokenBoundCidr) {
596596
* @param tokenExplicitMaxTtl the TTL
597597
* @return self
598598
*/
599-
public Builder withTokenExplicitMaxTtl(final Integer tokenExplicitMaxTtl) {
599+
public Builder withTokenExplicitMaxTtl(final Long tokenExplicitMaxTtl) {
600600
this.tokenExplicitMaxTtl = tokenExplicitMaxTtl;
601601
return this;
602602
}

src/main/java/de/stklcode/jvault/connector/model/Token.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
@JsonIgnoreProperties(ignoreUnknown = true)
3434
public final class Token implements Serializable {
35-
private static final long serialVersionUID = 5208508683665365287L;
35+
private static final long serialVersionUID = 7003016071684507115L;
3636

3737
@JsonProperty("id")
3838
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -56,11 +56,11 @@ public final class Token implements Serializable {
5656

5757
@JsonProperty("ttl")
5858
@JsonInclude(JsonInclude.Include.NON_NULL)
59-
private Integer ttl;
59+
private Long ttl;
6060

6161
@JsonProperty("explicit_max_ttl")
6262
@JsonInclude(JsonInclude.Include.NON_NULL)
63-
private Integer explicitMaxTtl;
63+
private Long explicitMaxTtl;
6464

6565
@JsonProperty("num_uses")
6666
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -162,15 +162,15 @@ public Boolean getNoDefaultPolicy() {
162162
/**
163163
* @return Time-to-live in seconds
164164
*/
165-
public Integer getTtl() {
165+
public Long getTtl() {
166166
return ttl;
167167
}
168168

169169
/**
170170
* @return Explicit maximum time-to-live in seconds
171171
* @since 0.9
172172
*/
173-
public Integer getExplicitMaxTtl() {
173+
public Long getExplicitMaxTtl() {
174174
return explicitMaxTtl;
175175
}
176176

@@ -282,8 +282,8 @@ public static final class Builder {
282282
private String displayName;
283283
private Boolean noParent;
284284
private Boolean noDefaultPolicy;
285-
private Integer ttl;
286-
private Integer explicitMaxTtl;
285+
private Long ttl;
286+
private Long explicitMaxTtl;
287287
private Integer numUses;
288288
private List<String> policies;
289289
private Map<String, String> meta;
@@ -331,7 +331,7 @@ public Builder withDisplayName(final String displayName) {
331331
* @param ttl the ttl
332332
* @return self
333333
*/
334-
public Builder withTtl(final Integer ttl) {
334+
public Builder withTtl(final Long ttl) {
335335
this.ttl = ttl;
336336
return this;
337337
}
@@ -342,7 +342,7 @@ public Builder withTtl(final Integer ttl) {
342342
* @param explicitMaxTtl the explicit max. TTL
343343
* @return self
344344
*/
345-
public Builder withExplicitMaxTtl(final Integer explicitMaxTtl) {
345+
public Builder withExplicitMaxTtl(final Long explicitMaxTtl) {
346346
this.explicitMaxTtl = explicitMaxTtl;
347347
return this;
348348
}

src/main/java/de/stklcode/jvault/connector/model/TokenRole.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
@JsonIgnoreProperties(ignoreUnknown = true)
3636
public final class TokenRole implements Serializable {
37-
private static final long serialVersionUID = -3505215215838576321L;
37+
private static final long serialVersionUID = -4856948364869438439L;
3838

3939
@JsonProperty("name")
4040
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -78,7 +78,7 @@ public final class TokenRole implements Serializable {
7878

7979
@JsonProperty("token_explicit_max_ttl")
8080
@JsonInclude(JsonInclude.Include.NON_NULL)
81-
private Integer tokenExplicitMaxTtl;
81+
private Long tokenExplicitMaxTtl;
8282

8383
@JsonProperty("token_no_default_policy")
8484
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -204,7 +204,7 @@ public List<String> getTokenBoundCidrs() {
204204
/**
205205
* @return Token explicit maximum TTL
206206
*/
207-
public Integer getTokenExplicitMaxTtl() {
207+
public Long getTokenExplicitMaxTtl() {
208208
return tokenExplicitMaxTtl;
209209
}
210210

@@ -285,7 +285,7 @@ public static final class Builder {
285285
private String pathSuffix;
286286
private List<String> allowedEntityAliases;
287287
private List<String> tokenBoundCidrs;
288-
private Integer tokenExplicitMaxTtl;
288+
private Long tokenExplicitMaxTtl;
289289
private Boolean tokenNoDefaultPolicy;
290290
private Integer tokenNumUses;
291291
private Integer tokenPeriod;
@@ -537,7 +537,7 @@ public Builder withTokenBoundCidrs(final List<String> tokenBoundCidrs) {
537537
* @param tokenExplicitMaxTtl explicit maximum TTL
538538
* @return self
539539
*/
540-
public Builder withTokenExplicitMaxTtl(final Integer tokenExplicitMaxTtl) {
540+
public Builder withTokenExplicitMaxTtl(final Long tokenExplicitMaxTtl) {
541541
this.tokenExplicitMaxTtl = tokenExplicitMaxTtl;
542542
return this;
543543
}

src/main/java/de/stklcode/jvault/connector/model/response/embedded/MountConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*/
1616
@JsonIgnoreProperties(ignoreUnknown = true)
1717
public class MountConfig implements Serializable {
18-
private static final long serialVersionUID = -8653909672663717792L;
18+
private static final long serialVersionUID = 7241631159224756605L;
1919

2020
@JsonProperty("default_lease_ttl")
21-
private Integer defaultLeaseTtl;
21+
private Long defaultLeaseTtl;
2222

2323
@JsonProperty("max_lease_ttl")
24-
private Integer maxLeaseTtl;
24+
private Long maxLeaseTtl;
2525

2626
@JsonProperty("force_no_cache")
2727
private Boolean forceNoCache;
@@ -56,14 +56,14 @@ public class MountConfig implements Serializable {
5656
/**
5757
* @return Default lease TTL
5858
*/
59-
public Integer getDefaultLeaseTtl() {
59+
public Long getDefaultLeaseTtl() {
6060
return defaultLeaseTtl;
6161
}
6262

6363
/**
6464
* @return Maximum lease TTL
6565
*/
66-
public Integer getMaxLeaseTtl() {
66+
public Long getMaxLeaseTtl() {
6767
return maxLeaseTtl;
6868
}
6969

src/main/java/de/stklcode/jvault/connector/model/response/embedded/TokenData.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
@JsonIgnoreProperties(ignoreUnknown = true)
3636
public final class TokenData implements Serializable {
37-
private static final long serialVersionUID = -5749716740973138916L;
37+
private static final long serialVersionUID = -4168046151053509784L;
3838

3939
@JsonProperty("accessor")
4040
private String accessor;
@@ -43,7 +43,7 @@ public final class TokenData implements Serializable {
4343
private Integer creationTime;
4444

4545
@JsonProperty("creation_ttl")
46-
private Integer creationTtl;
46+
private Long creationTtl;
4747

4848
@JsonProperty("display_name")
4949
private String name;
@@ -55,7 +55,7 @@ public final class TokenData implements Serializable {
5555
private ZonedDateTime expireTime;
5656

5757
@JsonProperty("explicit_max_ttl")
58-
private Integer explicitMaxTtl;
58+
private Long explicitMaxTtl;
5959

6060
@JsonProperty("id")
6161
private String id;
@@ -82,7 +82,7 @@ public final class TokenData implements Serializable {
8282
private boolean renewable;
8383

8484
@JsonProperty("ttl")
85-
private Integer ttl;
85+
private Long ttl;
8686

8787
@JsonProperty("type")
8888
private String type;
@@ -104,7 +104,7 @@ public Integer getCreationTime() {
104104
/**
105105
* @return Creation TTL (in seconds)
106106
*/
107-
public Integer getCreationTtl() {
107+
public Long getCreationTtl() {
108108
return creationTtl;
109109
}
110110

@@ -135,7 +135,7 @@ public ZonedDateTime getExpireTime() {
135135
* @return Explicit maximum TTL
136136
* @since 0.9
137137
*/
138-
public Integer getExplicitMaxTtl() {
138+
public Long getExplicitMaxTtl() {
139139
return explicitMaxTtl;
140140
}
141141

@@ -202,7 +202,7 @@ public boolean isRenewable() {
202202
/**
203203
* @return Token TTL (in seconds)
204204
*/
205-
public Integer getTtl() {
205+
public Long getTtl() {
206206
return ttl;
207207
}
208208

src/test/java/de/stklcode/jvault/connector/HTTPVaultConnectorIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ void createTokenTest() {
862862
.withDefaultPolicy()
863863
.withMeta("test", "success")
864864
.withMeta("key", "value")
865-
.withTtl(1234)
865+
.withTtl(1234L)
866866
.build();
867867
InvalidResponseException e = assertThrows(
868868
InvalidResponseException.class,

src/test/java/de/stklcode/jvault/connector/model/AppRoleTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class AppRoleTest extends AbstractModelTest<AppRole> {
4242
private static final String POLICY = "policy";
4343
private static final String POLICY_2 = "policy2";
4444
private static final Integer SECRET_ID_NUM_USES = 10;
45-
private static final Integer SECRET_ID_TTL = 7200;
45+
private static final Long SECRET_ID_TTL = 7200L;
4646
private static final Boolean LOCAL_SECRET_IDS = false;
47-
private static final Integer TOKEN_TTL = 4800;
48-
private static final Integer TOKEN_MAX_TTL = 9600;
49-
private static final Integer TOKEN_EXPLICIT_MAX_TTL = 14400;
47+
private static final Long TOKEN_TTL = 4800L;
48+
private static final Long TOKEN_MAX_TTL = 9600L;
49+
private static final Long TOKEN_EXPLICIT_MAX_TTL = 14400L;
5050
private static final Boolean TOKEN_NO_DEFAULT_POLICY = false;
5151
private static final Integer TOKEN_NUM_USES = 42;
5252
private static final Integer TOKEN_PERIOD = 1234;

src/test/java/de/stklcode/jvault/connector/model/TokenRoleTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class TokenRoleTest extends AbstractModelTest<TokenRole> {
5959
private static final String TOKEN_BOUND_CIDR_2 = "198.51.100.0/24";
6060
private static final String TOKEN_BOUND_CIDR_3 = "203.0.113.0/24";
6161
private static final List<String> TOKEN_BOUND_CIDRS = Arrays.asList(TOKEN_BOUND_CIDR_2, TOKEN_BOUND_CIDR_1);
62-
private static final Integer TOKEN_EXPLICIT_MAX_TTL = 1234;
62+
private static final Long TOKEN_EXPLICIT_MAX_TTL = 1234L;
6363
private static final Boolean TOKEN_NO_DEFAULT_POLICY = false;
6464
private static final Integer TOKEN_NUM_USES = 5;
6565
private static final Integer TOKEN_PERIOD = 2345;

src/test/java/de/stklcode/jvault/connector/model/TokenTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class TokenTest extends AbstractModelTest<Token> {
3535
private static final String DISPLAY_NAME = "display-name";
3636
private static final Boolean NO_PARENT = false;
3737
private static final Boolean NO_DEFAULT_POLICY = false;
38-
private static final Integer TTL = 123;
39-
private static final Integer EXPLICIT_MAX_TTL = 456;
38+
private static final Long TTL = 123L;
39+
private static final Long EXPLICIT_MAX_TTL = 456L;
4040
private static final Integer NUM_USES = 4;
4141
private static final List<String> POLICIES = new ArrayList<>();
4242
private static final String POLICY = "policy";

0 commit comments

Comments
 (0)