public class CmsTokenValidator extends java.lang.Object
When a user requests a link to change his password, an authorization token is generated and also stored in the user's additional info (in a slightly different form). When the user opens the 'change password' link sent to him, the authentication token is validated by comparing it to the token in the user's additional info. Additionally, the system checks whether the age of the token stored in the additional infos is older than the maximum age, which can also be configured.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ADDINFO_KEY
Additional info key to store the authorization data.
|
| Constructor and Description |
|---|
CmsTokenValidator() |
| Modifier and Type | Method and Description |
|---|---|
static void |
clearToken(CmsObject cms,
CmsUser user)
Removes an authorization token from the user's additional information.
|
static java.lang.String |
createToken(CmsObject cms,
CmsUser user,
long currentTime)
Creates a new token for the given user and stores it in the user's additional info.
|
CmsUser |
getUser()
Gets the user.
|
java.lang.String |
validateToken(CmsObject cms,
java.lang.String token,
long maxAgeMillis)
Validates the authentication token against the token stored in the user's additional info.
|
public static final java.lang.String ADDINFO_KEY
public CmsTokenValidator()
public static void clearToken(CmsObject cms, CmsUser user) throws CmsException
cms - the CMS contextuser - the userCmsException - if something goes wrongpublic static java.lang.String createToken(CmsObject cms, CmsUser user, long currentTime) throws CmsException
cms - the CMS contextuser - the usercurrentTime - the current timeCmsException - if something goes wrongpublic java.lang.String validateToken(CmsObject cms, java.lang.String token, long maxAgeMillis) throws CmsException
cms - the CMS contexttoken - the authentication tokenmaxAgeMillis - the maximum token age in millisecondsCmsException - if something goes wrong