tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util PrefixMapper.java
Date Fri, 16 Jun 2000 17:09:18 GMT
costin      00/06/16 10:09:11

  Modified:    src/etc  server.xml
               src/share/org/apache/tomcat/context DefaultCMSetter.java
                        WorkDirInterceptor.java
               src/share/org/apache/tomcat/core ContextManager.java
               src/share/org/apache/tomcat/net ServerSocketFactory.java
               src/share/org/apache/tomcat/request AccessInterceptor.java
                        Jdk12Interceptor.java
               src/share/org/apache/tomcat/startup EmbededTomcat.java
                        Tomcat.java
               src/share/org/apache/tomcat/util PrefixMapper.java
  Log:
  - moved up WebXml reader - it does read context config, all other modules depend on it.
  
  - strange, the workdir setting was in DefaultCMSetter instead of WorkDirInterceptor.
  
  - in AccessInterceptor, moved the mapping to requestMap callback, so the information about
  required roles and transport is available to auth modules
  
  - leave SSL out of EmbededTomcat till we finish debugging the rest - it adds few seconds
  per startup.
  
  - removed the securityManager config
  
  - added code to finish context removal.
  
  Revision  Changes    Path
  1.24      +3 -2      jakarta-tomcat/src/etc/server.xml
  
  Index: server.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/etc/server.xml,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- server.xml	2000/06/15 00:26:41	1.23
  +++ server.xml	2000/06/16 17:08:04	1.24
  @@ -45,6 +45,9 @@
           
           <ContextInterceptor className="org.apache.tomcat.context.AutoSetup" />
   
  +        <ContextInterceptor 
  +            className="org.apache.tomcat.context.WebXmlReader" />
  +
           <!-- Uncomment out if you have JDK1.2 and want to use policy 
           <ContextInterceptor 
               className="org.apache.tomcat.context.PolicyInterceptor" />
  @@ -56,8 +59,6 @@
               className="org.apache.tomcat.context.DefaultCMSetter" />
           <ContextInterceptor 
               className="org.apache.tomcat.context.WorkDirInterceptor" />
  -        <ContextInterceptor 
  -            className="org.apache.tomcat.context.WebXmlReader" />
           <ContextInterceptor 
               className="org.apache.tomcat.context.LoadOnStartupInterceptor" />
   
  
  
  
  1.39      +2 -46     jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java
  
  Index: DefaultCMSetter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- DefaultCMSetter.java	2000/06/13 00:32:33	1.38
  +++ DefaultCMSetter.java	2000/06/16 17:08:08	1.39
  @@ -87,34 +87,9 @@
       {
   	setEngineHeader( ctx );
   
  -	if( ctx.getWorkDir() == null)
  -	    setWorkDir(ctx);
   
  -	if (! ctx.getWorkDir().exists()) {
  -	    //log  System.out.println("Creating work dir " + ctx.getWorkDir() );
  -	    ctx.getWorkDir().mkdirs();
  -	}
  -	ctx.setAttribute(Constants.ATTRIB_WORKDIR1, ctx.getWorkDir());
  -	ctx.setAttribute(Constants.ATTRIB_WORKDIR , ctx.getWorkDir());
  -
  -	// Set default session manager if none set
  -	ServletWrapper authWrapper=new ServletWrapper();
  -	authWrapper.setContext( ctx );
  -	authWrapper.setServletName( "tomcat.authServlet");
  -	String login_type=ctx.getAuthMethod();
  -	if( "BASIC".equals( login_type )) {
  -	    authWrapper.setServletClass( "org.apache.tomcat.servlets.BasicLoginServlet" );
  -	    ctx.addServlet( authWrapper );
  -	} else if( "FORM".equals( login_type )) {
  -	    authWrapper.setServletClass( "org.apache.tomcat.servlets.BasicLoginServlet" );
  -	    //authWrapper.setServletClass( "org.apache.tomcat.servlets.FormLoginServlet" );
  -	    ctx.addServlet( authWrapper );
  -	} else {
  -	    authWrapper.setServletClass( "org.apache.tomcat.servlets.BasicLoginServlet" );
  -	    ctx.addServlet( authWrapper );
  -	    //	    ctx.log("Unknown auth method " + login_type );
  -	}
  -	
  +	// XXX XXX this will go away - error handling needs to
  +	// be re-writen !!!!!! 
   	ServletWrapper errorWrapper=new ServletWrapper();
   	errorWrapper.setContext( ctx );
   	errorWrapper.setServletClass( "org.apache.tomcat.servlets.DefaultErrorPage" );
  @@ -134,25 +109,6 @@
       }
   
       // -------------------- implementation
  -    /** Encoded ContextManager.getWorkDir() + host + port + path
  -     */
  -    private void setWorkDir(Context ctx ) {
  -	ContextManager cm=ctx.getContextManager();
  -
  -	StringBuffer sb=new StringBuffer();
  -	sb.append(cm.getWorkDir());
  -	sb.append(File.separator);
  -	String host=ctx.getHost();
  -	if( host==null ) 
  -	    sb.append(cm.getHostName() );
  -	else
  -	    sb.append( host );
  -	sb.append("_").append(cm.getPort());
  -	sb.append(URLEncoder.encode( ctx.getPath() ));
  -	
  -	ctx.setWorkDir( new File(sb.toString()));
  -    }
  -    
       private void setEngineHeader(Context ctx) {
           String engineHeader=ctx.getEngineHeader();
   
  
  
  
  1.7       +52 -7     jakarta-tomcat/src/share/org/apache/tomcat/context/WorkDirInterceptor.java
  
  Index: WorkDirInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/WorkDirInterceptor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WorkDirInterceptor.java	2000/02/16 00:48:44	1.6
  +++ WorkDirInterceptor.java	2000/06/16 17:08:08	1.7
  @@ -75,21 +75,66 @@
    * @author costin@dnt.ro
    */
   public class WorkDirInterceptor extends BaseInterceptor {
  -
  +    boolean cleanWorkDir=false;
  +    
       public WorkDirInterceptor() {
       }
  +
  +    /** IMHO this shouldn't be used - if true, we'll loose
  +	all jsp compiled files. The workdir is the only directory
  +	where the servlet is allowed to write anyway ( if policy
  +	is used ).
  +
  +	In case this proves to be usefull, the property should
  +	belong to context.
  +    */
  +    public void setCleanWorkDir( boolean b ) {
  +	cleanWorkDir=b;
  +    }
   	
       public void contextInit(Context ctx) {
  -	// 	if (! ctx.isWorkDirPersistent()) {
  -	// 	    clearDir(ctx.getWorkDir() );
  -	//         }
  +	if( ctx.getWorkDir() == null)
  +	    setWorkDir(ctx);
  +
  +	if (! ctx.getWorkDir().exists()) {
  +	    //log  System.out.println("Creating work dir " + ctx.getWorkDir() );
  +	    ctx.getWorkDir().mkdirs();
  +	}
  +	ctx.setAttribute(Constants.ATTRIB_WORKDIR1, ctx.getWorkDir());
  +	ctx.setAttribute(Constants.ATTRIB_WORKDIR , ctx.getWorkDir());
  +
  +	if ( cleanWorkDir ) {
  +	    clearDir(ctx.getWorkDir() );
  +	}
       }
   
       public void contextShutdown( Context ctx ) {
  -	// 	if (! ctx.isWorkDirPersistent()) {
  -	//             clearDir(ctx.getWorkDir());
  -	// 	}
  +	if ( cleanWorkDir ) {
  +	    clearDir(ctx.getWorkDir());
  +	}
  +    }
  +
  +    // -------------------- Implementation --------------------
  +
  +    /** Encoded ContextManager.getWorkDir() + host + port + path
  +     */
  +    private void setWorkDir(Context ctx ) {
  +	ContextManager cm=ctx.getContextManager();
  +
  +	StringBuffer sb=new StringBuffer();
  +	sb.append(cm.getWorkDir());
  +	sb.append(File.separator);
  +	String host=ctx.getHost();
  +	if( host==null ) 
  +	    sb.append(cm.getHostName() );
  +	else
  +	    sb.append( host );
  +	sb.append("_").append(cm.getPort());
  +	sb.append(URLEncoder.encode( ctx.getPath() ));
  +	
  +	ctx.setWorkDir( new File(sb.toString()));
       }
  +    
   
       private void clearDir(File dir) {
           String[] files = dir.list();
  
  
  
  1.91      +9 -6      jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- ContextManager.java	2000/06/15 19:34:27	1.90
  +++ ContextManager.java	2000/06/16 17:08:08	1.91
  @@ -682,8 +682,8 @@
   	return 0;
       }
   
  -    /** Call all authentication callbacks. If any of them is able to identify the user
  -     *  it will set the principal in req.
  +    /** Call all authentication callbacks. If any of them is able to
  +	identify the user it will set the principal in req.
        */
       public int authenticate( Request req, Response res ) {
   	for( int i=0; i< requestInterceptors.size(); i++ ) {
  @@ -692,12 +692,14 @@
   	return 0;
       }
   
  -    /** Call all authorization callbacks. The "require valid user" attributes are probably
  -     *  set during the mapping stage ( for efficiency), but it can be done here too.
  +    /** Call all authorization callbacks. The "require valid user" attributes
  +	are probably set during the mapping stage ( for efficiency), but it
  +	can be done here too.
        */
       int authorize( Request req, Response res ) {
   	for( int i=0; i< requestInterceptors.size(); i++ ) {
  -	    int err = ((RequestInterceptor)requestInterceptors.elementAt(i)).authorize( req, res
);
  +	    int err = ((RequestInterceptor)requestInterceptors.elementAt(i)
  +		       ).authorize( req, res );
   	    if ( err != 0 ) {
   		if( debug>0) log( "Authorize result " + err );
   		return err;
  @@ -712,7 +714,8 @@
       */
       int doBeforeBody( Request req, Response res ) {
   	for( int i=0; i< requestInterceptors.size(); i++ ) {
  -	    ((RequestInterceptor)requestInterceptors.elementAt(i)).beforeBody( req, res );
  +	    ((RequestInterceptor)requestInterceptors.elementAt(i)
  +	     ).beforeBody( req, res );
   	}
   	return 0;
       }
  
  
  
  1.5       +0 -10     jakarta-tomcat/src/share/org/apache/tomcat/net/ServerSocketFactory.java
  
  Index: ServerSocketFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/net/ServerSocketFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ServerSocketFactory.java	2000/06/14 19:07:19	1.4
  +++ ServerSocketFactory.java	2000/06/16 17:08:26	1.5
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/net/ServerSocketFactory.java,v
1.4 2000/06/14 19:07:19 costin Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/06/14 19:07:19 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -92,12 +88,6 @@
    * @author db@eng.sun.com
    * @author Harish Prabandham
    */
  -
  -
  -//
  -// WARNING: Some of the APIs in this class are used by J2EE. 
  -// Please talk to harishp@eng.sun.com before making any changes.
  -//
   public abstract class ServerSocketFactory implements Cloneable {
   
       //
  
  
  
  1.6       +60 -27    jakarta-tomcat/src/share/org/apache/tomcat/request/AccessInterceptor.java
  
  Index: AccessInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/AccessInterceptor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AccessInterceptor.java	2000/05/30 16:46:44	1.5
  +++ AccessInterceptor.java	2000/06/16 17:08:38	1.6
  @@ -83,7 +83,7 @@
    *  concepts - I think we can do that, but need to experiment with that)
    */
   public class AccessInterceptor extends  BaseInterceptor  {
  -    int debug=0;
  +    int debug=20;
       ContextManager cm;
   
       // Security mapping note
  @@ -91,21 +91,21 @@
   
       // Required roles attribute
       int reqRolesNote;
  +    int reqTransportNote;
       
       public AccessInterceptor() {
       }
   
       /* -------------------- Support functions -------------------- */
  -    public void setDebug( int level ) {
  -	if(level!=0) log("SM: AccessInterceptor - set debug " + level);
  -	debug=level;
  +    public void setDebug( int i ) {
  +	System.out.println("setDebug " + i );
       }
  -
  +    
       void log( String msg ) {
   	if( cm==null) 
   	    System.out.println("AccessInterceptor: " + msg );
   	else
  -	    cm.log( msg );
  +	    cm.log( "AccessInterceptor: " + msg );
       }
   
   
  @@ -114,23 +114,52 @@
       /** Set the context manager. To keep it simple we don't support
        *  dynamic add/remove for this interceptor. 
        */
  -    public void setContextManager( ContextManager cm ) {
  +    public void engineInit(ContextManager cm) throws TomcatException {
  +	
   	super.setContextManager( cm );
   	
   	this.cm=cm;
   	// set-up a per/container note for maps
   	try {
  -	    secMapNote = cm.getNoteId( ContextManager.CONTAINER_NOTE, "map.security");
  -	    reqRolesNote = cm.getNoteId( ContextManager.REQUEST_NOTE, "required.roles");
  +	    secMapNote = cm.getNoteId( ContextManager.CONTAINER_NOTE,
  +				       "map.security");
  +	    // Used for inter-module communication - required role, tr
  +	    reqRolesNote = cm.getNoteId( ContextManager.REQUEST_NOTE,
  +					 "required.roles");
  +	    reqTransportNote = cm.getNoteId( ContextManager.REQUEST_NOTE,
  +					 "required.transport");
   	} catch( TomcatException ex ) {
   	    ex.printStackTrace();
   	    throw new RuntimeException( "Invalid state ");
   	}
       }
   
  +    public void contextInit( Context ctx)
  +	throws TomcatException
  +    {
  +	// Set default session manager if none set
  +	ServletWrapper authWrapper=new ServletWrapper();
  +	authWrapper.setContext( ctx );
  +	authWrapper.setServletName( "tomcat.authServlet");
  +	String login_type=ctx.getAuthMethod();
  +	if( "FORM".equals( login_type )) {
  +	    authWrapper.setServletClass( "org.apache.tomcat.servlets.FormLoginServlet" );
  +	} else if( "BASIC".equals( login_type )) {
  +	    authWrapper.setServletClass( "org.apache.tomcat.servlets.BasicLoginServlet" );
  +	} else {
  +	    // if unknown, leave the normal 404 error handler to deal
  +	    // with unauthorized access.
  +	}
  +
  +	if( debug > 0 ) log( "Init  " + ctx.getHost() + " " +
  +			     ctx.getPath() + " " + login_type );
  +	ctx.addServlet( authWrapper );
  +    }
  +    
       /** Called when a context is added.
        */
  -    public void addContext( ContextManager cm, Context ctx ) throws TomcatException
  +    public void addContext( ContextManager cm, Context ctx )
  +	throws TomcatException
       {
   	Container ct=ctx.getContainer();
   	ct.setNote( secMapNote, new SecurityConstraints() );
  @@ -139,7 +168,8 @@
       /** Called when a context is removed from a CM - we must ask the mapper to
   	remove all the maps related with this context
        */
  -    public void removeContext( ContextManager cm, Context ctx ) throws TomcatException
  +    public void removeContext( ContextManager cm, Context ctx )
  +	throws TomcatException
       {
   	// nothing - will go away with the ctx
       }
  @@ -158,10 +188,14 @@
       {
   	Context ctx=ct.getContext();
   	Container ctxCt=ctx.getContainer();
  -	SecurityConstraints ctxSecurityC=(SecurityConstraints)ctxCt.getNote( secMapNote );
  +	SecurityConstraints ctxSecurityC=(SecurityConstraints)ctxCt.
  +	    getNote( secMapNote );
   	
   	if( ct.getRoles()!=null || ct.getTransport()!=null ) {
  -	    if( ctx.getDebug() > 0 ) log( "ACCESS: Adding " + ctx.getHost() + " " + ctx.getPath()
+ " " + ct.getPath() );
  +	    if( debug > 0 )
  +		log( "ACCESS: Adding " + ctx.getHost() + " " +
  +		     ctx.getPath() + " " +
  +		     ct.getPath() );
   	    ctxSecurityC.addContainer( ct );
   	}
       }
  @@ -169,37 +203,36 @@
       /* -------------------- Request mapping -------------------- */
   
       /** Check if this request requires auth, and if so check the roles.
  -     *  This interceptor needs to be "up-chain" from security check interceptor.
  -     *  It is also possible to move this check at requestMap stage.
        */
  -    public int authorize( Request req, Response response )
  +    public int requestMap( Request req )
       {
   	Context ctx=req.getContext();
  -	SecurityConstraints ctxSec=(SecurityConstraints)ctx.getContainer().getNote( secMapNote
);
  +	SecurityConstraints ctxSec=(SecurityConstraints)ctx.getContainer().
  +	    getNote( secMapNote );
  +	log("XXX1 " + ctxSec + " " + debug);
   	if( ctxSec.patterns==0 ) return 0; // fast exit
   	
   	String reqURI = req.getRequestURI();
   	String ctxPath= ctx.getPath();
   	String path=reqURI.substring( ctxPath.length());
   	String method=req.getMethod();
  -
  -	if( ctx.getDebug() > 0 ) log( "ACCESS: checking " + path );
  +	
  +	if( debug > 1 ) log( "ACCESS: checking " + path );
   	
   	for( int i=0; i< ctxSec.patterns ; i++ ) {
   	    Container ct=ctxSec.securityPatterns[i];
   	    if( match( ct, path, method ) ) {
  -		log( "ACCESS: matched " + ct.getPath() + " " + ct.getMethods() + " " +
  -		     ct.getTransport() + " " + ct.getRoles());
  +		if( debug>0) log( "ACCESS: matched " + ct.getPath() + " " +
  +				  ct.getMethods() + " " +
  +				  ct.getTransport() + " " + ct.getRoles());
   		String roles[]=ct.getRoles();
   		String transport=ct.getTransport();
   
  -		if( transport != null && (
  -					  "INTEGRAL".equals( transport ) ||
  -					  "CONFIDENTIAL".equals( transport ))) {
  -		    // check if SSL is used
  -		    log( "ACCESS: SSL required " + req );
  +		if( transport != null &&
  +		    ! "NONE".equals( transport )) {
  +		    req.setNote( reqTransportNote, transport );
   		}
  -
  +	    
   		// roles will be checked by a different interceptor
   		req.setNote( reqRolesNote, roles );
   	    }
  
  
  
  1.7       +1 -1      jakarta-tomcat/src/share/org/apache/tomcat/request/Jdk12Interceptor.java
  
  Index: Jdk12Interceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/Jdk12Interceptor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Jdk12Interceptor.java	2000/06/13 00:32:38	1.6
  +++ Jdk12Interceptor.java	2000/06/16 17:08:38	1.7
  @@ -70,7 +70,7 @@
   /**
    *  JDK1.2 specific options. Fix the class loader, etc.
    */
  -public final class Jdk12Interceptor extends  BaseInterceptor implements RequestInterceptor
{
  +public final class Jdk12Interceptor extends  BaseInterceptor {
       private ContextManager cm;
       private int debug=0;
   
  
  
  
  1.4       +18 -10    jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java
  
  Index: EmbededTomcat.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EmbededTomcat.java	2000/06/15 18:51:01	1.3
  +++ EmbededTomcat.java	2000/06/16 17:08:55	1.4
  @@ -50,7 +50,7 @@
       String workDir;
       
       // configurable properties
  -    int debug=21;
  +    int debug=0;
       
       public EmbededTomcat() {
       }
  @@ -125,7 +125,10 @@
   	sc.setAttribute( "vhost_port" , new Integer( port ) );
   	if( addr != null ) sc.setAttribute( "vhost_address", addr );
   	if( hostname != null ) sc.setAttribute( "vhost_name", hostname );
  -	
  +
  +// 	sc.setAttribute( "socketFactory",
  +// 			 "org.apache.tomcat.net.SSLSocketFactory");
  +	System.out.println("XXX " + keyFile + " " + keyPass);
   	sc.setTcpConnectionHandler( new HttpConnectionHandler());
   	// XXX add the secure socket
   	
  @@ -173,13 +176,10 @@
   		return;
   	    }
   	    Context ctx=facadeM.getRealContext( sctx );
  -	    contextM.initContext( ctx );
  +	    contextM.removeContext( ctx );
   	} catch( Exception ex ) {
   	    ex.printStackTrace();
   	}
  -	// XXX todo
  -	// XXX Make sure we remove the HttpSecurityHandler:
  -	// 	HttpSecurityHandler.removeInstance(ctx);	
       }
   
   
  @@ -290,6 +290,10 @@
   	// no AutoSetup !
   	
   	// set workdir, engine header, auth Servlet, error servlet, loader
  +	WebXmlReader webXmlI=new WebXmlReader();
  +	webXmlI.setValidate( false );
  +	addContextInterceptor( webXmlI );
  +
   	PolicyInterceptor polI=new PolicyInterceptor();
   	addContextInterceptor( polI );
   
  @@ -299,9 +303,9 @@
   	DefaultCMSetter defaultCMI=new DefaultCMSetter();
   	addContextInterceptor( defaultCMI );
   
  -	WebXmlReader webXmlI=new WebXmlReader();
  -	webXmlI.setValidate( false );
  -	addContextInterceptor( webXmlI );
  +	WorkDirInterceptor wdI=new WorkDirInterceptor();
  +	addContextInterceptor( wdI );
  +
   	
   	LoadOnStartupInterceptor loadOnSI=new LoadOnStartupInterceptor();
   	addContextInterceptor( loadOnSI );
  @@ -314,18 +318,22 @@
   	addRequestInterceptor( sessI );
   
   	SimpleMapper1 mapI=new SimpleMapper1();
  -	//	mapI.setDebug(10);
   	addRequestInterceptor( mapI );
  +	//	mapI.setDebug(10);
   	
   	addRequestInterceptor( new StandardSessionInterceptor());
   	
   	// access control ( find if a resource have constraints )
   	AccessInterceptor accessI=new AccessInterceptor();
   	addRequestInterceptor( accessI );
  +	accessI.setDebug(20);
   
   	// set context class loader
   	Jdk12Interceptor jdk12I=new Jdk12Interceptor();
   	addRequestInterceptor( jdk12I );
  +
  +	// xXXX
  +	addRequestInterceptor( new SimpleRealm());
       }
       
   
  
  
  
  1.30      +0 -15     jakarta-tomcat/src/share/org/apache/tomcat/startup/Tomcat.java
  
  Index: Tomcat.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/Tomcat.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Tomcat.java	2000/06/15 00:26:50	1.29
  +++ Tomcat.java	2000/06/16 17:08:57	1.30
  @@ -136,21 +136,7 @@
   	xh.addRule("Server/Logger", 
   		   xh.addChild("addLogger", "org.apache.tomcat.logging.Logger") );
       }
  -    
   
  -    /** Setup a SecurityManager, this can only be called once or a
  -     *  SecurityException will be generated.
  -    */
  -    void setSecurityManager( XmlMapper xh ) {
  -        xh.addRule("Server/SecurityManager", xh.objectCreate("org.apache.tomcat.loader.SetSecurityManager"));
  -        xh.addRule("Server/SecurityManager", xh.setProperties());
  -//         xh.addRule("Server/SecurityManager/Permission",xh.methodSetter("setPermission",3));
  -//         xh.addRule("Server/SecurityManager/Permission",xh.methodParam(0,"className"));
  -//         xh.addRule("Server/SecurityManager/Permission",xh.methodParam(1,"attribute"));
  -//         xh.addRule("Server/SecurityManager/Permission",xh.methodParam(2,"value"));
  -//         xh.addRule("Server/SecurityManager",xh.addChild("addPermissions",null));
  -    }
  -
       /**
        * Return the configuration file we are processing.  If the
        * <code>-config filename</code> command line argument is not
  @@ -198,7 +184,6 @@
   	setHelper( xh );
   	setConnectorHelper( xh );
   	setLogHelper( xh );
  -        setSecurityManager( xh );
   
   	File f = getConfigFile(cm);
   	try {
  
  
  
  1.2       +37 -16    jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java
  
  Index: PrefixMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PrefixMapper.java	2000/05/01 23:07:48	1.1
  +++ PrefixMapper.java	2000/06/16 17:08:58	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java,v
1.1 2000/05/01 23:07:48 costin Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/05/01 23:07:48 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java,v
1.2 2000/06/16 17:08:58 costin Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/06/16 17:08:58 $
    *
    * ====================================================================
    *
  @@ -68,7 +68,7 @@
   import java.io.File;
   import java.net.MalformedURLException;
   import java.io.IOException;
  -import java.util.Hashtable;
  +import java.util.*;
   
   /** Prefix and exact mapping alghoritm.
    *XXX finish factoring out the creation of the map ( right now direct field access is
  @@ -83,13 +83,13 @@
       Hashtable vhostMaps=new Hashtable();
   
   
  -    SimpleHashtable prefixMappedServlets;
  -    SimpleHashtable exactMappedServlets;
  +    Hashtable prefixMappedServlets;
  +    Hashtable exactMappedServlets;
   
           // Cache the most recent mappings
       // Disabled by default ( since we haven't implemented
       // capacity and remove ). 
  -    SimpleHashtable mapCache;
  +    Hashtable mapCache;
       // By using TreeMap instead of SimpleMap you go from 143 to 161 RPS
       // ( at least on my machine )
       // Interesting - even if SimpleHashtable is faster than Hashtable
  @@ -105,34 +105,55 @@
   
       
       public PrefixMapper() {
  -	prefixMappedServlets=new SimpleHashtable();
  -	exactMappedServlets=new SimpleHashtable();
  -	mapCache=new SimpleHashtable();
  +	prefixMappedServlets=new Hashtable();
  +	exactMappedServlets=new Hashtable();
  +	mapCache=new Hashtable();
       }
   
       public void setMapCache( boolean v ) {
   	mapCacheEnabled=v;
       }
       
  -    public void removeMapping( String host, String path ) {
  -	// XXX not implemented
  -    }
  +//     public void removeMapping( String host, String path ) {
  +// 	// XXX not implemented
  +//     }
   
       /** Remove all mappings matching path
        */
       public void removeAllMappings( String host, String path ) {
  -	// XXX not implemented
  +	PrefixMapper vmap=this;
  +	if( host==null ) {
  +	    vmap=(PrefixMapper)vhostMaps.get(host);
  +	}
  +	
  +	// remove all paths starting with path
  +	Enumeration en=vmap.prefixMappedServlets.keys();
  +	while( en.hasMoreElements() ) {
  +	    String s=(String)en.nextElement();
  +	    if( s.startsWith( path ))
  +		vmap.prefixMappedServlets.remove( s );
  +	}
  +	
  +	en=vmap.exactMappedServlets.keys();
  +	while( en.hasMoreElements() ) {
  +	    String s=(String)en.nextElement();
  +	    if( s.startsWith( path ))
  +		vmap.exactMappedServlets.remove( s );
  +	}
  +	// reset the cache
  +	mapCache=new Hashtable();
  +	
       }
   
       /**
        */
  -    public void addMapping( String path, Object target ) {
  +    void addMapping( String path, Object target ) {
   	prefixMappedServlets.put( path, target);
       }
   
       /**
        */
  -    public void addExactMapping( String path, Object target ) {
  +    void addExactMapping( String path, Object target ) {
   	exactMappedServlets.put( path, target);
       }
       
  
  
  

Mime
View raw message