tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/servlet JspServlet.java
Date Thu, 14 Dec 2000 23:55:18 GMT
craigmcc    00/12/14 15:55:18

  Modified:    jasper/src/share/org/apache/jasper/servlet JspServlet.java
  Log:
  Encapsulate the creation of a new class loader in a doPrivileged() action
  so that it works correctly when Tomcat is run underneath a security
  manager.
  
  Submitted by:	Vivek Nagar <vivek.nagar@eng.sun.com>
  
  Revision  Changes    Path
  1.8       +23 -9     jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/servlet/JspServlet.java
  
  Index: JspServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/servlet/JspServlet.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JspServlet.java	2000/11/06 20:52:30	1.7
  +++ JspServlet.java	2000/12/14 23:55:17	1.8
  @@ -73,6 +73,9 @@
   import java.io.IOException;
   import java.io.FileNotFoundException;
   
  +import java.security.AccessController;
  +import java.security.PrivilegedAction;
  +
   import org.apache.jasper.JasperException;
   import org.apache.jasper.Constants;
   import org.apache.jasper.Options;
  @@ -271,16 +274,27 @@
   	//	System.out.println("JspServlet: init " + config.getServletName() );
   	if( loader==null ) {
   	    if( jdk12 ) {
  -		try {
  -		    Class ld=Class.forName("org.apache.jasper.servlet.JasperLoader12");
  -		    loader=(JasperLoader)ld.newInstance();
  -		} catch(Throwable t ) {
  -		    loghelper.log("Loading org.apache.jasper.servlet.JasperLoader12", t);
  -		}
  +                class createLoader12 implements PrivilegedAction {
  +                    public Object run() {
  +                        return
  +                            (new org.apache.jasper.servlet.JasperLoader12());
  +                    }
  +                }
  +                createLoader12 cl = new createLoader12();
  +                loader = (org.apache.jasper.servlet.JasperLoader)
  +                    AccessController.doPrivileged(cl);
   	    }
  -	    if( loader==null )
  -		loader = new org.apache.jasper.servlet.JasperLoader();
  -
  +	    if( loader==null ) {
  +                class createLoader implements PrivilegedAction {
  +                    public Object run() {
  +                        return
  +                            (new org.apache.jasper.servlet.JasperLoader());
  +                    }
  +                }
  +                createLoader cl = new createLoader();
  +                loader = (org.apache.jasper.servlet.JasperLoader)
  +                    AccessController.doPrivileged(cl);
  +            }
   	    loader.setParentClassLoader(parentClassLoader);
   	    loader.setOptions(options);
   	    Object pd=context.getAttribute("org.apache.tomcat.protection_domain");
  
  
  

Mime
View raw message