com.vaadin.flow.server.

Class HandlerHelper

    • Method Detail

      • isRequestType

        public static boolean isRequestType(VaadinRequest request,
                                            HandlerHelper.RequestType requestType)

        Returns whether the given request is of the given type.

        Parameters:

        request - the request to check

        requestType - the type to check for

        Returns:

        true if the request is of the given type, false otherwise

      • findLocale

        public static Locale findLocale(VaadinSession session,
                                        VaadinRequest request)

        Helper to find the most most suitable Locale. These potential sources are checked in order until a Locale is found:

        1. The passed component (or UI) if not null
        2. UI.getCurrent() if defined
        3. The passed session if not null
        4. VaadinSession.getCurrent() if defined
        5. The passed request if not null
        6. VaadinService.getCurrentRequest() if defined
        7. Locale.getDefault()

        Parameters:

        session - the session that is searched for locale or null if not available

        request - the request that is searched for locale or null if not available

        Returns:

        the found locale

      • setResponseNoCacheHeaders

        public static void setResponseNoCacheHeaders(BiConsumer<String,String> headerSetter,
                                                     BiConsumer<String,Long> longHeaderSetter)

        Sets no cache headers to the specified response.

        Parameters:

        headerSetter - setter for string value headers

        longHeaderSetter - setter for long value headers

      • getCancelingRelativePath

        public static String getCancelingRelativePath(String pathToCancel)

        Gets a relative path that cancels the provided path. This essentially adds one .. for each part of the path to cancel.

        Parameters:

        pathToCancel - the path that should be canceled

        Returns:

        a relative path that cancels out the provided path segment

      • isPathUnsafe

        public 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.

        Parameters:

        path - the URL path to be verified.

        Returns:

        true, if the given path has a directory change instruction, false otherwise.