public class AuthTokenUtil extends Object
| Constructor and Description |
|---|
AuthTokenUtil() |
| Modifier and Type | Method and Description |
|---|---|
static AuthToken |
consumeToken(String encodedJson)
Consumes an auth token, validating it during the process.
|
static AuthToken |
createAuthToken(String principal,
Set<String> roles,
int expiresInMillis)
Creates an auth token.
|
static AuthToken |
fromJSON(String json)
Read the auth token from the JSON string.
|
static String |
produceToken(String principal,
Set<String> roles,
int expiresInMillis)
Produce a token suitable for transmission.
|
static void |
signAuthToken(AuthToken token)
Adds a digital signature to the auth token.
|
static String |
toJSON(AuthToken token)
Convert the auth token to a JSON string.
|
static void |
validateToken(AuthToken token)
Validates an auth token.
|
public static final String produceToken(String principal, Set<String> roles, int expiresInMillis)
principal - the auth principalroles - the auth rolesexpiresInMillis - the number of millis to expirypublic static final AuthToken consumeToken(String encodedJson) throws IllegalArgumentException
AuthToken is returned. If the token is invalid (expired or bad
signature) then an IllegalArgumentException is thrown. Any other
error will result in a runtime exception.encodedJson - the raw tokenIllegalArgumentException - indicate that a method has been passed an
illegal or inappropriate argumentpublic static final void validateToken(AuthToken token) throws IllegalArgumentException
token - the authentication tokenIllegalArgumentException - when the token is invalidpublic static final AuthToken createAuthToken(String principal, Set<String> roles, int expiresInMillis)
principal - the auth principalroles - the auth rolesexpiresInMillis - the number of millis to expirypublic static final void signAuthToken(AuthToken token)
token - the auth tokenpublic static final String toJSON(AuthToken token)
token - the auth tokenCopyright © 2015 JBoss, a division of Red Hat. All rights reserved.