Complete the code to create a JWT token with a secret key.
String token = Jwts.builder().setSubject(user.getUsername()).signWith([1]).compact();Use Keys.secretKeyFor(SignatureAlgorithm.HS256) to generate a secure secret key for signing the JWT.
Complete the code to store user info in HTTP session.
HttpSession session = request.getSession(); session.setAttribute("[1]", user);
The attribute name user is commonly used to store the user object in session.
Fix the error in the JWT validation code by completing the missing method.
Jwts.parserBuilder().setSigningKey([1]).build().parseClaimsJws(token);The setSigningKey method requires the secret key used to sign the token for validation.
Fill both blanks to configure session timeout and secure cookie.
session.setMaxInactiveInterval([1]); response.addCookie(new Cookie("JSESSIONID", [2]));
Set session timeout to 1800 seconds (30 minutes) and add a secure cookie value.
Fill all three blanks to create a JWT with claims and expiration.
String jwt = Jwts.builder().setSubject([1]).claim("role", [2]).setExpiration([3]).signWith(secretKey).compact();
Use the username as subject, set role claim to "admin", and expiration to 1 hour from now.
