docs(docstrings): add docstrings to public method interfaces (#25)
All checks were successful
CI / Maven unit tests (push) Successful in 18s
CI / Build and push images (push) Has been skipped
CI / Deploy to server (push) Has been skipped

- Resolves #18

Reviewed-on: #25
This commit was merged in pull request #25.
This commit is contained in:
2026-08-24 16:02:04 +01:00
parent 38942776df
commit ec9a982fe9
31 changed files with 688 additions and 0 deletions

View File

@@ -26,6 +26,12 @@ public class JwtService {
this.algorithm = Algorithm.HMAC256(jwtSecretKey);
}
/**
* Generates a signed JWT carrying the given user ID, valid for the configured expiry.
*
* @param userId the user ID to embed as a claim
* @return the signed JWT string
*/
public String generateToken(Long userId) {
return JWT.create()
.withClaim(USER_ID_CLAIM, userId)
@@ -34,6 +40,12 @@ public class JwtService {
.sign(algorithm);
}
/**
* Verifies a JWT's signature, issuer, and expiry, returning the embedded user ID.
*
* @param token the JWT to validate
* @return the user ID claim if the token is valid and unexpired, otherwise {@code null}
*/
public Long validateTokenAndGetUserId(String token) {
try {
JWTVerifier verifier = JWT.require(algorithm)