-
Hey! I noticed that compression/decompression does not work when passing arbitrary content instead of claims. The compression is not done at all, but the Sample code below:
Is this supposed to work? If not, maybe the builder shouldn't allow calling In this example, the
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Can be worked around by manually compressing the content: public static void main(final String[] args) {
var secretKey = Jwts.ENC.A128GCM.key().build();
var content = "hello, world!";
final byte[] compressedContent;
try (final var out = new ByteArrayOutputStream()) {
try (final var def = Jwts.ZIP.DEF.compress(out)) {
def.write(content.getBytes(StandardCharsets.UTF_8));
}
compressedContent = out.toByteArray();
}
var encodedJwe = Jwts
.builder()
.content(compressedContent)
.compressWith(Jwts.ZIP.DEF)
.encryptWith(secretKey, Jwts.ENC.A128GCM)
.compact();
System.out.println("encodedJwe: " + encodedJwe);
var decodedJwe = Jwts.parser().decryptWith(secretKey).build().parseEncryptedContent(encodedJwe);
System.out.println("decodedJwe: " + decodedJwe);
System.out.println("decodedJwe.payload: " + new String(decodedJwe.getPayload(), StandardCharsets.UTF_8));
} |
Beta Was this translation helpful? Give feedback.
-
Hmm-m. I don't find anywhere in the JWE spec (or from JJWT docs) that it says that this shouldn't be supported. I created a PR to fix this #937 |
Beta Was this translation helpful? Give feedback.
Hmm-m. I don't find anywhere in the JWE spec (or from JJWT docs) that it says that this shouldn't be supported. I created a PR to fix this #937