Package org.keycloak.util
Class TokenUtil
- java.lang.Object
- 
- org.keycloak.util.TokenUtil
 
- 
 public class TokenUtil extends Object - Author:
- Marek Posolda
 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringTOKEN_BACKCHANNEL_LOGOUT_EVENTstatic StringTOKEN_BACKCHANNEL_LOGOUT_EVENT_REVOKE_OFFLINE_TOKENSstatic StringTOKEN_TYPE_BEARERstatic StringTOKEN_TYPE_IDstatic StringTOKEN_TYPE_KEYCLOAK_IDstatic StringTOKEN_TYPE_LOGOUTstatic StringTOKEN_TYPE_OFFLINEstatic StringTOKEN_TYPE_REFRESH
 - 
Constructor SummaryConstructors Constructor Description TokenUtil()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static StringattachOIDCScope(String scopeParam)static RefreshTokengetRefreshToken(byte[] decodedToken)Return refresh token or offline tokenstatic RefreshTokengetRefreshToken(String refreshToken)static booleanhasPrompt(String promptParam, String targetPrompt)static booleanhasScope(String scopeParam, String targetScope)static booleanisOfflineToken(String refreshToken)Return true if given refreshToken represents offline tokenstatic booleanisOfflineTokenRequested(String scopeParam)static booleanisOIDCRequest(String scopeParam)static StringjweDirectEncode(Key aesKey, Key hmacKey, byte[] contentBytes)static StringjweDirectEncode(Key aesKey, Key hmacKey, JsonWebToken jwt)static byte[]jweDirectVerifyAndDecode(Key aesKey, Key hmacKey, String jweStr)static <T extends JsonWebToken>
 TjweDirectVerifyAndDecode(Key aesKey, Key hmacKey, String jweStr, Class<T> expectedClass)static StringjweKeyEncryptionEncode(Key encryptionKEK, byte[] contentBytes, String algAlgorithm, String encAlgorithm, String kid, JWEAlgorithmProvider jweAlgorithmProvider, JWEEncryptionProvider jweEncryptionProvider)static StringjweKeyEncryptionEncode(Key encryptionKEK, byte[] contentBytes, String algAlgorithm, String encAlgorithm, String kid, JWEAlgorithmProvider jweAlgorithmProvider, JWEEncryptionProvider jweEncryptionProvider, String jweContentType)static byte[]jweKeyEncryptionVerifyAndDecode(Key decryptionKEK, String encodedContent)static byte[]jweKeyEncryptionVerifyAndDecode(Key decryptionKEK, String encodedContent, JWEAlgorithmProvider algorithmProvider, JWEEncryptionProvider encryptionProvider)
 
- 
- 
- 
Field Detail- 
TOKEN_TYPE_BEARERpublic static final String TOKEN_TYPE_BEARER - See Also:
- Constant Field Values
 
 - 
TOKEN_TYPE_KEYCLOAK_IDpublic static final String TOKEN_TYPE_KEYCLOAK_ID - See Also:
- Constant Field Values
 
 - 
TOKEN_TYPE_IDpublic static final String TOKEN_TYPE_ID - See Also:
- Constant Field Values
 
 - 
TOKEN_TYPE_REFRESHpublic static final String TOKEN_TYPE_REFRESH - See Also:
- Constant Field Values
 
 - 
TOKEN_TYPE_OFFLINEpublic static final String TOKEN_TYPE_OFFLINE - See Also:
- Constant Field Values
 
 - 
TOKEN_TYPE_LOGOUTpublic static final String TOKEN_TYPE_LOGOUT - See Also:
- Constant Field Values
 
 - 
TOKEN_BACKCHANNEL_LOGOUT_EVENTpublic static final String TOKEN_BACKCHANNEL_LOGOUT_EVENT - See Also:
- Constant Field Values
 
 - 
TOKEN_BACKCHANNEL_LOGOUT_EVENT_REVOKE_OFFLINE_TOKENSpublic static final String TOKEN_BACKCHANNEL_LOGOUT_EVENT_REVOKE_OFFLINE_TOKENS - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
isOIDCRequestpublic static boolean isOIDCRequest(String scopeParam) 
 - 
isOfflineTokenRequestedpublic static boolean isOfflineTokenRequested(String scopeParam) 
 - 
getRefreshTokenpublic static RefreshToken getRefreshToken(byte[] decodedToken) throws JWSInputException Return refresh token or offline token- Parameters:
- decodedToken-
- Returns:
- Throws:
- JWSInputException
 
 - 
getRefreshTokenpublic static RefreshToken getRefreshToken(String refreshToken) throws JWSInputException - Throws:
- JWSInputException
 
 - 
isOfflineTokenpublic static boolean isOfflineToken(String refreshToken) throws JWSInputException Return true if given refreshToken represents offline token- Parameters:
- refreshToken-
- Returns:
- Throws:
- JWSInputException
 
 - 
jweDirectEncodepublic static String jweDirectEncode(Key aesKey, Key hmacKey, JsonWebToken jwt) throws JWEException - Throws:
- JWEException
 
 - 
jweDirectVerifyAndDecodepublic static <T extends JsonWebToken> T jweDirectVerifyAndDecode(Key aesKey, Key hmacKey, String jweStr, Class<T> expectedClass) throws JWEException - Throws:
- JWEException
 
 - 
jweKeyEncryptionEncodepublic static String jweKeyEncryptionEncode(Key encryptionKEK, byte[] contentBytes, String algAlgorithm, String encAlgorithm, String kid, JWEAlgorithmProvider jweAlgorithmProvider, JWEEncryptionProvider jweEncryptionProvider) throws JWEException - Throws:
- JWEException
 
 - 
jweKeyEncryptionEncodepublic static String jweKeyEncryptionEncode(Key encryptionKEK, byte[] contentBytes, String algAlgorithm, String encAlgorithm, String kid, JWEAlgorithmProvider jweAlgorithmProvider, JWEEncryptionProvider jweEncryptionProvider, String jweContentType) throws JWEException - Throws:
- JWEException
 
 - 
jweKeyEncryptionVerifyAndDecodepublic static byte[] jweKeyEncryptionVerifyAndDecode(Key decryptionKEK, String encodedContent) throws JWEException - Throws:
- JWEException
 
 - 
jweKeyEncryptionVerifyAndDecodepublic static byte[] jweKeyEncryptionVerifyAndDecode(Key decryptionKEK, String encodedContent, JWEAlgorithmProvider algorithmProvider, JWEEncryptionProvider encryptionProvider) throws JWEException - Throws:
- JWEException
 
 - 
jweDirectEncodepublic static String jweDirectEncode(Key aesKey, Key hmacKey, byte[] contentBytes) throws JWEException - Throws:
- JWEException
 
 - 
jweDirectVerifyAndDecodepublic static byte[] jweDirectVerifyAndDecode(Key aesKey, Key hmacKey, String jweStr) throws JWEException - Throws:
- JWEException
 
 
- 
 
-