ca.bc.gov.webade.http
Class HttpRequestUtils

java.lang.Object
  extended byca.bc.gov.webade.http.HttpRequestUtils

public final class HttpRequestUtils
extends java.lang.Object

Used to retrieve the application and user info service singletons from the servlet context and the session user's permissions and information from the session object associated with the current request.

Author:
jross

Field Summary
static java.lang.String CURRENT_WEBADE_USER_INFO
          The attribute name for the WebADEUserInfo object in the HttpSession
static java.lang.String CURRENT_WEBADE_USER_PERMISSIONS
          The attribute name for the WebADEUserPermissions object in the HttpSession
static java.lang.String WEBADE_APPLICATION
          The attribute name for the Application object in the HttpSession
static java.lang.String WEBADE_FLOW_CONTROL_FLAG
          The attribute name for the flag used by the tag FlowControlTag to prevent users from calling JSPs directly.
static java.lang.String WEBADE_HAS_PREPROCESSED_REQUEST
          The request attribute name for the flag indicating the WebADE has pre-processed this request.
static java.lang.String WEBADE_USER
          The attribute name for the User object in the HttpSession
static java.lang.String WEBADE_USER_INFO_SERVICE
          The attribute name for the UserInfoService object in the HttpSession
 
Constructor Summary
HttpRequestUtils()
           
 
Method Summary
static Application getApplication(javax.servlet.ServletContext context)
          A convenience method for web application code needing to access the Application object.
static User getCurrentUser(javax.servlet.http.HttpServletRequest req)
          Deprecated. Use getCurrentUserPermissions(javax.servlet.http.HttpServletRequest) and getCurrentUserInfo(javax.servlet.http.HttpServletRequest) instead.
static User getCurrentUser(javax.servlet.http.HttpSession session)
          Deprecated. Use getCurrentUserPermissions(javax.servlet.http.HttpSession) and getCurrentUserInfo(javax.servlet.http.HttpSession) instead.
static WebADEUserInfo getCurrentUserInfo(javax.servlet.http.HttpServletRequest req)
          Returns the WebADEUserInfo object for the user making the request.
static WebADEUserInfo getCurrentUserInfo(javax.servlet.http.HttpSession session)
          Returns the WebADEUserInfo object for the user making the request.
static WebADECurrentUserPermissions getCurrentUserPermissions(javax.servlet.http.HttpServletRequest req)
          Returns the WebADEUserPermissions object for the user making the request.
static WebADECurrentUserPermissions getCurrentUserPermissions(javax.servlet.http.HttpSession session)
          Returns the WebADEUserPermissions object for the user making the request.
static UserInfoService getUserInfoService(javax.servlet.ServletContext context)
          A convenience method for web application code needing to access the UserInfoService object.
static void init(javax.servlet.ServletConfig config, javax.servlet.ServletContext context, java.lang.String appCode)
          Deprecated. Use WebAppInitializationUtils.initializeWebApp(javax.servlet.ServletContext, java.lang.String) instead.
static void init(javax.servlet.ServletContext context, java.lang.String appCode)
          Deprecated. Use WebAppInitializationUtils.initializeWebApp(javax.servlet.ServletContext, java.lang.String) instead.
static boolean isAnonymousRemoteUser(javax.servlet.http.HttpServletRequest req)
          Tests if the remote user making this request is the anonymous user (eg has not been authenticated by the Web server).
static void postprocessRequest(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Deprecated. Use WebAppRequestProcessingUtils.postprocessRequest(ServletContext, HttpServletRequest, HttpServletResponse)
static boolean preprocessRequest(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Deprecated. Use WebAppRequestProcessingUtils.preprocessRequest(ServletContext, HttpServletRequest, HttpServletResponse)
static User reloadCurrentUser(javax.servlet.http.HttpServletRequest req)
          Deprecated. Use reloadCurrentUserPermissions(javax.servlet.http.HttpServletRequest) and reloadCurrentUserInfo(javax.servlet.http.HttpServletRequest) instead.
static WebADEUserInfo reloadCurrentUserInfo(javax.servlet.http.HttpServletRequest req)
          Refreshes and returns the WebADEUserInfo object from the session for the user making the request.
static WebADECurrentUserPermissions reloadCurrentUserPermissions(javax.servlet.http.HttpServletRequest req)
          Refreshes and returns the WebADECurrentUserPermissions object from the session for the user making the request.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEBADE_APPLICATION

public static final java.lang.String WEBADE_APPLICATION
The attribute name for the Application object in the HttpSession

See Also:
Constant Field Values

WEBADE_USER_INFO_SERVICE

public static final java.lang.String WEBADE_USER_INFO_SERVICE
The attribute name for the UserInfoService object in the HttpSession

See Also:
Constant Field Values

WEBADE_USER

public static final java.lang.String WEBADE_USER
The attribute name for the User object in the HttpSession

See Also:
Constant Field Values

CURRENT_WEBADE_USER_PERMISSIONS

public static final java.lang.String CURRENT_WEBADE_USER_PERMISSIONS
The attribute name for the WebADEUserPermissions object in the HttpSession

See Also:
Constant Field Values

CURRENT_WEBADE_USER_INFO

public static final java.lang.String CURRENT_WEBADE_USER_INFO
The attribute name for the WebADEUserInfo object in the HttpSession

See Also:
Constant Field Values

WEBADE_FLOW_CONTROL_FLAG

public static final java.lang.String WEBADE_FLOW_CONTROL_FLAG
The attribute name for the flag used by the tag FlowControlTag to prevent users from calling JSPs directly.

See Also:
Constant Field Values

WEBADE_HAS_PREPROCESSED_REQUEST

public static final java.lang.String WEBADE_HAS_PREPROCESSED_REQUEST
The request attribute name for the flag indicating the WebADE has pre-processed this request.

See Also:
Constant Field Values
Constructor Detail

HttpRequestUtils

public HttpRequestUtils()
Method Detail

init

public static void init(javax.servlet.ServletConfig config,
                        javax.servlet.ServletContext context,
                        java.lang.String appCode)
Deprecated. Use WebAppInitializationUtils.initializeWebApp(javax.servlet.ServletContext, java.lang.String) instead.

Initialize the WebADE application's core settings. Deprecated because the config parameter was not being used. Calls the corrected method.

Parameters:
config - Servlet config.
context - Servlet context to create the application singleton in.
appCode - The application code used to load WebADE info for.

init

public static void init(javax.servlet.ServletContext context,
                        java.lang.String appCode)
Deprecated. Use WebAppInitializationUtils.initializeWebApp(javax.servlet.ServletContext, java.lang.String) instead.

Initialize the WebADE application's core settings.

Parameters:
context - Servlet context to create the application singleton in.
appCode - The application code used to load WebADE info for.

preprocessRequest

public static boolean preprocessRequest(javax.servlet.ServletContext context,
                                        javax.servlet.http.HttpServletRequest req,
                                        javax.servlet.http.HttpServletResponse res)
                                 throws javax.servlet.ServletException
Deprecated. Use WebAppRequestProcessingUtils.preprocessRequest(ServletContext, HttpServletRequest, HttpServletResponse)

Preprocess an HTTP request. Checks to see if the application has been disabled, or is improperly configured. Also checks to see if the application supports organization-selection or if the user has agreements to be agreed to.

Parameters:
context - The servlet context.
req - The incoming request.
res - The outgoing response.
Returns:
A boolean flag indicating whether to continue processing the request.
Throws:
javax.servlet.ServletException

postprocessRequest

public static void postprocessRequest(javax.servlet.ServletContext context,
                                      javax.servlet.http.HttpServletRequest req,
                                      javax.servlet.http.HttpServletResponse res)
                               throws javax.servlet.ServletException
Deprecated. Use WebAppRequestProcessingUtils.postprocessRequest(ServletContext, HttpServletRequest, HttpServletResponse)

Postprocess an HTTP request. Cleans up the WebADE request-based state after the request is processed.

Parameters:
context - The servlet context.
req - The incoming request.
res - The outgoing response.
Throws:
javax.servlet.ServletException

getCurrentUser

public static User getCurrentUser(javax.servlet.http.HttpSession session)
Deprecated. Use getCurrentUserPermissions(javax.servlet.http.HttpSession) and getCurrentUserInfo(javax.servlet.http.HttpSession) instead.

Returns the User object for the user making the request. The User object is obtained from the session if it exists, otherwise it is obtained from the request. This method assumes that the User object already exists (as will be the case in a WebADE application).

Parameters:
session - The user's session.
Returns:
The current user object.

getCurrentUser

public static User getCurrentUser(javax.servlet.http.HttpServletRequest req)
Deprecated. Use getCurrentUserPermissions(javax.servlet.http.HttpServletRequest) and getCurrentUserInfo(javax.servlet.http.HttpServletRequest) instead.

Returns the User object for the user making the request. The User object is obtained from the session if it exists, otherwise it is obtained from the request. This method assumes that the User object already exists (as will be the case in a WebADE application).

Parameters:
req - The request object.
Returns:
The current user object.

getCurrentUserPermissions

public static WebADECurrentUserPermissions getCurrentUserPermissions(javax.servlet.http.HttpSession session)
Returns the WebADEUserPermissions object for the user making the request. The WebADEUserPermissions object is obtained from the session if it exists, otherwise it is obtained from the request. This method assumes that the User object already exists (as will be the case in a WebADE application).

Parameters:
session - The user's session.
Returns:
The current user permissions object.

getCurrentUserPermissions

public static WebADECurrentUserPermissions getCurrentUserPermissions(javax.servlet.http.HttpServletRequest req)
Returns the WebADEUserPermissions object for the user making the request. The WebADEUserPermissions object is obtained from the session if it exists, otherwise it is obtained from the request. This method assumes that the User object already exists (as will be the case in a WebADE application).

Parameters:
req - The request object.
Returns:
The current user permissions object.

getCurrentUserInfo

public static WebADEUserInfo getCurrentUserInfo(javax.servlet.http.HttpSession session)
Returns the WebADEUserInfo object for the user making the request. The WebADEUserInfo object is obtained from the session if it exists, otherwise it is obtained from the request. This method assumes that the User object already exists (as will be the case in a WebADE application).

Parameters:
session - The user's session.
Returns:
The current user info object.

getCurrentUserInfo

public static WebADEUserInfo getCurrentUserInfo(javax.servlet.http.HttpServletRequest req)
Returns the WebADEUserInfo object for the user making the request. The WebADEUserInfo object is obtained from the session if it exists, otherwise it is obtained from the request. This method assumes that the User object already exists (as will be the case in a WebADE application).

Parameters:
req - The request object.
Returns:
The current user info object.

reloadCurrentUser

public static User reloadCurrentUser(javax.servlet.http.HttpServletRequest req)
                              throws WebADEException
Deprecated. Use reloadCurrentUserPermissions(javax.servlet.http.HttpServletRequest) and reloadCurrentUserInfo(javax.servlet.http.HttpServletRequest) instead.

Refreshes and returns the User object from the session for the user making the request. The User object is obtained from the session if it exists, otherwise it is obtained from the request.

Parameters:
req - The user's request.
Returns:
The current user object.
Throws:
WebADEException

reloadCurrentUserPermissions

public static WebADECurrentUserPermissions reloadCurrentUserPermissions(javax.servlet.http.HttpServletRequest req)
                                                                 throws WebADEException
Refreshes and returns the WebADECurrentUserPermissions object from the session for the user making the request. The WebADECurrentUserPermissions object is obtained from the session if it exists, otherwise it is obtained from the request.

Parameters:
req - The user's request.
Returns:
The current user permissions object.
Throws:
WebADEException

reloadCurrentUserInfo

public static WebADEUserInfo reloadCurrentUserInfo(javax.servlet.http.HttpServletRequest req)
                                            throws WebADEException
Refreshes and returns the WebADEUserInfo object from the session for the user making the request. The WebADEUserInfo object is obtained from the session if it exists, otherwise it is obtained from the request.

Parameters:
req - The user's request.
Returns:
The current user info object.
Throws:
WebADEException

isAnonymousRemoteUser

public static boolean isAnonymousRemoteUser(javax.servlet.http.HttpServletRequest req)
Tests if the remote user making this request is the anonymous user (eg has not been authenticated by the Web server).

Parameters:
req - The request object.
Returns:
Indicates if the user arrived at the site without authentication.

getApplication

public static Application getApplication(javax.servlet.ServletContext context)
A convenience method for web application code needing to access the Application object. The call is: Application app = HttpRequestUtils.getApplication(context);

Parameters:
context - Servlet context to retrieve the application singleton from.
Returns:
The application singleton.

getUserInfoService

public static UserInfoService getUserInfoService(javax.servlet.ServletContext context)
A convenience method for web application code needing to access the UserInfoService object. The call is: UserInfoService service = HttpRequestUtils.getUserInfoService(context);

Parameters:
context - Servlet context to retrieve UserInfoService singleton from.
Returns:
The UserInfoService singleton.