From 403df2da94a1d030b249a4b21cc066510b0bfff2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 14 Oct 2023 18:14:11 +0200 Subject: [PATCH] Bump jwt.version from 0.11.5 to 0.12.2 (#468) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bump jwt.version from 0.11.5 to 0.12.2 Bumps `jwt.version` from 0.11.5 to 0.12.2. Updates `io.jsonwebtoken:jjwt-api` from 0.11.5 to 0.12.2 - [Release notes](https://github.com/jwtk/jjwt/releases) - [Changelog](https://github.com/jwtk/jjwt/blob/master/CHANGELOG.md) - [Commits](https://github.com/jwtk/jjwt/compare/0.11.5...0.12.2) Updates `io.jsonwebtoken:jjwt-impl` from 0.11.5 to 0.12.2 - [Release notes](https://github.com/jwtk/jjwt/releases) - [Changelog](https://github.com/jwtk/jjwt/blob/master/CHANGELOG.md) - [Commits](https://github.com/jwtk/jjwt/compare/0.11.5...0.12.2) Updates `io.jsonwebtoken:jjwt-jackson` from 0.11.5 to 0.12.2 --- updated-dependencies: - dependency-name: io.jsonwebtoken:jjwt-api dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: io.jsonwebtoken:jjwt-impl dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: io.jsonwebtoken:jjwt-jackson dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update JWT use for 0.12.2 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Marek Suchánek --- pom.xml | 2 +- .../dtls/fairdatapoint/service/jwt/JwtService.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 274012c0b..a630c3964 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ 5.3.4 4.1.5 4.3.7 - 0.11.5 + 0.12.2 1.18.30 0.1.2-SNAPSHOT diff --git a/src/main/java/nl/dtls/fairdatapoint/service/jwt/JwtService.java b/src/main/java/nl/dtls/fairdatapoint/service/jwt/JwtService.java index db1cfe854..970c286e7 100644 --- a/src/main/java/nl/dtls/fairdatapoint/service/jwt/JwtService.java +++ b/src/main/java/nl/dtls/fairdatapoint/service/jwt/JwtService.java @@ -73,7 +73,7 @@ public class JwtService { protected void init() { secretKey = Base64.getEncoder().encodeToString(secretKey.getBytes()); key = new SecretKeySpec(secretKey.getBytes(), SignatureAlgorithm.HS256.getJcaName()); - parser = Jwts.parserBuilder().setSigningKey(key).build(); + parser = Jwts.parser().setSigningKey(key).build(); } public String createToken(AuthDTO authDTO) { @@ -94,13 +94,13 @@ public Authentication getAuthentication(String token) { } public String getUserUuid(String token) { - return parser.parseClaimsJws(token).getBody().getSubject(); + return parser.parseClaimsJws(token).getPayload().getSubject(); } public boolean validateToken(String token) { try { final Jws claims = parser.parseClaimsJws(token); - return !claims.getBody().getExpiration().before(new Date()); + return !claims.getPayload().getExpiration().before(new Date()); } catch (JwtException | IllegalArgumentException exception) { throw new UnauthorizedException("Expired or invalid JWT token"); @@ -108,13 +108,13 @@ public boolean validateToken(String token) { } private String buildToken(User user) { - final Claims claims = Jwts.claims().setSubject(user.getUuid()); + final Claims claims = Jwts.claims().subject(user.getUuid()).build(); final Date now = new Date(); final Date validity = new Date(now.getTime() + (expiration * DAY_MS)); return Jwts.builder() - .setClaims(claims) - .setIssuedAt(now) - .setExpiration(validity) + .claims(claims) + .issuedAt(now) + .expiration(validity) .signWith(key) .compact(); }