public static final class AccessControlManager.AccessTokens extends Object
Constructor and Description |
---|
AccessTokens(String accessToken,
String refreshToken)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clearTokens()
Clear the tokens in this object.
|
javax.json.JsonObject |
decodeToken(String token)
Decode token
String to a JSON object. |
String |
getAccessToken() |
String |
getRefreshToken() |
boolean |
isTokenExpired()
This implementation is taken from the Javascript Keycloak client adapter,
function isTokenExpired.
|
boolean |
isTokenValid() |
public AccessTokens(String accessToken, String refreshToken) throws NullPointerException, IllegalArgumentException
accessToken
- Access Control Manager access token.refreshToken
- Access Control Manager refresh token.NullPointerException
- if the accessToken is malformed.IllegalArgumentException
- if the accessToken contains expired data.public javax.json.JsonObject decodeToken(String token)
String
to a JSON object. Taken from Keycloak Javascript
adapter:
function decodeToken(str) { str = str.split('.')[1]; str = str.replace('/-/g', '+'); str = str.replace('/_/g', '/'); switch(str.length % 4) { case 0: break; case 2: str += '=='; break; case 3: str += '='; break; default: throw 'Invalid token'; } str = (str + '===').slice(0, str.length + (str.length % 4)); str = str.replace(/-/g, '+').replace(/_/g, '/'); str = decodeURIComponent(escape(atob(str))); str = JSON.parse(str); return str; }
token
- the token String
to decode.null
on failure.public String getAccessToken()
public String getRefreshToken()
public boolean isTokenExpired()
true
if token has expired, false otherwise.public boolean isTokenValid()
true
if tokens can be successfully decoded,
false
otherwise.public void clearTokens()
Copyright © 2020. All rights reserved.