Class 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.
    • 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 action
      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)
      Compute a hyperlink URL based on the forward, href, or page 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 parameters
      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
      static java.lang.String getRequestParameters​(javax.servlet.http.HttpServletRequest aRequest)
      Creates query String from request body parameters
      static void reclaimRequestAttributes​(javax.servlet.http.HttpServletRequest aRequest, boolean doRemove)
      Reclaims request attributes from session to request
      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.
      static boolean stowRequestAttributes​(javax.servlet.http.HttpServletRequest aRequest)
      Stores request attributes in session
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • messages

        protected static org.apache.struts.util.MessageResources messages
        The message resources.
    • Constructor Detail

      • SecureRequestUtils

        public SecureRequestUtils()
    • 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 the forward, href, or page parameter that is not null. The returned URL will have already been passed to response.encodeURL() for adding a session identifier.
        Parameters:
        pageContext - PageContext for the tag making this call
        forward - 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 name
        params - Map of parameters to be dynamically included (if any)
        anchor - Anchor to be dynamically included (if any)
        redirect - Is this URL for a response.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 parameters
        ampersand - 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 request
        doRemove - 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 request
        application - the currecnt ServletContext
        isSecure - "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 URL
        pageContext - 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 Action
        aContext - The current ServletContext
        aRequest - The current request object
        aResponse - The current response object
        Returns:
        true, if being redirected, false otherwise