EAF 7.4 Implementation

com.lutris.appserver.server
Class StandardAppUtil

java.lang.Object
  extended by com.lutris.appserver.server.StandardAppUtil

public class StandardAppUtil
extends java.lang.Object

Static methods used by StandardApplication. These mostly are used to manage sessions.

Version:
$Revision: 1.8 $
Author:
Mark Diekhans, Richard Kunze

Field Summary
static java.lang.String ENHYDRA_SESSION_ID_COOKIE
           
static java.lang.String ENHYDRA_SESSION_ID_URL
           
 
Method Summary
static void bindSessionToClient(HttpPresentationComms comms)
          Associate a new StandardSession to a client cookie.
static java.lang.String encodeUrl(java.lang.String url, java.lang.String id)
          Encode a URL with a session identifier.
static java.net.InetAddress[] getPeerAddress(HttpPresentationComms comms)
          Get internet peer address.
static com.lutris.appserver.server.session.Session getRequestSession(HttpPresentationComms comms)
          Determine if a session exists for this request.
static com.lutris.appserver.server.session.Session getRequestSession(javax.servlet.ServletRequest request, com.lutris.appserver.server.Application application)
          This is a rarely used utility function.
static boolean pointsToPO(java.lang.String url)
          Determine if a URL references a presentation object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENHYDRA_SESSION_ID_URL

public static final java.lang.String ENHYDRA_SESSION_ID_URL
See Also:
Constant Field Values

ENHYDRA_SESSION_ID_COOKIE

public static final java.lang.String ENHYDRA_SESSION_ID_COOKIE
See Also:
Constant Field Values
Method Detail

getPeerAddress

public static java.net.InetAddress[] getPeerAddress(HttpPresentationComms comms)
                                             throws com.lutris.appserver.server.ApplicationException
Get internet peer address.

Parameters:
comms - The presentations manager comms object with all request/response information in it.
Returns:
The peer address.
Throws:
ApplicationException - If address can't be obtained.

encodeUrl

public static java.lang.String encodeUrl(java.lang.String url,
                                         java.lang.String id)
Encode a URL with a session identifier.

Parameters:
url - The url to encode.
id - The session identifier to encode with the url.

pointsToPO

public static boolean pointsToPO(java.lang.String url)
Determine if a URL references a presentation object. Used for URL rewriting to test if a session ID should be appended to a given URL. Takes the cheap way out at the moment in that it simply returns true iff (if and only if, for the non-mathematicians :-) the URL contains the character sequence .po.
TODO: Implement a better check A safety check has been added by Petr Stehlik on 2002/11/05 First, it strips a query and fragment parts of the URL, since both the query and the fragment may contain ".po" that confuses the original algorithm.
Example: http://www.server.org/path/file.html?query=page.po
The function now correctly returns false for the URL above.

Parameters:
url - The url to check
Returns:
True if the URL points to a PO, false otherwise

getRequestSession

public static com.lutris.appserver.server.session.Session getRequestSession(HttpPresentationComms comms)
                                                                     throws com.lutris.appserver.server.ApplicationException
Determine if a session exists for this request. Does not validate that a session is logged in.

Parameters:
comms - The presentations manager comms object with all request/response information in it.
Returns:
The session object or null if a session cookie or matching session is not found.
Throws:
ApplicationException - If address can't be obtained.

getRequestSession

public static com.lutris.appserver.server.session.Session getRequestSession(javax.servlet.ServletRequest request,
                                                                            com.lutris.appserver.server.Application application)
                                                                     throws com.lutris.appserver.server.ApplicationException
This is a rarely used utility function. Give a raw ServletRequest, the session cookie used to look up the session object that would be used with the request if it were passed into the Enhydra framework. Returns null if no cookie or session is found; a new session will not be created. Currently this is only used to support the debugger.

Parameters:
request - The raw request.
application - The application that will be servicing the request.
Returns:
The session object that would be used if the request were passed into the Enhydra framework, or null if not found (no new session will be created).
Throws:
com.lutris.appserver.server.ApplicationException

bindSessionToClient

public static void bindSessionToClient(HttpPresentationComms comms)
                                throws com.lutris.appserver.server.ApplicationException
Associate a new StandardSession to a client cookie.

Parameters:
comms - The presentations manager comms object with all request/response information in it.
Throws:
ApplicationException - If address can't be obtained.

EAF 7.4 Implementation