Complete the code to extract the token from the HTTP header.
String token = request.getHeader([1]);The token is usually sent in the Authorization header in stateless authentication.
Complete the code to validate the JWT token signature.
boolean isValid = jwtUtil.validateToken([1]);The token string is passed to the validation method to check its signature and claims.
Fix the error in the code to set the authentication in the security context.
SecurityContextHolder.getContext().setAuthentication([1]);The authenticationToken object represents the authenticated user and must be set in the security context.
Fill both blanks to create a JWT token with a subject and expiration.
String jwt = Jwts.builder().setSubject([1]).setExpiration([2]).compact();
The username is set as the subject, and the expiration is set to one hour from now.
Fill both blanks to extract username, check expiration, and get claims from JWT.
Claims claims = Jwts.parser().setSigningKey(secretKey).parseClaimsJws([1]).getBody(); String username = claims.getSubject(); boolean expired = claims.getExpiration().[2](new Date());
The token is parsed to get claims. The expiration date is checked if it is before the current date to determine if expired.