Class JwtService

java.lang.Object
com.eurodyn.qlack.util.jwt.service.JwtService

@Service public class JwtService extends Object
A service allowing creation, validation, and claims management in JWTs.
  • Constructor Details

  • Method Details

    • generateJwt

      public String generateJwt(JwtGenerateRequestDTO request)
      Generates a JWT encapsulating the requested paramaters including any number of custom claims.
      Parameters:
      request - The details of the JWT to be generated.
      Returns:
      Returns a compacted JWT encapsulating the specified details as per JWT Compact Serialization
    • getClaims

      public JwtClaimsDTO getClaims(String jwt)
      Returns the claims of a JWT. This method automatically validates the JWT before a claim is returned.
      Parameters:
      jwt - The compacted JWT to validate.
      Returns:
      Returns the claims of the JWT, or an encapsulated error message explaining what went wrong when trying to validatete the JWT.
    • getRawToken

      public static String getRawToken(jakarta.servlet.http.HttpServletRequest request)
      Extracts the JWT from am `Authorization` HTTP header. The JWT is expected to be prefixed with the word `Bearer`.
      Parameters:
      request - The HttpServletRequest bearing the JWT.