Class AccessTokenManager
java.lang.Object
com.jalios.jcms.authentication.accesstoken.AccessTokenManager
Provides utility methods to manage AccessToken.
- Since:
- JCMS-4770
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanManageAccessToken(Member member) Check if the specified member is authorized to manage access tokensstatic StringcomputeTokenFingerprint(String tokenValue) Compute a fingerprint of the specified token.static final AccessTokencreateAccessToken(Member member, String url, AccessTokenOptions hints, String fingerprint, AccessTokenManager.TokenType tokenType) Create a new AccessToken in the db for the specified token.static voiddeleteAccessToken(Member member, String fingerprint) Delete AccessToken matching specified parameter.static voidDelete all AccessToken whose expiration date is prior to now.static final AccessTokengetAccessToken(Member member, String fingerprint) Retrieve the AccessToken stored in DB and matching the specified criteriaGet list of all AccessToken about to expire in the next 30 days (by default).protected static intstatic voidsendAccessTokenCreatedAlert(AccessToken accessToken) Send the security alert informing the member that a new AccessToken was createdstatic voidsendAccessTokenDeletedAlert(AccessToken accessToken) Send the security alert informing the member that an AccessToken was deleted/revokedstatic voidNotifies all members for their expiring soon AccessToken.static voidtrackAccessTokenUse(AccessToken accessToken) Update the last used data of the specified AccessToken
-
Field Details
-
ALERT_DOMAIN
- See Also:
-
EXPIRING_REMINDER_ALERT_NAME
- See Also:
-
EXPIRING_REMINDER_DEFAULT_RECIPIENT
- See Also:
-
-
Method Details
-
canManageAccessToken
Check if the specified member is authorized to manage access tokens- Parameters:
member- true if member can manage access tokens, false otherwise- Returns:
- the member to check
-
createAccessToken
public static final AccessToken createAccessToken(Member member, String url, AccessTokenOptions hints, String fingerprint, AccessTokenManager.TokenType tokenType) Create a new AccessToken in the db for the specified token.- Parameters:
member- the member for which token was generated, must not be nullurl- the URL for which token was generatedhints- the AccessTokenHints instance containing all token information used to generate the token, must not be nullfingerprint- the unique value identifying the token that was computed, must not be nulltokenType- the type of token being generated- Returns:
- a new AccessToken instance
-
getAccessToken
Retrieve the AccessToken stored in DB and matching the specified criteria- Parameters:
member- the Member for which the key has been emittedfingerprint- a unique value identifying the token that should be retrieved from DB, cfcomputeTokenFingerprint(String)- Returns:
- an AccessToken or null
-
deleteAccessToken
Delete AccessToken matching specified parameter.Parameters are all required, no operation is performed if any of them are null or empty.
- Parameters:
member- the member for which AccessToken was emitted.fingerprint- the fingerprint of the token that must be deleted, cfcomputeTokenFingerprint(String)
-
deleteExpiredAccessToken
public static void deleteExpiredAccessToken()Delete all AccessToken whose expiration date is prior to now. -
sendAccessTokenCreatedAlert
Send the security alert informing the member that a new AccessToken was created- Parameters:
accessToken- the token newly created
-
sendAccessTokenDeletedAlert
Send the security alert informing the member that an AccessToken was deleted/revoked- Parameters:
accessToken- the token deleted/revoked
-
computeTokenFingerprint
Compute a fingerprint of the specified token. Use this method when your access token does not have any simple unique id that can be refenced. This methods computes the SHA256 signature of the specified token value.- Parameters:
tokenValue- the value- Returns:
- a SHA256 fingerprint of the specified tokenValue
-
trackAccessTokenUse
Update the last used data of the specified AccessToken- Parameters:
accessToken- the AccessToken to track (null value authorized, no operation is performed)
-
getExpiringAccessTokenIdList
Get list of all AccessToken about to expire in the next 30 days (by default).- Returns:
- id list of token
- Since:
- jcms-10.0.8 / JCMS-4770
-
getExpiringReminderDaysUntilExpiration
protected static int getExpiringReminderDaysUntilExpiration()- Returns:
- count of next days during which access token will expire
- Since:
- jcms-10.0.8 / JCMS-4770
-
sendExpiringAccessTokenReminderAlert
public static void sendExpiringAccessTokenReminderAlert()Notifies all members for their expiring soon AccessToken.Tokens of invalid accounts will be notified to a default recipient.
- Since:
- jcms-10.0.8 / JCMS-4770
-