Class SecretBasedAXSRFTVendingMachine
java.lang.Object
com.webmethods.caf.faces.render.xsrf.BaseAXSRFTVendingMachine
com.webmethods.caf.faces.render.xsrf.SecretBasedAXSRFTVendingMachine
- All Implemented Interfaces:
IAXSRFTVendingMachine
Anti-cross-site-request-forgery-token manager
which uses server secrets to produce and validate tokens.
This class must be initialized with at least one secret
in its list of secrets. Ideally, one thread (ie portal scheduled event listener)
will call
removeOldSecrets(long)
and then addNewSecret()
on a timed schedule (which will update the secrets list).-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
protected List<SecretBasedAXSRFTVendingMachine.Secret>
Fields inherited from class com.webmethods.caf.faces.render.xsrf.BaseAXSRFTVendingMachine
m_whitelist
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptToken
(FacesContext context, String token) Returns true if the specified anti-cross-site-request-forgery token is valid for the specified user.boolean
acceptToken
(HttpServletRequest request, String token) Returns true if the specified anti-cross-site-request-forgery token is valid for the specified user.void
Generates a new random secret, and adds it to the list of secrets.protected String
digest
(SecretBasedAXSRFTVendingMachine.Secret secret, String user) Digests user + secret.protected SecretBasedAXSRFTVendingMachine.Secret
Generates a new random secret.protected String
generateToken
(String user) Generates a token for this user.protected String
getUser
(FacesContext context) protected String
getUser
(HttpServletRequest request) produceToken
(String user) Produces an anti-cross-site-request-forgery token for the specified user.produceToken
(FacesContext context) Produces an anti-cross-site-request-forgery token for the specified user.produceToken
(HttpServletRequest request) Produces an anti-cross-site-request-forgery token for the specified user.void
removeOldSecrets
(long oldestAllowed) void
protected boolean
validateToken
(String user, String token) Validates the token for this user.Methods inherited from class com.webmethods.caf.faces.render.xsrf.BaseAXSRFTVendingMachine
getRequest, getWhitelist, inWhitelist, parseWhitelist, setWhitelist
-
Field Details
-
CURRENT_TOKEN
-
m_secrets
-
-
Constructor Details
-
SecretBasedAXSRFTVendingMachine
public SecretBasedAXSRFTVendingMachine()
-
-
Method Details
-
produceToken
Produces an anti-cross-site-request-forgery token for the specified user. -
produceToken
Produces an anti-cross-site-request-forgery token for the specified user. -
produceToken
Produces an anti-cross-site-request-forgery token for the specified user. -
acceptToken
Returns true if the specified anti-cross-site-request-forgery token is valid for the specified user. -
acceptToken
Returns true if the specified anti-cross-site-request-forgery token is valid for the specified user. -
addNewSecret
public void addNewSecret()Generates a new random secret, and adds it to the list of secrets. -
removeOldSecrets
public void removeOldSecrets(long oldestAllowed) -
generateNewSecret
Generates a new random secret. -
generateToken
Generates a token for this user. -
validateToken
Validates the token for this user. -
digest
Digests user + secret. -
getUser
-
getUser
-
getSecrets
-
setSecrets
-