@Component public class CsrfChecker extends Object
| Constructor and Description |
|---|
CsrfChecker(javax.servlet.ServletContext servletContext)
Creates a new csrf checker for the given context.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isCsrfProtectionEnabled()
Checks if CSRF token checking in endpoints is enabled.
|
void |
setCsrfProtection(boolean csrfProtectionEnabled)
Enable or disable CSRF token checking in endpoints.
|
boolean |
validateCsrfTokenInRequest(javax.servlet.http.HttpServletRequest request)
Validates the CSRF token that is included in the request.
|
public CsrfChecker(javax.servlet.ServletContext servletContext)
servletContext - the servlet contextpublic boolean validateCsrfTokenInRequest(javax.servlet.http.HttpServletRequest request)
Checks that the CSRF token in the request matches the expected one that is stored in the HTTP cookie.
Note! If CSRF protection is disabled, this method will always return
true.
request - the request to validatetrue if the CSRF token is ok or checking is disabled,
false otherwisepublic void setCsrfProtection(boolean csrfProtectionEnabled)
csrfProtectionEnabled - enable or disable protectionpublic boolean isCsrfProtectionEnabled()
true if protection is enabled, false otherwiseCopyright © 2000–2022 Vaadin Ltd. All rights reserved.