org.mmbase.servlet
Class JamesServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byorg.mmbase.servlet.MMBaseServlet
              extended byorg.mmbase.servlet.JamesServlet
All Implemented Interfaces:
org.mmbase.servlet.MMBaseStarter, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
servdb, servflash, servjumpers, servscan, SimpleFormToMailServlet

public class JamesServlet
extends MMBaseServlet

JamesServlet is a adaptor class. It is used to extend the basic Servlet to provide services not found in suns Servlet API.

Version:
$Id: JamesServlet.java,v 1.44 2004/01/15 23:21:49 michiel Exp $
Author:
vpro
See Also:
Serialized Form
Warning: Contains Duplicate Code (present in other classes)
this code is aimed at the SCAN servlets, and some features (i.e. cookies) do not communicate well with jsp pages. Functionality might need to be moved or adapted so that it uses the MMCI.

Field Summary
protected static Logger pageLog
           
 
Fields inherited from class org.mmbase.servlet.MMBaseServlet
mmbase
 
Constructor Summary
JamesServlet()
           
 
Method Summary
 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.
 void init()
          Initializes the servlet.
 
Methods inherited from class org.mmbase.servlet.MMBaseServlet
associateMapping, decRefCount, destroy, doGet, getAssociations, getMMBase, getRequestURL, getServletByAssociation, getServletByMapping, getServletInfo, getServletMappings, getServletMappingsByAssociation, incRefCount, service, setInitException, setMMBase
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pageLog

protected static Logger pageLog
Constructor Detail

JamesServlet

public JamesServlet()
Method Detail

init

public void init()
          throws javax.servlet.ServletException
Initializes the servlet.

Overrides:
init in class MMBaseServlet
Throws:
javax.servlet.ServletException

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.
To Do:
type returned should be Module

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 AuthorizationException,
                                         NotLoggedInException
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. 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.
Warning: Contains Dependency Found
org.mmbase.module.builder.Properties should not depend on this builder ?

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.

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 comes from an internal or external host, i.e. when using two streaming servers, one for external users and one for internal users.

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"
Warning: No Java Documentation Available.

Warning: Contains VPRO Legacy Code
uses VPROProxyName, VPROProxyAddress. Should be made more generic.


MMBase build 1.7.1.20041002