JJWT Implementation module providing concrete implementations of JSON Web Token (JWT) creation, parsing, verification, and cryptographic operations for Java and Android applications.
npx @tessl/cli install tessl/maven-io-jsonwebtoken--jjwt-impl@0.12.0The JJWT Implementation module (io.jsonwebtoken:jjwt-impl) provides concrete implementations of JSON Web Token (JWT) creation, parsing, verification, and cryptographic operations for Java and Android applications. This module works in conjunction with the JJWT API module to deliver a complete JWT/JWS/JWE solution.
| Property | Value |
|---|---|
| Package Name | io.jsonwebtoken:jjwt-impl |
| Type | Maven Dependency |
| Language | Java |
| Version | 0.12.6 |
| License | Apache 2.0 |
| JDK Support | Java 8+ |
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.12.6</version>
<scope>runtime</scope>
</dependency>
<!-- Also include the API module -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.12.6</version>
</dependency>// Core JWT Operations
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.JwtParser;
// Token Types
import io.jsonwebtoken.Jwt;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwe;
import io.jsonwebtoken.Claims;
// Security
import io.jsonwebtoken.security.Keys;
import io.jsonwebtoken.security.SecureDigestAlgorithm;
import io.jsonwebtoken.security.AeadAlgorithm;
import io.jsonwebtoken.security.KeyAlgorithm;
// JWK Support
import io.jsonwebtoken.security.Jwk;
import io.jsonwebtoken.security.JwkSet;
// Standard Java
import javax.crypto.SecretKey;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Date;// Create a secret key for HMAC signing
SecretKey key = Jwts.SIG.HS256.key().build();
// Create a simple JWT with claims
String jwt = Jwts.builder()
.subject("john.doe")
.issuer("my-app")
.issuedAt(new Date())
.expiration(new Date(System.currentTimeMillis() + 3600000)) // 1 hour
.signWith(key)
.compact();
// Create a JWT with custom claims
String customJwt = Jwts.builder()
.claims()
.subject("user123")
.add("role", "admin")
.add("permissions", Arrays.asList("read", "write"))
.and()
.signWith(key)
.compact();// Parse and verify a signed JWT
JwtParser parser = Jwts.parser()
.verifyWith(key)
.build();
Jws<Claims> jws = parser.parseSignedClaims(jwt);
Claims claims = jws.getPayload();
String subject = claims.getSubject();
String issuer = claims.getIssuer();
Date expiration = claims.getExpiration();
// Access custom claims
String role = claims.get("role", String.class);
List<String> permissions = claims.get("permissions", List.class);// Use different signature algorithms
SecretKey hmacKey = Jwts.SIG.HS512.key().build();
KeyPair rsaKeyPair = Jwts.SIG.RS256.keyPair().build();
KeyPair ecKeyPair = Jwts.SIG.ES256.keyPair().build();
// Create JWS with different algorithms
String hmacJwt = Jwts.builder()
.subject("user")
.signWith(hmacKey, Jwts.SIG.HS512)
.compact();
String rsaJwt = Jwts.builder()
.subject("user")
.signWith(rsaKeyPair.getPrivate(), Jwts.SIG.RS256)
.compact();
// Parse with corresponding verification keys
Jws<Claims> hmacClaims = Jwts.parser()
.verifyWith(hmacKey)
.build()
.parseSignedClaims(hmacJwt);
Jws<Claims> rsaClaims = Jwts.parser()
.verifyWith(rsaKeyPair.getPublic())
.build()
.parseSignedClaims(rsaJwt);The JJWT Implementation module is organized into several key packages:
io.jsonwebtoken.impl)io.jsonwebtoken.impl.security)io.jsonwebtoken.impl.compression)Comprehensive JWT, JWS, and JWE token creation with the DefaultJwtBuilder class.
// Quick example - full JWT creation with encryption
SecretKey encKey = Jwts.ENC.A256GCM.key().build();
SecretKey kekKey = Jwts.KEY.A256KW.key().build();
String jwe = Jwts.builder()
.subject("sensitive-user")
.claim("ssn", "123-45-6789")
.encryptWith(kekKey, Jwts.KEY.A256KW, Jwts.ENC.A256GCM)
.compact();Flexible JWT, JWS, and JWE token parsing and validation with DefaultJwtParser.
// Quick example - parsing with clock skew tolerance
JwtParser parser = Jwts.parser()
.decryptWith(kekKey)
.clockSkewSeconds(30) // Allow 30 seconds clock skew
.build();
Jwe<Claims> jwe = parser.parseEncryptedClaims(encryptedJwt);Complete JWA-compliant algorithm implementations for signatures, encryption, and key management.
// Quick example - algorithm discovery and key generation
SecureDigestAlgorithm<?, ?> signAlg = Jwts.SIG.get().forKey(someKey);
SecretKey newKey = signAlg.key().build();Full JSON Web Key (JWK) and JWK Set functionality with RFC 7517 compliance.
// Quick example - JWK creation and parsing
Jwk<SecretKey> jwk = Jwts.JWK.builder(secretKey)
.id("my-key-1")
.operations().add("sign").add("verify").and()
.build();
String jwkJson = jwk.toJson();Payload compression support with DEFLATE and GZIP algorithms.
// Quick example - compressed JWT
String compressed = Jwts.builder()
.subject("user")
.claim("data", largeDataString)
.compressWith(Jwts.ZIP.DEF)
.signWith(key)
.compact();Essential utilities including cryptographic key management, Base64URL encoding, stream processing, and service discovery.
// Quick example - secure key generation
SecretKey hmacKey = Keys.hmacShaKeyFor(secureRandomBytes);
Password password = Keys.password("secret".toCharArray());
// Base64URL operations
Base64UrlCodec codec = new Base64UrlCodec();
String encoded = codec.encode("Hello World");
byte[] decoded = codec.decode(encoded);This implementation module provides the complete runtime functionality for JWT operations while maintaining clean separation from the API definitions, enabling flexible deployment and testing scenarios.