Package org.apache.struts.util
Class SecureRequestUtils
- java.lang.Object
-
- org.apache.struts.util.SecureRequestUtils
-
public class SecureRequestUtils extends java.lang.Object
Define some additional utility methods utilized by sslext.- Author:
- Steve Ditlinger, Kim Turner
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.struts.util.MessageResources
messages
The message resources.
-
Constructor Summary
Constructors Constructor Description SecureRequestUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
checkSsl(SecureActionConfig aMapping, javax.servlet.ServletContext aContext, javax.servlet.http.HttpServletRequest aRequest, javax.servlet.http.HttpServletResponse aResponse)
Checks to see if SSL should be toggled for this actionstatic java.lang.String
computeURL(javax.servlet.jsp.PageContext pageContext, java.lang.String forward, java.lang.String href, java.lang.String page, java.lang.String action, java.lang.String module, java.util.Map params, java.lang.String anchor, boolean redirect)
Compute a hyperlink URL based on theforward
,href
, orpage
parameter that is not null.static java.lang.StringBuffer
createQueryStringFromMap(java.util.Map m, java.lang.String ampersand)
Builds a query string from a given map of parametersstatic java.lang.String
getRedirectString(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext application, java.lang.String isSecure)
Creates a redirect URL string if the current request should be redirectedstatic java.lang.String
getRequestParameters(javax.servlet.http.HttpServletRequest aRequest)
Creates query String from request body parametersstatic void
reclaimRequestAttributes(javax.servlet.http.HttpServletRequest aRequest, boolean doRemove)
Reclaims request attributes from session to requeststatic org.apache.struts.config.ModuleConfig
selectModule(java.lang.String urlPath, javax.servlet.jsp.PageContext pageContext)
Select the module to which the specified request belongs.static boolean
stowRequestAttributes(javax.servlet.http.HttpServletRequest aRequest)
Stores request attributes in session
-
-
-
Method Detail
-
computeURL
public static java.lang.String computeURL(javax.servlet.jsp.PageContext pageContext, java.lang.String forward, java.lang.String href, java.lang.String page, java.lang.String action, java.lang.String module, java.util.Map params, java.lang.String anchor, boolean redirect) throws java.net.MalformedURLException
Compute a hyperlink URL based on theforward
,href
, orpage
parameter that is not null. The returned URL will have already been passed toresponse.encodeURL()
for adding a session identifier.- Parameters:
pageContext
- PageContext for the tag making this callforward
- Logical forward name for which to look up the context-relative URI (if specified)href
- URL to be utilized unmodified (if specified)page
- Context-relative page for which a URL should be created (if specified)action
- a Struts action nameparams
- Map of parameters to be dynamically included (if any)anchor
- Anchor to be dynamically included (if any)redirect
- Is this URL for aresponse.sendRedirect()
?- Throws:
java.net.MalformedURLException
- if a URL cannot be created for the specified parameters
-
getRequestParameters
public static java.lang.String getRequestParameters(javax.servlet.http.HttpServletRequest aRequest)
Creates query String from request body parameters- Parameters:
aRequest
- The current request- Returns:
- The created query string (with no leading "?")
-
createQueryStringFromMap
public static java.lang.StringBuffer createQueryStringFromMap(java.util.Map m, java.lang.String ampersand)
Builds a query string from a given map of parameters- Parameters:
m
- A map of parametersampersand
- String to use for ampersands (e.g. "&" or "&" )- Returns:
- query string (with no leading "?")
-
stowRequestAttributes
public static boolean stowRequestAttributes(javax.servlet.http.HttpServletRequest aRequest)
Stores request attributes in session- Parameters:
aRequest
- The current request- Returns:
- true, if the attributes were stowed in the session, false otherwise
-
reclaimRequestAttributes
public static void reclaimRequestAttributes(javax.servlet.http.HttpServletRequest aRequest, boolean doRemove)
Reclaims request attributes from session to request- Parameters:
aRequest
- The current requestdoRemove
- True, if the attributes should be removed after being reclaimed, false otherwise
-
getRedirectString
public static java.lang.String getRedirectString(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext application, java.lang.String isSecure)
Creates a redirect URL string if the current request should be redirected- Parameters:
request
- current servlet requestapplication
- the currecnt ServletContextisSecure
- "true" if the current request should be transmitted via SSL "false" if not, "any" if we just don't care if it's SSL or not- Returns:
- the URL to redirect to
-
selectModule
public static org.apache.struts.config.ModuleConfig selectModule(java.lang.String urlPath, javax.servlet.jsp.PageContext pageContext)
Select the module to which the specified request belongs.- Parameters:
urlPath
- The requested URLpageContext
- The ServletContext for this web application- Returns:
- The ModuleConfig for the given URL path
-
checkSsl
public static boolean checkSsl(SecureActionConfig aMapping, javax.servlet.ServletContext aContext, javax.servlet.http.HttpServletRequest aRequest, javax.servlet.http.HttpServletResponse aResponse)
Checks to see if SSL should be toggled for this action- Parameters:
aMapping
- The mapping object for this ActionaContext
- The current ServletContextaRequest
- The current request objectaResponse
- The current response object- Returns:
- true, if being redirected, false otherwise
-
-