A. Incorrect method to set signing key in new jjwt versions
B. Missing call to build() before compact()
C. Username should not be set as subject
D. Missing token expiration setting
Solution
Step 1: Check jjwt signing method usage
In recent jjwt versions, signWith requires a Key object, not just algorithm and string key.
Step 2: Identify correct signing method
Using signWith(SignatureAlgorithm, String) is deprecated and causes errors; must use signWith(Key).
Final Answer:
Incorrect method to set signing key in new jjwt versions -> Option A
Quick Check:
Use Key object with signWith in jjwt [OK]
Hint: Use Key object, not algorithm + string, in signWith [OK]
Common Mistakes:
Ignoring jjwt version changes
Assuming string key is accepted directly
Confusing expiration with signing errors
5. You want to implement JWT authentication in Spring Boot that automatically rejects tokens older than 15 minutes and refreshes tokens on each valid request. Which approach correctly combines expiration and refresh logic?
hard
A. Set token expiration to 15 minutes and issue a new token with updated expiration on each valid request
B. Set token expiration to 15 minutes and never refresh tokens; force user to login again after expiry
C. Set token expiration to 1 hour and refresh tokens only when user logs out
D. Do not set expiration and refresh tokens every time to keep user logged in indefinitely
Solution
Step 1: Understand token expiration and refresh needs
To reject tokens older than 15 minutes, set expiration to 15 minutes.
Step 2: Implement refresh on each valid request
Issuing a new token with updated expiration on each valid request keeps user session active securely.
Final Answer:
Set token expiration to 15 minutes and issue a new token with updated expiration on each valid request -> Option A
Quick Check:
Short expiration + refresh token = secure session [OK]
Hint: Short expiration plus refresh token on requests [OK]
Common Mistakes:
Not refreshing tokens causing forced logouts
Setting too long expiration risking security
Ignoring expiration causing infinite sessions
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.