Class JWTUtil

java.lang.Object
fr.paris.lutece.util.jwt.service.JWTUtil

public class JWTUtil extends Object
Utils class for JWT
  • Constructor Details

    • JWTUtil

      public JWTUtil()
  • Method Details

    • checkUnsecuredPayloadValues

      @Deprecated public static boolean checkUnsecuredPayloadValues(jakarta.servlet.http.HttpServletRequest request, String strHeaderName, Map<String,String> claimsToCheck)
      Deprecated.
      This method should not be used because there is no control over the signature of the token.
      Checks claims key/value inside the JWT payload
      Parameters:
      request -
      strHeaderName -
      claimsToCheck -
      Returns:
      true if the key/values are present, false otherwise
    • checkPayloadValues

      public static boolean checkPayloadValues(jakarta.servlet.http.HttpServletRequest request, Key key, String strHeaderName, Map<String,String> claimsToCheck)
    • checkSignature

      public static boolean checkSignature(jakarta.servlet.http.HttpServletRequest request, String strHeaderName, Key key)
      Check the JWT signature with provided java security Key: this can be a RSA Public Key
      Parameters:
      request - The request
      strHeaderName - The header name
      key - The key
      Returns:
      true if the signature of the JWT is checked; false otherwise
    • buildBase64JWT

      public static String buildBase64JWT(Map<String,String> mapClaims, Date expirationDate, String strAlgo, Key key)
      Check the signature of the JWT with a secret key
      Parameters:
      mapClaims - The map of claims
      expirationDate - The expiration date
      strAlgo - The algorythm name
      key - The key
      Returns:
      true if the signature is checked, false otherwise
    • getKey

      public static Key getKey(String strSecretKey, String strAlgoName)
      Get a java security Key from a String secretKey and algorithm name
      Parameters:
      strSecretKey - The secret Key
      strAlgoName - The algorithm name
      Returns:
      The java securitySecretKey
    • checkSignature

      public static boolean checkSignature(String strBase64JWT, Key key)
      Check a JWT signature with a Java security Key
      Parameters:
      strBase64JWT -
      key -
      Returns:
      true if the JWT is checked, false otherwise