jfarcand    2003/02/26 10:37:46

  Modified:    catalina/src/share/org/apache/catalina/core
                        ApplicationContext.java
  Log:
  More missing doPrivilege blocks.
  
  Revision  Changes    Path
  1.8       +97 -16    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
  
  Index: ApplicationContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ApplicationContext.java   27 Jan 2003 22:19:24 -0000      1.7
  +++ ApplicationContext.java   26 Feb 2003 18:37:43 -0000      1.8
  @@ -133,7 +133,49 @@
   public class ApplicationContext
       implements ServletContext {
   
  +    protected class PrivilegedGetInitParameter
  +        implements PrivilegedAction {
  +            
  +        private String name;
  +
  +        PrivilegedGetInitParameter(String name){
  +            this.name = name;
  +        }
  +        
  +        public Object run(){
  +            return ((String) parameters.get(name));
  +        }
  +    }
  +    
  +    
  +    protected class PrivilegedGetInitParameterNames
  +        implements PrivilegedAction {
  +
  +        PrivilegedGetInitParameterNames(){
  +        }
   
  +        public Object run() {
  +            return (new Enumerator(parameters.keySet()));
  +        }
  +    }        
  +
  +    protected class PrivilegedGetNamedDispatcher
  +        implements PrivilegedAction {
  +
  +        private Wrapper wrapper;
  +        private String name;
  +        
  +        PrivilegedGetNamedDispatcher(Wrapper wrapper, String name) {
  +            this.wrapper = wrapper;
  +            this.name = name;
  +        }
  +
  +        public Object run() {
  +            return new ApplicationDispatcher(wrapper, null, null, null, name);
  +        }
  +    }
  +    
  +    
       protected class PrivilegedGetRequestDispatcher
           implements PrivilegedAction {
   
  @@ -422,13 +464,19 @@
        *
        * @param name Name of the initialization parameter to retrieve
        */
  -    public String getInitParameter(String name) {
  +    public String getInitParameter(final String name) {
   
           mergeParameters();
           synchronized (parameters) {
  -            return ((String) parameters.get(name));
  +            if (System.getSecurityManager() != null){
  +                PrivilegedGetInitParameter ip =
  +                    new PrivilegedGetInitParameter(name);
  +                return (String)AccessController.doPrivileged(ip);
  + 
  +            } else {
  +               return ((String) parameters.get(name));
  +            }                   
           }
  -
       }
   
   
  @@ -440,7 +488,13 @@
   
           mergeParameters();
           synchronized (parameters) {
  -            return (new Enumerator(parameters.keySet()));
  +            if (System.getSecurityManager() != null){
  +                PrivilegedGetInitParameterNames pn =
  +                    new PrivilegedGetInitParameterNames();
  +                return (Enumeration)AccessController.doPrivileged(pn);
  +            } else {
  +               return (new Enumerator(parameters.keySet()));
  +            }
           }
   
       }
  @@ -503,8 +557,17 @@
           Wrapper wrapper = (Wrapper) context.findChild(name);
           if (wrapper == null)
               return (null);
  -        ApplicationDispatcher dispatcher =
  -          new ApplicationDispatcher(wrapper, null, null, null, name);
  +        
  +        ApplicationDispatcher dispatcher;
  +        if (System.getSecurityManager() != null){
  +            PrivilegedGetNamedDispatcher nd = 
  +                    new PrivilegedGetNamedDispatcher(wrapper, name);
  +            dispatcher = (ApplicationDispatcher)AccessController.doPrivileged(nd);
  +        } else {
  +            dispatcher =
  +              new ApplicationDispatcher(wrapper, null, null, null, name);
  +        }
  +        
           return ((RequestDispatcher) dispatcher);
   
       }
  @@ -745,9 +808,18 @@
        * @deprecated As of Java Servlet API 2.1, with no direct replacement.
        */
       public Enumeration getServletNames() {
  -
  -        return (new Enumerator(empty));
  -
  +        if (System.getSecurityManager() != null){
  +            return (Enumeration)AccessController.doPrivileged(
  +                new PrivilegedAction(){
  +                    
  +                    public Object run(){
  +                        return (new Enumerator(empty)); 
  +                    }
  +                }
  +            );
  +        } else {
  +            return (new Enumerator(empty));
  +        }
       }
   
   
  @@ -755,9 +827,18 @@
        * @deprecated As of Java Servlet API 2.1, with no direct replacement.
        */
       public Enumeration getServlets() {
  -
  -        return (new Enumerator(empty));
  -
  +        if (System.getSecurityManager() != null){
  +            return (Enumeration)AccessController.doPrivileged(
  +                new PrivilegedAction(){
  +                    
  +                    public Object run(){
  +                        return (new Enumerator(empty)); 
  +                    }
  +                }
  +            );
  +        } else {
  +            return (new Enumerator(empty));
  +        }        
       }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to