public class HandlerHelper extends Object implements Serializable
VaadinServlet
and generally for handling
VaadinRequests
.Modifier and Type | Class and Description |
---|---|
static class |
HandlerHelper.RequestType
Framework internal enum for tracking the type of a request.
|
Modifier and Type | Method and Description |
---|---|
static Locale |
findLocale(VaadinSession session,
VaadinRequest request)
Helper to find the most most suitable Locale.
|
static String |
getCancelingRelativePath(String pathToCancel)
Gets a relative path that cancels the provided path.
|
static Optional<String> |
getPathIfInsideServlet(String servletMappingPath,
String requestedPath)
Returns the rest of the path after the servlet mapping part, if the
requested path targets a path inside the servlet.
|
static String[] |
getPublicResources()
URLs matching these patterns should be publicly available for
applications to work.
|
static String[] |
getPublicResourcesRequiringSecurityContext()
URLs matching these patterns should be publicly available for
applications to work but might require a security context, i.e.
|
static boolean |
isFrameworkInternalRequest(String servletMappingPath,
javax.servlet.http.HttpServletRequest request)
Checks whether the request is an internal request.
|
static boolean |
isPathUnsafe(String path)
Checks if the given URL path contains the directory change instruction
(dot-dot), taking into account possible double encoding in hexadecimal
format, which can be injected maliciously.
|
static boolean |
isRequestType(VaadinRequest request,
HandlerHelper.RequestType requestType)
Returns whether the given request is of the given type.
|
static void |
setResponseNoCacheHeaders(BiConsumer<String,String> headerSetter,
BiConsumer<String,Long> longHeaderSetter)
Sets no cache headers to the specified response.
|
public static boolean isRequestType(VaadinRequest request, HandlerHelper.RequestType requestType)
request
- the request to checkrequestType
- the type to check fortrue
if the request is of the given type,
false
otherwisepublic static boolean isFrameworkInternalRequest(String servletMappingPath, javax.servlet.http.HttpServletRequest request)
HandlerHelper.RequestType
are considered internal as
they are needed for applications to work.
Requests for routes, static resources requests and similar are not considered internal requests.
servletMappingPath
- the path the Vaadin servlet is mapped to, with or without and
ending "/*"request
- the servlet requesttrue
if the request is Vaadin internal, false
otherwisepublic static Optional<String> getPathIfInsideServlet(String servletMappingPath, String requestedPath)
servletMappingPath
- the servlet mapping from the servlet configurationrequestedPath
- the request path relative to the context rootpublic static Locale findLocale(VaadinSession session, VaadinRequest request)
UI.getCurrent()
if definedVaadinSession.getCurrent()
if definedVaadinService.getCurrentRequest()
if definedLocale.getDefault()
session
- the session that is searched for locale or null
if not availablerequest
- the request that is searched for locale or null
if not availablepublic static void setResponseNoCacheHeaders(BiConsumer<String,String> headerSetter, BiConsumer<String,Long> longHeaderSetter)
headerSetter
- setter for string value headerslongHeaderSetter
- setter for long value headerspublic static String getCancelingRelativePath(String pathToCancel)
pathToCancel
- the path that should be canceledpublic static boolean isPathUnsafe(String path)
path
- the URL path to be verified.true
, if the given path has a directory change
instruction, false
otherwise.public static String[] getPublicResources()
public static String[] getPublicResourcesRequiringSecurityContext()
Copyright © 2021. All rights reserved.