Skip to content

Commit

Permalink
Refactor the logic in JwtVendor
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <[email protected]>
  • Loading branch information
RyanL1997 committed Aug 22, 2023
1 parent 267255c commit 387027b
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,12 @@ public String createJwt(

jwtClaims.setNotBefore(timeMillis);

if (expirySeconds == null) {
long expiryTime = timeProvider.getAsLong() + 300;
jwtClaims.setExpiryTime(expiryTime);
} else if (expirySeconds > 0) {
long expiryTime = timeProvider.getAsLong() + expirySeconds;
jwtClaims.setExpiryTime(expiryTime);
} else {
expirySeconds = (expirySeconds == null) ? 300 : expirySeconds;
if (expirySeconds <= 0) {
throw new Exception("The expiration time should be a positive integer");
}
long expiryTime = timeProvider.getAsLong() + expirySeconds;
jwtClaims.setExpiryTime(expiryTime);

if (roles != null) {
String listOfRoles = String.join(",", roles);
Expand Down

0 comments on commit 387027b

Please sign in to comment.