Skip to content

Commit

Permalink
Bump jwt.version from 0.11.5 to 0.12.2 (#468)
Browse files Browse the repository at this point in the history
* 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](jwtk/jjwt@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](jwtk/jjwt@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] <[email protected]>

* Update JWT use for 0.12.2

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marek Suchánek <[email protected]>
  • Loading branch information
dependabot[bot] and MarekSuchanek authored Oct 14, 2023
1 parent d1f59cb commit 403df2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<mongock.version>5.3.4</mongock.version>
<mongodb.spring-data.version>4.1.5</mongodb.spring-data.version>
<rdf4j.version>4.3.7</rdf4j.version>
<jwt.version>0.11.5</jwt.version>
<jwt.version>0.12.2</jwt.version>
<lombok.version>1.18.30</lombok.version>
<rdf-resolver.version>0.1.2-SNAPSHOT</rdf-resolver.version>

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/nl/dtls/fairdatapoint/service/jwt/JwtService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -94,27 +94,27 @@ 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> 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");
}
}

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();
}
Expand Down

0 comments on commit 403df2d

Please sign in to comment.