public final class WebUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
escapePath(String path)
Does a URL encoding of the
path. |
static org.apache.shiro.subject.Subject |
getAuthenticatedSubject(javax.servlet.http.HttpServletRequest request)
Return authenticated subject, performing login using basic authentication credentials, if provided in the current request.
|
static String[] |
getBasicAuthData(javax.servlet.http.HttpServletRequest request)
Returns the username and password pair from provided request if it contains authorization header of type BASIC.
|
static String |
getInternetExplorerCompatibility(javax.servlet.http.HttpServletRequest request)
Returns the value for the X-UA-Compatible tag, based on the configuration and current UI theme.
|
static InputStream |
getResourceAsStream(String path)
Returns the InputStream for the specified servlet context resource.
|
static String |
getResourceAsString(String path)
Loads the content of the specified servlet context resource as text.
|
static String |
getUITheme(javax.servlet.http.HttpServletRequest request)
Returns the value of the currently active UI theme, considering the theme request parameter, session scope attribute, user
preferred theme property and finally the globally configured theme.
|
static String |
lookupResourceAsString(String... lookupPaths)
Loads the content of the servlet context resource as text looking up the specified paths until the first resource is found.
|
static void |
setCacheHeaders(long expiresSeconds,
javax.servlet.http.HttpServletResponse response)
Sets proper response headers to cache current response for the specified number of seconds.
|
static void |
setFileDownloadHeaders(javax.servlet.http.HttpServletResponse response,
String fileName)
Sets proper response headers in case of file download using the provided file name.
|
static void |
setNoCacheHeaders(javax.servlet.http.HttpServletResponse response)
Sets proper response headers to prevent caching of this response.
|
static String |
urlDecode(String url)
Decodes a
application/x-www-form-urlencoded string using the character encoding, configured in jahia.properties. |
public static String escapePath(String path)
path. The characters that don't need encoding are those defined 'unreserved' in section 2.3
of the 'URI generic syntax' RFC 2396. Not the entire path string is escaped, but every individual part (i.e. the slashes are not
escaped).path - the path to encodeNullPointerException - if path is null.Text.escapePath(String)public static org.apache.shiro.subject.Subject getAuthenticatedSubject(javax.servlet.http.HttpServletRequest request)
throws org.apache.shiro.authc.AuthenticationException
request - current HTTP requestorg.apache.shiro.authc.AuthenticationException - in case of errors during login operationpublic static String[] getBasicAuthData(javax.servlet.http.HttpServletRequest request)
request - current HTTP requestnull if the request does not contain such
informationpublic static String getInternetExplorerCompatibility(javax.servlet.http.HttpServletRequest request)
request - current HTTP requestpublic static InputStream getResourceAsStream(String path) throws IOException
path - the resource path (context relative)null if the corresponding resource does not existIOException - in case of a problem reading resource contentpublic static String getResourceAsString(String path) throws IOException
path - the resource path (context relative)null if the corresponding resource does not existIOException - in case of a problem reading resource contentpublic static String getUITheme(javax.servlet.http.HttpServletRequest request)
request - current HTTP requestpublic static String lookupResourceAsString(String... lookupPaths) throws IOException
lookupPaths - the resource paths to lookup (context relative)null if the corresponding resource does not existIOException - in case of a problem reading resource contentpublic static void setCacheHeaders(long expiresSeconds,
javax.servlet.http.HttpServletResponse response)
expiresSeconds - the expiration in secondsresponse - current response objectpublic static void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response)
response - current response objectpublic static void setFileDownloadHeaders(javax.servlet.http.HttpServletResponse response,
String fileName)
response - current responsefileName - the file name to use in the response headerCopyright © 2004–2020 Jahia Solutions Group SA. All rights reserved.