org.mmbase.servlet
Class JamesServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--org.mmbase.servlet.JamesServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
performance, remoteXML, servdb, servflash, servjumpers, servscan, SimpleFormToMailServlet

public class JamesServlet
extends javax.servlet.http.HttpServlet

JamesServlet is a addaptor class its used to extend the basic Servlet to with the calls that where/are needed for 'James' servlets to provide services not found in suns Servlet API.

Version:
$Id: JamesServlet.java,v 1.28.2.1 2001/07/30 13:18:43 gerard Exp $
See Also:
Serialized Form

Constructor Summary
JamesServlet()
           
 
Method Summary
protected  void debug(java.lang.String msg)
          Debug method for logging.
 void decRefCount(javax.servlet.http.HttpServletRequest req)
          Decrease the reference count of the servlet (for debugging)
protected  void finalize()
          Notifies through logging that the servlet was removed.
 java.lang.String getAddress(javax.servlet.http.HttpServletRequest req)
          Extract hostname from request, get address and determine the proxies between it.
 java.lang.String getAuthorization(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Try to get the default authorisation
 java.lang.String getAuthorization(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.lang.String server, java.lang.String level)
          Authenticates a user, If the user cannot be authenticated a login-popup will appear
 java.lang.String getCookie(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          This method retrieves the users' MMBase cookie name & value as 'name/value'.
protected  java.util.Hashtable getInitParameters()
          Retrieves all initialization parameters.
protected  java.lang.Object getModule(java.lang.String name)
          Retrieves a module.
 java.lang.String getParam(javax.servlet.http.HttpServletRequest req, int num)
          Get the parameter specified.
 java.util.Vector getParamVector(javax.servlet.http.HttpServletRequest req)
          Get the Vector containing all parameters
protected  java.util.Hashtable getProperties(java.lang.String name)
          Gets properties.
protected  java.lang.String getProperty(java.lang.String name, java.lang.String var)
          Gets a property out of the Environment.
static java.lang.String getRequestURL(javax.servlet.http.HttpServletRequest req)
          Return URI with QueryString appended
 void incRefCount(javax.servlet.http.HttpServletRequest req)
          Increase the reference count of the servlet (for debugging)
 void init(javax.servlet.ServletConfig config)
          Initializes the servlet.
 boolean isInternalVPROAddress(javax.servlet.http.HttpServletRequest req)
          Determines if a user comes from an internal or external host, i.e.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JamesServlet

public JamesServlet()
Method Detail

debug

protected void debug(java.lang.String msg)
Debug method for logging. obsolete

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initializes the servlet.
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - the servlet configuration

getModule

protected final java.lang.Object getModule(java.lang.String name)
Retrieves a module. Creates the module if it hasn't been created yet (but does not initialize).
Parameters:
name - the name of the module to retrieve
Returns:
the Module, or null if it doesn't exist.

getInitParameters

protected final java.util.Hashtable getInitParameters()
Retrieves all initialization parameters. Note: overides the normal way to set init params in javax.

getProperties

protected final java.util.Hashtable getProperties(java.lang.String name)
Gets properties. If allowed.

getProperty

protected final java.lang.String getProperty(java.lang.String name,
                                             java.lang.String var)
Gets a property out of the Environment. If allowed

getAuthorization

public java.lang.String getAuthorization(javax.servlet.http.HttpServletRequest req,
                                         javax.servlet.http.HttpServletResponse res)
                                  throws java.lang.Exception
Try to get the default authorisation
Parameters:
req - The HttpServletRequest.
res - The HttpServletResponse.
Throws:
AuthorizationException - if the authorization fails.
NotLoggedInException - if the user hasn't logged in yet.

getAuthorization

public java.lang.String getAuthorization(javax.servlet.http.HttpServletRequest req,
                                         javax.servlet.http.HttpServletResponse res,
                                         java.lang.String server,
                                         java.lang.String level)
                                  throws AuthorizationException,
                                         NotLoggedInException
Authenticates a user, If the user cannot be authenticated a login-popup will appear
Parameters:
req - The HttpServletRequest.
res - The HttpServletResponse.
server - server-account. (for exameple 'film' or 'www')
level - loginlevel. (for example 'Basic' or 'MD5')
Throws:
AuthorizationException - if the authorization fails.
NotLoggedInException - if the user hasn't logged in yet.

getCookie

public java.lang.String getCookie(javax.servlet.http.HttpServletRequest req,
                                  javax.servlet.http.HttpServletResponse res)
This method retrieves the users' MMBase cookie name & value as 'name/value'. When the cookie can't be found, a new cookie will be added. When an old James cookie is found, the related MMBaseProperty 'value' field will be replaced with a new MMBase cookie name & value. The cookies domain will be implicit or explicit depending on the MMBASEROOT.properties value.
Parameters:
req - The HttpServletRequest.
res - The HttpServletResponse.
Returns:
A String with the users' MMBase cookie as 'name/value' or null when MMBase core module can't be found, or when the MMBase cookie is located but can't be retrieved from the cookies list.

getParam

public java.lang.String getParam(javax.servlet.http.HttpServletRequest req,
                                 int num)
Get the parameter specified.
Parameters:
req - The HttpServletRequest.

getParamVector

public java.util.Vector getParamVector(javax.servlet.http.HttpServletRequest req)
Get the Vector containing all parameters
Parameters:
req - The HttpServletRequest.

getRequestURL

public static java.lang.String getRequestURL(javax.servlet.http.HttpServletRequest req)
Return URI with QueryString appended
Parameters:
req - The HttpServletRequest.

decRefCount

public void decRefCount(javax.servlet.http.HttpServletRequest req)
Decrease the reference count of the servlet (for debugging)
Parameters:
req - The HttpServletRequest.

incRefCount

public void incRefCount(javax.servlet.http.HttpServletRequest req)
Increase the reference count of the servlet (for debugging)
Parameters:
req - The HttpServletRequest.

finalize

protected void finalize()
Notifies through logging that the servlet was removed.
Overrides:
finalize in class java.lang.Object

isInternalVPROAddress

public boolean isInternalVPROAddress(javax.servlet.http.HttpServletRequest req)
Determines if a user comes from an internal or external host, i.e. when using two streaming servers, one for external users and one for internal users.
XXX: uses VPROProxyName, VPROProxyAddress, VPRODomain. Should be made more generic by using propertie values in mmbaseroot (?). The name of the method should be changed (i.e to isInternalAddres)
Parameters:
req - The HTTP request, which contains hostname as ipaddress
Returns:
true if the user is internal, false if external.

getAddress

public java.lang.String getAddress(javax.servlet.http.HttpServletRequest req)
Extract hostname from request, get address and determine the proxies between it. Needed to determine if user a comes from an internal or external host, i.e. when using two streaming servers, one for external users and one for internal users.
XXX: uses VPROProxyName, VPROProxyAddress, VPRODomain. Should be made more generic.
Parameters:
req - The HTTP request, which contains hostname as ipaddress
Returns:
a string containing the proxy chain. in the format "clientproxy.clientside.com->dialin07.clientside.com"


MMBase 2001