Package fr.paris.lutece.util.jwt.service
Class JWTUtil
java.lang.Object
fr.paris.lutece.util.jwt.service.JWTUtil
Utils class for JWT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringCheck the signature of the JWT with a secret keystatic booleancheckPayloadValues(jakarta.servlet.http.HttpServletRequest request, Key key, String strHeaderName, Map<String, String> claimsToCheck) static booleancheckSignature(jakarta.servlet.http.HttpServletRequest request, String strHeaderName, Key key) Check the JWT signature with provided java security Key: this can be a RSA Public Keystatic booleancheckSignature(String strBase64JWT, Key key) Check a JWT signature with a Java security Keystatic booleancheckUnsecuredPayloadValues(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.static KeyGet a java security Key from a String secretKey and algorithm name
-
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
-
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 requeststrHeaderName- The header namekey- 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 claimsexpirationDate- The expiration datestrAlgo- The algorythm namekey- The key- Returns:
- true if the signature is checked, false otherwise
-
getKey
Get a java security Key from a String secretKey and algorithm name- Parameters:
strSecretKey- The secret KeystrAlgoName- The algorithm name- Returns:
- The java securitySecretKey
-
checkSignature
Check a JWT signature with a Java security Key- Parameters:
strBase64JWT-key-- Returns:
- true if the JWT is checked, false otherwise
-