Package org.eclnt.jsfserver.util
Class ServletUtil
java.lang.Object
org.eclnt.jsfserver.util.ServletUtil
- All Implemented Interfaces:
ICCServerConstants
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsFields inherited from interface org.eclnt.jsfserver.util.ICCServerConstants
CLIENTDEVICETYPE_DESKTOP, CLIENTDEVICETYPE_MOBILE, CLIENTJAVATYPE_FX, CLIENTJAVATYPE_SWING, CLIENTTYPE_APPLET, CLIENTTYPE_APPLICATION, CLIENTTYPE_BROWSER, CLIENTTYPE_RISC, CLIENTTYPE_UI5, CLIENTTYPE_WEBSTART, EXPLICIT_EMPTY, EXPLICIT_NULL, FOCUSSEQUENCE_FIX_PREFIX, HEADER_ATTRIBUTE_CLIENT, HEADER_ATTRIBUTE_CLIENTJAVATYPE, HEADER_ATTRIBUTE_COOKIESENABLED, HEADER_ATTRIBUTE_COUNTRY, HEADER_ATTRIBUTE_DEVICESCREENHEIGHT, HEADER_ATTRIBUTE_DEVICESCREENWIDTH, HEADER_ATTRIBUTE_DEVICETYPE, HEADER_ATTRIBUTE_LANGUAGE, HEADER_ATTRIBUTE_MEDIADEVICES, HEADER_ATTRIBUTE_ORIGINALURL, HEADER_ATTRIBUTE_PERFORMANCEDATA, HEADER_ATTRIBUTE_REQUESTID, HEADER_ATTRIBUTE_TIMEZONEOFFSET, HEADER_ATTRIBUTE_USERAGENT, HEADER_ATTRIBUTE_XFRAMEOPTIONS, HEADER_RESPONSE_ATTRIBUTE_HTTPSESSIONID, HEADER_RESPONSE_ATTRIBUTE_HTTPSESSIONREFERENCEURL, HEADER_RESPONSE_ATTRIBUTE_HTTPSESSIONTRACKINGMODE, HEADER_RESPONSE_ATTRIBUTE_OVERRIDE, HEADER_RESPONSE_ATTRIBUTE_RELOAD, HEADER_RESPONSE_ATTRIBUTE_STYLE, INPUTMASK_VALUEMODE_WITHMASK, INPUTMASK_VALUEMODE_WITHOUTMASK, LAYOUTEXTENSION_JSP, LAYOUTEXTENSION_XML, LITERAL_LINK_PREFIX, LITERAL_TEMP_PREFIX, QP_CCSTYLE, QP_KEEPDIALOGSESSION, QP_SUBPAGEID, SECURITY_ROLE_CCADMIN, SESSION_TRACKING_COOKIE, SESSION_TRACKING_URL, SIZE_UNDEFINED, TEXTPANE_CONTENTTYPE_HTML, TEXTPANE_CONTENTTYPE_PLAIN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddFileNameAdviceIntoURL(String url, String fileName) static StringaddQueryParameterToURL(String url, String name, String value) static Stringstatic booleancheckIfRequestIsDesignTimerRequest(jakarta.servlet.http.HttpServletRequest req) Certain requests are only processed in a design time version of the server - in order to support anylysis of the system.static booleancheckIfRISCUrlStartedInDevelopmentMode(jakarta.servlet.http.HttpServletRequest startRequest) static Stringstatic StringencodeURL(String url, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) static StringencodeURLWithoutURLEncoding(String url, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) static voidensureRequestIsDesignTimeRequest(jakarta.servlet.http.HttpServletRequest req) Similar tocheckIfRequestIsDesignTimerRequest(HttpServletRequest)but now throws an Error if not running in design time mode.static voidensureServletGetIsAllowed(Class clazz) static voidensureSessionIsAvailableAndValid(jakarta.servlet.http.HttpServletRequest req) static StringfindWebappCookiePath(jakarta.servlet.http.HttpServletRequest req) static StringgetPathBehindContextPath(jakarta.servlet.http.HttpServletRequest request) The path (without query parameters!)static voidinitClientIdCookieParamHttpOnly(boolean httpOnly) static voidinitClientIdCookieParamSameSite(String sameSite) static voidinitClientIdCookieParamSecure(boolean secure) static voidinitClientIdCookieParamSecure(String secure) static voidstatic StringisolateOriginalProtocol(jakarta.servlet.http.HttpServletRequest req, boolean withError) static StringisolateOriginalServer(jakarta.servlet.http.HttpServletRequest req, boolean withError) static StringisolateOriginalUrlWebappContextPath(jakarta.servlet.http.HttpServletRequest req) static StringisolateResourcePath(jakarta.servlet.http.HttpServletRequest req) Find the resource path that is relative to the web content view.static StringproposeContentType(String extension) static StringreadRequestParameterFromDesignTimeRequest(jakarta.servlet.http.HttpServletRequest req, String parameterName) Reads an http parameter from the request - but only if the request is targeting a design time server.static StringsanitizeContentType(String contentType) static StringsanitizeCookieValue(String value) static voidsetResponseContentType(jakarta.servlet.http.HttpServletResponse response, String contentType) Central method for setting response content type - with sanitizing the content.static voidsetResponseHeader(jakarta.servlet.http.HttpServletResponse response, String fieldName, String attributeValue) Central method for setting response header attributes - with sanitizing the content.static voidsetSessionAttributeWithTrustedName(jakarta.servlet.http.HttpSession session, String attributeName, Object data) Central method for setting HttpSession attributes.static StringupdateResource(jakarta.servlet.http.HttpServletRequest req, String resource) Update the resource namestatic voidwriteCookie(jakarta.servlet.http.HttpServletResponse resp, String name, String path, String value, boolean httponly, String samesite, boolean secure) static voidwriteEclntIdCookie(jakarta.servlet.http.HttpServletResponse resp, String id) static voidwriteTrustedDataToResponseOutputStream(jakarta.servlet.http.HttpServletResponse resp, byte[] data) Central method for writing trusted data into response output stream.
-
Field Details
-
ECLNTID_COOKIE_NAME
- See Also:
-
-
Constructor Details
-
ServletUtil
public ServletUtil()
-
-
Method Details
-
initialize
public static void initialize() -
initClientIdCookieParamHttpOnly
public static void initClientIdCookieParamHttpOnly(boolean httpOnly) -
initClientIdCookieParamSecure
public static void initClientIdCookieParamSecure(boolean secure) -
initClientIdCookieParamSecure
-
initClientIdCookieParamSameSite
- Parameters:
sameSite- "Strict", "Lax", "None" or null
-
encodeURL
-
encodeURLWithoutURLEncoding
-
decodeURL
-
addQueryParameterToURL
-
ensureServletGetIsAllowed
-
isolateResourcePath
Find the resource path that is relative to the web content view.- Returns:
- The result is returned starting as a relative path, not starting with a "/".
-
findWebappCookiePath
- Parameters:
req- Must be a faces request!- Returns:
- Path of the cookie so that it is use-able for whole application context. E.g. when original URL is http://aaa/bbb/faces/... then the returned path is "/aaa/bbb". If no webapp path can be found then "/" is returned.
-
isolateOriginalUrlWebappContextPath
public static String isolateOriginalUrlWebappContextPath(jakarta.servlet.http.HttpServletRequest req) - Parameters:
req- Must be a faces request!- Returns:
- If original URL is available => "/...rootOfWebApp...>". Otherwise: null.
-
isolateOriginalProtocol
public static String isolateOriginalProtocol(jakarta.servlet.http.HttpServletRequest req, boolean withError) - Parameters:
req- Must be a faces request!- Returns:
- Protocol, e.g. "http" or "https"
-
isolateOriginalServer
public static String isolateOriginalServer(jakarta.servlet.http.HttpServletRequest req, boolean withError) - Parameters:
req- Must be a faces request!- Returns:
- Server (without port!).
-
updateResource
Update the resource name -
proposeContentType
-
writeEclntIdCookie
-
writeCookie
-
calculateExpirationDateForever
-
ensureSessionIsAvailableAndValid
public static void ensureSessionIsAvailableAndValid(jakarta.servlet.http.HttpServletRequest req) throws ServletUtil.SessionIsNotAvailableOrInvalidException -
checkIfRISCUrlStartedInDevelopmentMode
public static boolean checkIfRISCUrlStartedInDevelopmentMode(jakarta.servlet.http.HttpServletRequest startRequest) -
getPathBehindContextPath
The path (without query parameters!) behind the context path of the current request. -
setResponseContentType
public static void setResponseContentType(jakarta.servlet.http.HttpServletResponse response, String contentType) Central method for setting response content type - with sanitizing the content. -
setResponseHeader
public static void setResponseHeader(jakarta.servlet.http.HttpServletResponse response, String fieldName, String attributeValue) Central method for setting response header attributes - with sanitizing the content. -
sanitizeContentType
-
sanitizeCookieValue
-
readRequestParameterFromDesignTimeRequest
public static String readRequestParameterFromDesignTimeRequest(jakarta.servlet.http.HttpServletRequest req, String parameterName) Reads an http parameter from the request - but only if the request is targeting a design time server. If the server is a "real" system then null is returned. -
ensureRequestIsDesignTimeRequest
public static void ensureRequestIsDesignTimeRequest(jakarta.servlet.http.HttpServletRequest req) Similar tocheckIfRequestIsDesignTimerRequest(HttpServletRequest)but now throws an Error if not running in design time mode. -
checkIfRequestIsDesignTimerRequest
public static boolean checkIfRequestIsDesignTimerRequest(jakarta.servlet.http.HttpServletRequest req) Certain requests are only processed in a design time version of the server - in order to support anylysis of the system. This function is the central one to check if a request is contacting a system running in design time or a system running as "real" system. -
setSessionAttributeWithTrustedName
public static void setSessionAttributeWithTrustedName(jakarta.servlet.http.HttpSession session, String attributeName, Object data) Central method for setting HttpSession attributes. The caller makes sure that the data that the attributeName that is used is trust-able.
The method needs to be called by any code that sets attributes with a dynamic name. -
writeTrustedDataToResponseOutputStream
public static void writeTrustedDataToResponseOutputStream(jakarta.servlet.http.HttpServletResponse resp, byte[] data) throws IOException Central method for writing trusted data into response output stream. The caller of this method must ensure that the data is not infected with e.g. user input or user data.- Throws:
IOException
-
addFileNameAdviceIntoURL
-