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/task ApacheConfig.java
Date Thu, 03 Feb 2000 23:05:28 GMT
costin      00/02/03 15:05:28

  Modified:    src/native/apache/jserv jserv_ajpv12.c
               src/share/org/apache/tomcat/core ContextManager.java
                        RequestImpl.java
               src/share/org/apache/tomcat/request SimpleMapper.java
               src/share/org/apache/tomcat/service/connector
                        Ajp12ConnectionHandler.java
               src/share/org/apache/tomcat/task ApacheConfig.java
  Log:
  - Added back ApacheConfig - it will generate the apache configuration file.
  XXX need to update the docs, the only config for apache is to Include tomcat-apache.conf
  ( probably that can also be automated !)
  
  - Updated Ajp12 to make use of the context and user informations from mod_jserv.
  Problems: mod_jserv will not send the context if setHandler is used ( zone
  works only for prefix mounts ).
  PathTranslated is broken ( for 2.2 servlet API).
  
  - As a result, Authentication works now in Apache + tomcat, with Apache dealing with user
  authentication and authorization. ( not integrated into automatic config, you need to
  set it up in apache.conf ).
  
  Revision  Changes    Path
  1.4       +3 -1      jakarta-tomcat/src/native/apache/jserv/jserv_ajpv12.c
  
  Index: jserv_ajpv12.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/apache/jserv/jserv_ajpv12.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jserv_ajpv12.c	1999/12/13 23:48:44	1.3
  +++ jserv_ajpv12.c	2000/02/03 23:05:26	1.4
  @@ -57,7 +57,7 @@
    * Description: ajpv1.2 protocol, used to call local or remote jserv hosts   *
    * Author:      Pierpaolo Fumagalli <ianosh@iname.com>                       *
    * Author:      Michal Mosiewicz <mimo@interdata.pl>                         *
  - * Version:     $Revision: 1.3 $                                            *
  + * Version:     $Revision: 1.4 $                                            *
    *****************************************************************************/
   #include "jserv.h"
   
  @@ -486,6 +486,8 @@
   	 * To get PATH_TRANSLATED, treat PATH_INFO as a URI path.
   	 * Need to re-escape it for this, since the entire URI was
   	 * un-escaped before we determined where the PATH_INFO began.
  +	 */
  +	/* XXX In 2.2 we need to add "contextPath" or zone to the path_info !!!!!
   	 */
   	request_rec *pa_req;
   
  
  
  
  1.32      +4 -0      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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- ContextManager.java	2000/02/03 07:11:51	1.31
  +++ ContextManager.java	2000/02/03 23:05:26	1.32
  @@ -148,6 +148,10 @@
               Context context = getContext((String)enum.nextElement());
               context.init();
   	}
  +
  +	// After all context are configured, we can generate Apache configs
  +	org.apache.tomcat.task.ApacheConfig apacheConfig=new  org.apache.tomcat.task.ApacheConfig();
  +	apacheConfig.execute( this );     
       }
       
       /** Will start the connectors and begin serving requests
  
  
  
  1.14      +16 -8     jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java
  
  Index: RequestImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- RequestImpl.java	2000/02/03 07:11:52	1.13
  +++ RequestImpl.java	2000/02/03 23:05:27	1.14
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v
1.13 2000/02/03 07:11:52 costin Exp $
  - * $Revision: 1.13 $
  - * $Date: 2000/02/03 07:11:52 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v
1.14 2000/02/03 23:05:27 costin Exp $
  + * $Revision: 1.14 $
  + * $Date: 2000/02/03 23:05:27 $
    *
    * ====================================================================
    *
  @@ -95,6 +95,7 @@
       protected String lookupPath; // everything after contextPath before ?
       protected String servletPath;
       protected String pathInfo;
  +    protected String pathTranslated;
   
       protected Hashtable parameters = new Hashtable();
       protected int contentLength = -1;
  @@ -117,16 +118,18 @@
       // Session
       // set by interceptors - the session id
       protected String reqSessionId;
  -    boolean sessionIdFromCookie=true;
  -    boolean sessionIdFromURL=false;
  +    protected boolean sessionIdFromCookie=true;
  +    protected boolean sessionIdFromURL=false;
       // cache- avoid calling SessionManager for each getSession()
       protected HttpSession serverSession;
   
   
       // LookupResult - used by sub-requests and
       // set by interceptors
  -    ServletWrapper handler = null;
  -    String mappedPath = null;
  +    protected String servletName;
  +    protected ServletWrapper handler = null;
  +    
  +    protected String mappedPath = null;
   
       protected String scheme;
       protected String method;
  @@ -240,7 +243,9 @@
   	// the real path for this ( i.e. the URI ).
   
   	// Check the PATH_TRANSLATED specs before changing!
  -	return context.getRealPath( getPathInfo() );
  +	if( pathTranslated==null)
  +	    pathTranslated=context.getRealPath( getPathInfo() );
  +	return pathTranslated;
       }
   
   
  @@ -249,6 +254,9 @@
       }
   
       public String getRemoteUser() {
  +	if( remoteUser!=null)
  +	    return remoteUser;
  +	
   	// Using the Servlet 2.2 semantics ...
   	//  return request.getRemoteUser();
   	java.security.Principal p = getUserPrincipal();
  
  
  
  1.6       +1 -2      jakarta-tomcat/src/share/org/apache/tomcat/request/SimpleMapper.java
  
  Index: SimpleMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/SimpleMapper.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SimpleMapper.java	2000/02/03 07:11:54	1.5
  +++ SimpleMapper.java	2000/02/03 23:05:27	1.6
  @@ -105,14 +105,13 @@
   	String path = rrequest.getRequestURI();
   	
   	Context ctx= this.getContextByPath(path);
  +	rrequest.setContext(ctx);
   	
   	// final fix on response & request
   	//		rresponse.setServerHeader(server.getServerHeader());
  -	
   	String ctxPath = ctx.getPath();
   	String pathInfo =path.substring(ctxPath.length(),
   					    path.length());
  -	rrequest.setContext(ctx);
   
   	String lookupPath=rrequest.getLookupPath();
   
  
  
  
  1.11      +45 -8     jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp12ConnectionHandler.java
  
  Index: Ajp12ConnectionHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp12ConnectionHandler.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Ajp12ConnectionHandler.java	2000/02/01 22:53:32	1.10
  +++ Ajp12ConnectionHandler.java	2000/02/03 23:05:27	1.11
  @@ -195,32 +195,68 @@
   
   	    case 1: //beginning of request
   		method = ajpin.readString(null);              //Method
  -		dummy = ajpin.readString(null);               //Zone
  -		dummy = ajpin.readString(null);         //Servlet
  +
  +		contextPath = ajpin.readString(null);               //Zone
  +		if("ROOT".equals( contextPath ) ) contextPath="";
  +		//		System.out.println("AJP: CP=" + contextPath);
  +		if( contextPath!= null )
  +		    context=contextM.getContext( contextPath );
  +		
  +		servletName = ajpin.readString(null);         //Servlet
  +		
  +		//		System.out.println("AJP: servlet=" + servletName );
  +		
   		serverName = ajpin.readString(null);            //Server hostname
  +
   		dummy = ajpin.readString(null);               //Apache document root
  -		dummy = ajpin.readString(null);               //Apache parsed path-info
  -		dummy = ajpin.readString(null);               //Apache parsed path-translated
  +		
  +		pathInfo = ajpin.readString(null);               //Apache parsed path-info
  +		//		System.out.println("AJP: PI=" + pathInfo );
  +
  +		// XXX Bug in mod_jserv !!!!!
  +		pathTranslated = ajpin.readString(null);               //Apache parsed path-translated
  +		//		System.out.println("AJP: PT=" + pathTranslated );
  +		
   		queryString = ajpin.readString(null);         //query string
   		remoteAddr = ajpin.readString("");            //remote address
   		remoteHost = ajpin.readString("");            //remote host
  -		dummy = ajpin.readString(null);                 //remote user
  -		dummy = ajpin.readString(null);                 //auth type
  +		
  +		remoteUser = ajpin.readString(null);                 //remote user
  +		//		System.out.println("Remote User: " + remoteUser);
  +		
  +		authType = ajpin.readString(null);                 //auth type
  +		
   		dummy = ajpin.readString(null);                 //remote port
  -		dummy = ajpin.readString(null);                //request method
  +		
  +		method = ajpin.readString(null);                //request method
  +		//		System.out.println("AJP: Meth=" + method );
  +		
   		requestURI = ajpin.readString("");             //request uri
  +		if(contextPath!=null && contextPath.length() >0 )
  +		    lookupPath=requestURI.substring( contextPath.length() + 1 );
  +		//		System.out.println("AJP: URI: " + requestURI + " CP:" + contextPath + " LP: " + lookupPath);
  +		
   		dummy = ajpin.readString(null);                   //script filename
  +		//		System.out.println("AJP: Script filen=" + dummy);
  +		
   		dummy = ajpin.readString(null);                   //script name
  +		//		System.out.println("AJP: Script name=" + dummy);
  +		
   		serverName = ajpin.readString("");                //server name
   		try {
   		    serverPort = Integer.parseInt(ajpin.readString("80")); //server port
   		} catch (Exception any) {
   		    serverPort = 80;
   		}
  -		dummy = ajpin.readString("");                     //server protocol 
  +		
  +		dummy = ajpin.readString("");                     //server protocol
  +		//		System.out.println("AJP: Server proto=" + dummy);
   		dummy = ajpin.readString("");                     //server signature
  +		//		System.out.println("AJP: Server sign=" + dummy);
   		dummy = ajpin.readString("");                     //server software
  +		//		System.out.println("AJP: Server softw=" + dummy);
   		dummy = ajpin.readString("");                     //JSERV ROUTE
  +		//		System.out.println("AJP: JServ Route=" + dummy);
                   /**
                    * The two following lines are commented out because we don't 
                    * want to depend on unreleased versions of the jserv module. 
  @@ -285,6 +321,7 @@
   	    throw ioe;
           } catch (Exception e) {
   	    System.err.println("Uncaught exception" + e);
  +	    e.printStackTrace();
           }
   	
   	// REQUEST_URI includes query string 
  
  
  
  1.2       +66 -13    jakarta-tomcat/src/share/org/apache/tomcat/task/ApacheConfig.java
  
  Index: ApacheConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/task/ApacheConfig.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApacheConfig.java	2000/01/25 03:04:20	1.1
  +++ ApacheConfig.java	2000/02/03 23:05:28	1.2
  @@ -73,18 +73,49 @@
    */
   public class ApacheConfig  { // implements XXX
       // XXX maybe conf/
  -    public static final String APACHE_CONFIG="/etc/tomcat-apache.conf";
  +    public static final String APACHE_CONFIG="/conf/tomcat-apache.conf";
       
       public ApacheConfig() {
       }
   
  +    String findApache() {
  +	return null;
  +    }
  +    
       public void execute(ContextManager cm) throws TomcatException {
   	try {
   	    String tomcatHome= cm.getHome();
  +	    String apacheHome=findApache();
  +	    
   	    System.out.println("Tomcat home= " + tomcatHome);
   	    
   	    FileWriter configW=new FileWriter( tomcatHome + APACHE_CONFIG);
   	    PrintWriter pw=new PrintWriter( configW );
  +
  +	    if( System.getProperty( "os.name" ).equalsIgnoreCase("windows") ) {
  +		pw.println("LoadModule jserv_module modules/ApacheModuleJServ.dll");
  +	    } else {
  +		// XXX XXX change it to mod_jserv_${os.name}.so, put all so in tomcat
  +		// home
  +		pw.println("LoadModule jserv_module libexec/mod_jserv.so");
  +	    }
  +
  +	    pw.println("ApJServManual on");
  +	    pw.println("ApJServDefaultProtocol ajpv12");
  +	    pw.println("ApJServSecretKey DISABLED");
  +	    pw.println("ApJServMountCopy on");
  +	    pw.println("ApJServLogLevel notice");
  +	    pw.println();
  +	    
  +	    // XXX read it from ContextManager
  +	    pw.println("ApJServDefaultPort 8007");
  +
  +	    pw.println();
  +	    pw.println("AddType test/jsp .jsp");
  +	    pw.println("AddHandler jserv-servlet .jsp");
  +
  +	    
  +	    // Set up contexts 
   	    
   	    Enumeration enum = cm.getContextNames();
   	    while (enum.hasMoreElements()) {
  @@ -93,23 +124,44 @@
   		if( path.length() > 1) {
   		    // It's not the root context
   		    // assert path.startsWith( "/" )
  +
  +		    // Static files will be served by Apache
   		    pw.println("Alias " + path + " " + tomcatHome + "/webapps" + path);
  +
  +		    // Dynamic /servet pages go to tomcat
   		    pw.println("ApJServMount " + path +"/servlet" + " " + path);
  +
  +		    // Deny WEB-INF
   		    pw.println("<Location " + path + "/WEB-INF/ >");
   		    pw.println("    AllowOverride None");
   		    pw.println("    deny from all");
   		    pw.println("</Location>");
   		    pw.println();
  -		    pw.println("<Location " + path + "/servlet/ >");
  -		    pw.println("    AllowOverride None");
  -		    pw.println("    SetHandler jserv-servlet");
  -		    pw.println("</Location>");
  -		    pw.println();
  -		    pw.println("<Location " + path + " >");
  -		    pw.println("    AllowOverride None");
  -		    pw.println("    AddHandler jserv-servlet .jsp");
  -		    pw.println("    Options Indexes");
  -		    pw.println("</Location>");
  +
  +		    // SetHandler broken in jserv ( no zone is sent )
  +		    // 		    pw.println("<Location " + path + "/servlet/ >");
  +		    // 		    pw.println("    AllowOverride None");
  +		    // 		    pw.println("    SetHandler jserv-servlet");
  +		    // 		    pw.println("</Location>");
  +		    // 		    pw.println();
  +
  +		    // XXX check security
  +		    if( false ) {
  +			pw.println("<Location " + path + "/servlet/ >");
  +			pw.println("    AllowOverride None");
  +			pw.println("   AuthName \"restricted \"");
  +			pw.println("    AuthType Basic");
  +			pw.println("    AuthUserFile conf/users");	    
  +			pw.println("    require valid-user");
  +			pw.println("</Location>");
  +		    }
  +				    
  +		    // SetHandler broken in jserv ( no zone is sent )
  +		    // 		    pw.println("<Location " + path + " >");
  +		    // 		    pw.println("    AllowOverride None");
  +		    // 		    pw.println("    AddHandler jserv-servlet .jsp");
  +		    // 		    pw.println("    Options Indexes");
  +		    // 		    pw.println("</Location>");
   
   		    // XXX ErrorDocument
   
  @@ -126,8 +178,9 @@
   
   	    pw.close();
   	} catch( Exception ex ) {
  -	    ex.printStackTrace();
  -	    throw new TomcatException( "Error generating Apache config", ex );
  +	    //	    ex.printStackTrace();
  +	    //throw new TomcatException( "Error generating Apache config", ex );
  +	    System.out.println("Failed to generate automactic apache confiugration " + ex.toString());
   	}
   	    
       }
  
  
  

Mime
View raw message