1

I am trying to generate JWE using JJWT in Java.

As per the documentation https://github.com/jwtk/jjwt#creating-a-jwe there has to be an encryptWith method in JwtBuilder class but I am not able to find it and I am using the latest available version with JDK 8

implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'

Currently, I am using JWS and want to replace it with JWE

String token = Jwts.builder().setClaims(claims).setIssuer(jwtIssuer)
                .setIssuedAt(Date.from(currentTime.atZone(ZoneId.systemDefault()).toInstant()))
                .setExpiration(Date
                        .from(currentTime.plusMinutes(accessTokenExpiryMin).atZone(ZoneId.systemDefault()).toInstant()))
                .signWith(getSigningKey()).compact();

How to use the encryptWith method? Am I missing something?

Thanks in advance.

Shashank Gupta
  • 321
  • 3
  • 15
  • 1
    The latest release is 0.11.5 which was released last year. but the `encryptWith` method was added on 19 May 2023. you should download the latest code and compile it locally. – exudong Jun 16 '23 at 08:26

0 Answers0