Complete the code to create a JWT token with a subject.
String token = Jwts.builder().setSubject([1]).compact();The setSubject method requires a string value representing the subject of the token. It must be a string literal or variable containing a string.
Complete the code to sign the JWT token with a secret key.
String token = Jwts.builder().signWith([1]).compact();The signWith method requires a Key object, which can be created using Keys.secretKeyFor(SignatureAlgorithm.HS256) to generate a secure key.
Fix the error in setting the expiration date for the JWT token.
Date expiryDate = new Date(System.currentTimeMillis() [1] 3600000);
To set the expiration one hour from now, add 3600000 milliseconds (1 hour) to the current time.
Fill both blanks to add claims and set expiration in the JWT builder.
String token = Jwts.builder().claim("role", [1]).setExpiration([2]).compact();
The claim value should be a string like "admin". The expiration should be a Date object like expiryDate representing the expiration time.
Fill all three blanks to build a JWT token with subject, claim, and expiration.
String token = Jwts.builder().setSubject([1]).claim("scope", [2]).setExpiration([3]).compact();
The subject is a string like "user42". The claim value for "scope" is a string like "read:write". The expiration is a Date object like expiryDate.