Top Fields Constructors Methods
org.keycloak.util

public Class TokenUtil

extends Object
Class Inheritance
Imports
org.keycloak.OAuth2Constants, org.keycloak.jose.jwe.JWE, .JWEConstants, .JWEException, .JWEHeader, .JWEKeyStorage, org.keycloak.jose.jwe.alg.JWEAlgorithmProvider, org.keycloak.jose.jwe.enc.JWEEncryptionProvider, org.keycloak.jose.jws.JWSInput, .JWSInputException, org.keycloak.representations.JsonWebToken, .RefreshToken, java.io.IOException, java.security.Key

Author
Marek Posolda

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String
attachOIDCScope(String scopeParam)

public static RefreshToken
getRefreshToken(byte[] decodedToken)

Return refresh token or offline token

public static RefreshToken
getRefreshToken(String refreshToken)

public static boolean
hasPrompt(String promptParam, String targetPrompt)

public static boolean
hasScope(String scopeParam, String targetScope)

public static boolean
isOfflineToken(String refreshToken)

Return true if given refreshToken represents offline token

public static boolean
public static boolean
isOIDCRequest(String scopeParam)

public static String
jweDirectEncode(Key aesKey, Key hmacKey, JsonWebToken jwt)

public static String
jweDirectEncode(Key aesKey, Key hmacKey, byte[] contentBytes)

public static <T extends JsonWebToken> T
jweDirectVerifyAndDecode(Key aesKey, Key hmacKey, String jweStr, Class<T> expectedClass)

public static byte[]
jweDirectVerifyAndDecode(Key aesKey, Key hmacKey, String jweStr)

public static String
jweKeyEncryptionEncode(Key encryptionKEK, byte[] contentBytes, String algAlgorithm, String encAlgorithm, String kid, JWEAlgorithmProvider jweAlgorithmProvider, JWEEncryptionProvider jweEncryptionProvider)

public static String
jweKeyEncryptionEncode(Key encryptionKEK, byte[] contentBytes, String algAlgorithm, String encAlgorithm, String kid, JWEAlgorithmProvider jweAlgorithmProvider, JWEEncryptionProvider jweEncryptionProvider, String jweContentType)

private static String
jweKeyEncryptionEncode(Key encryptionKEK, byte[] contentBytes, JWEHeader jweHeader, JWEAlgorithmProvider jweAlgorithmProvider, JWEEncryptionProvider jweEncryptionProvider)

public static byte[]
jweKeyEncryptionVerifyAndDecode(Key decryptionKEK, String encodedContent)

public static byte[]
jweKeyEncryptionVerifyAndDecode(Key decryptionKEK, String encodedContent, JWEAlgorithmProvider algorithmProvider, JWEEncryptionProvider encryptionProvider)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

TOKEN_BACKCHANNEL_LOGOUT_EVENTback to summary
public static final String TOKEN_BACKCHANNEL_LOGOUT_EVENT
TOKEN_BACKCHANNEL_LOGOUT_EVENT_REVOKE_OFFLINE_TOKENSback to summary
public static final String TOKEN_BACKCHANNEL_LOGOUT_EVENT_REVOKE_OFFLINE_TOKENS
TOKEN_TYPE_BEARERback to summary
public static final String TOKEN_TYPE_BEARER
TOKEN_TYPE_DPOPback to summary
public static final String TOKEN_TYPE_DPOP
TOKEN_TYPE_IDback to summary
public static final String TOKEN_TYPE_ID
TOKEN_TYPE_KEYCLOAK_IDback to summary
public static final String TOKEN_TYPE_KEYCLOAK_ID
TOKEN_TYPE_LOGOUTback to summary
public static final String TOKEN_TYPE_LOGOUT
TOKEN_TYPE_OFFLINEback to summary
public static final String TOKEN_TYPE_OFFLINE
TOKEN_TYPE_REFRESHback to summary
public static final String TOKEN_TYPE_REFRESH

Constructor Detail

TokenUtilback to summary
public TokenUtil()

Method Detail

attachOIDCScopeback to summary
public static String attachOIDCScope(String scopeParam)
getRefreshTokenback to summary
public static RefreshToken getRefreshToken(byte[] decodedToken) throws JWSInputException

Return refresh token or offline token

getRefreshTokenback to summary
public static RefreshToken getRefreshToken(String refreshToken) throws JWSInputException
hasPromptback to summary
public static boolean hasPrompt(String promptParam, String targetPrompt)
hasScopeback to summary
public static boolean hasScope(String scopeParam, String targetScope)
isOfflineTokenback to summary
public static boolean isOfflineToken(String refreshToken) throws JWSInputException

Return true if given refreshToken represents offline token

isOfflineTokenRequestedback to summary
public static boolean isOfflineTokenRequested(String scopeParam)
isOIDCRequestback to summary
public static boolean isOIDCRequest(String scopeParam)
jweDirectEncodeback to summary
public static String jweDirectEncode(Key aesKey, Key hmacKey, JsonWebToken jwt) throws JWEException
jweDirectEncodeback to summary
public static String jweDirectEncode(Key aesKey, Key hmacKey, byte[] contentBytes) throws JWEException
jweDirectVerifyAndDecodeback to summary
public static <T extends JsonWebToken> T jweDirectVerifyAndDecode(Key aesKey, Key hmacKey, String jweStr, Class<T> expectedClass) throws JWEException
jweDirectVerifyAndDecodeback to summary
public static byte[] jweDirectVerifyAndDecode(Key aesKey, Key hmacKey, String jweStr) throws JWEException
jweKeyEncryptionEncodeback to summary
public static String jweKeyEncryptionEncode(Key encryptionKEK, byte[] contentBytes, String algAlgorithm, String encAlgorithm, String kid, JWEAlgorithmProvider jweAlgorithmProvider, JWEEncryptionProvider jweEncryptionProvider) throws JWEException
jweKeyEncryptionEncodeback to summary
public static String jweKeyEncryptionEncode(Key encryptionKEK, byte[] contentBytes, String algAlgorithm, String encAlgorithm, String kid, JWEAlgorithmProvider jweAlgorithmProvider, JWEEncryptionProvider jweEncryptionProvider, String jweContentType) throws JWEException
jweKeyEncryptionEncodeback to summary
private static String jweKeyEncryptionEncode(Key encryptionKEK, byte[] contentBytes, JWEHeader jweHeader, JWEAlgorithmProvider jweAlgorithmProvider, JWEEncryptionProvider jweEncryptionProvider) throws JWEException
jweKeyEncryptionVerifyAndDecodeback to summary
public static byte[] jweKeyEncryptionVerifyAndDecode(Key decryptionKEK, String encodedContent) throws JWEException
jweKeyEncryptionVerifyAndDecodeback to summary
public static byte[] jweKeyEncryptionVerifyAndDecode(Key decryptionKEK, String encodedContent, JWEAlgorithmProvider algorithmProvider, JWEEncryptionProvider encryptionProvider) throws JWEException