Skip to content

Commit

Permalink
Token should lazily load default value from configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
robdu committed Sep 1, 2020
1 parent ff5215f commit 235b9a3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/main/java/com/codingchili/core/security/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public class Token implements Serializable {
private Map<String, Object> properties = new HashMap<>();
private String domain = UUID.randomUUID().toString();
private String key = "";
private long expiry = Instant.now().getEpochSecond() +
Configurations.security().getTokenttl();
private Long expiry;

/**
* Creates a new empty unverified token.
Expand Down Expand Up @@ -55,6 +54,10 @@ public Token setKey(String key) {
* @return the time of expiry in epoch seconds.
*/
public long getExpiry() {
if (expiry == null) {
expiry = Instant.now().getEpochSecond() +
Configurations.security().getTokenttl();
}
return expiry;
}

Expand Down

0 comments on commit 235b9a3

Please sign in to comment.