tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r505593 - in /tomcat/tc6.0.x/trunk/java/org/apache: catalina/ catalina/connector/ catalina/core/ catalina/loader/ catalina/security/ catalina/session/ coyote/ coyote/http11/ jasper/ jasper/compiler/ jasper/runtime/ jasper/security/ naming/ ...
Date Sat, 10 Feb 2007 00:54:57 GMT
Author: remm
Date: Fri Feb  9 16:54:56 2007
New Revision: 505593

URL: http://svn.apache.org/viewvc?view=rev&rev=505593
Log:
- Set of minor optimizations.
- Unify usage of the security manager flag.
- Submitted by Arvind Srinivasan.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/Globals.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Constants.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/OutputBuffer.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Request.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/RequestFacade.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/ResponseFacade.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterChain.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ContainerBase.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardWrapper.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/security/SecurityUtil.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/ManagerBase.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/StandardSession.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/Constants.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/Constants.java
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspFactoryImpl.java
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/security/SecurityUtil.java
    tomcat/tc6.0.x/trunk/java/org/apache/naming/Constants.java
    tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/DirContextURLConnection.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/Globals.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/Globals.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/Globals.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/Globals.java Fri Feb  9 16:54:56 2007
@@ -330,4 +330,11 @@
         Boolean.valueOf(System.getProperty("org.apache.catalina.STRICT_SERVLET_COMPLIANCE",
"false")).booleanValue();
 
 
+    /**
+     * Has security been turned on?
+     */
+    public static final boolean IS_SECURITY_ENABLED =
+        (System.getSecurityManager() != null);
+
+
 }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Constants.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Constants.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Constants.java Fri Feb  9 16:54:56
2007
@@ -39,11 +39,5 @@
     public static final int PROCESSOR_IDLE = 0;
     public static final int PROCESSOR_ACTIVE = 1;
 
-    /**
-     * Security flag.
-     */
-    public static final boolean SECURITY = 
-        (System.getSecurityManager() != null);
-
 
 }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/OutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/OutputBuffer.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/OutputBuffer.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/OutputBuffer.java Fri Feb  9 16:54:56
2007
@@ -27,6 +27,7 @@
 
 import org.apache.coyote.ActionCode;
 import org.apache.coyote.Response;
+import org.apache.catalina.Globals;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.C2BConverter;
 
@@ -499,7 +500,7 @@
         conv = (C2BConverter) encoders.get(enc);
         if (conv == null) {
             
-            if (System.getSecurityManager() != null){
+            if (Globals.IS_SECURITY_ENABLED){
                 try{
                     conv = (C2BConverter)AccessController.doPrivileged(
                             new PrivilegedExceptionAction(){

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Request.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Request.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Request.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Request.java Fri Feb  9 16:54:56
2007
@@ -423,7 +423,7 @@
         requestedSessionId = null;
         requestedSessionURL = false;
 
-        if (Constants.SECURITY || Connector.RECYCLE_FACADES) {
+        if (Globals.IS_SECURITY_ENABLED || Connector.RECYCLE_FACADES) {
             parameterMap = new ParameterMap();
         } else {
             parameterMap.setLocked(false);
@@ -432,7 +432,7 @@
 
         mappingData.recycle();
 
-        if (Constants.SECURITY || Connector.RECYCLE_FACADES) {
+        if (Globals.IS_SECURITY_ENABLED || Connector.RECYCLE_FACADES) {
             if (facade != null) {
                 facade.clear();
                 facade = null;
@@ -1738,7 +1738,7 @@
      */
     public void setUserPrincipal(Principal principal) {
 
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             HttpSession session = getSession(false);
             if ( (subject != null) && 
                  (!subject.getPrincipals().contains(principal)) ){

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/RequestFacade.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/RequestFacade.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/RequestFacade.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/RequestFacade.java Fri Feb  9
16:54:56 2007
@@ -32,6 +32,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 
+import org.apache.catalina.Globals;
 import org.apache.catalina.util.StringManager;
 
 
@@ -270,7 +271,7 @@
                             sm.getString("requestFacade.nullRequest"));
         }
 
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             return (Enumeration)AccessController.doPrivileged(
                 new GetAttributePrivilegedAction());        
         } else {
@@ -286,7 +287,7 @@
                             sm.getString("requestFacade.nullRequest"));
         }
 
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             return (String)AccessController.doPrivileged(
                 new GetCharacterEncodingPrivilegedAction());
         } else {
@@ -347,7 +348,7 @@
                             sm.getString("requestFacade.nullRequest"));
         }
 
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             return (String)AccessController.doPrivileged(
                 new GetParameterPrivilegedAction(name));
         } else {
@@ -363,7 +364,7 @@
                             sm.getString("requestFacade.nullRequest"));
         }
 
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             return (Enumeration)AccessController.doPrivileged(
                 new GetParameterNamesPrivilegedAction());
         } else {
@@ -406,7 +407,7 @@
                             sm.getString("requestFacade.nullRequest"));
         }
 
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             return (Map)AccessController.doPrivileged(
                 new GetParameterMapPrivilegedAction());        
         } else {
@@ -521,7 +522,7 @@
                             sm.getString("requestFacade.nullRequest"));
         }
 
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             return (Locale)AccessController.doPrivileged(
                 new GetLocalePrivilegedAction());
         } else {
@@ -537,7 +538,7 @@
                             sm.getString("requestFacade.nullRequest"));
         }
 
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             return (Enumeration)AccessController.doPrivileged(
                 new GetLocalesPrivilegedAction());
         } else {
@@ -564,7 +565,7 @@
                             sm.getString("requestFacade.nullRequest"));
         }
 
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             return (RequestDispatcher)AccessController.doPrivileged(
                 new GetRequestDispatcherPrivilegedAction(path));
         } else {
@@ -650,7 +651,7 @@
                             sm.getString("requestFacade.nullRequest"));
         }
 
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             return (Enumeration)AccessController.doPrivileged(
                 new GetHeadersPrivilegedAction(name));
         } else {
@@ -666,7 +667,7 @@
                             sm.getString("requestFacade.nullRequest"));
         }
 
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             return (Enumeration)AccessController.doPrivileged(
                 new GetHeaderNamesPrivilegedAction());
         } else {

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/ResponseFacade.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/ResponseFacade.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/ResponseFacade.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/ResponseFacade.java Fri Feb  9
16:54:56 2007
@@ -30,6 +30,7 @@
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.catalina.Globals;
 import org.apache.catalina.util.StringManager;
 import org.apache.catalina.security.SecurityUtil;
 
@@ -446,7 +447,7 @@
         if (isCommitted())
             return;
 
-        if(System.getSecurityManager() != null) {
+        if(Globals.IS_SECURITY_ENABLED) {
             AccessController.doPrivileged(new DateHeaderPrivilegedAction
                                              (name, date, false));
         } else {
@@ -461,7 +462,7 @@
         if (isCommitted())
             return;
 
-        if(System.getSecurityManager() != null) {
+        if(Globals.IS_SECURITY_ENABLED) {
             AccessController.doPrivileged(new DateHeaderPrivilegedAction
                                              (name, date, true));
         } else {

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java Fri Feb
 9 16:54:56 2007
@@ -36,6 +36,7 @@
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 
+import org.apache.catalina.Globals;
 import org.apache.catalina.security.SecurityUtil;
 
 
@@ -161,7 +162,7 @@
 
     public URL getResource(String path)
         throws MalformedURLException {
-        if (System.getSecurityManager() != null) {
+        if (Globals.IS_SECURITY_ENABLED) {
             try {
                 return (URL) invokeMethod(context, "getResource", 
                                           new Object[]{path});

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java Fri Feb
 9 16:54:56 2007
@@ -287,7 +287,7 @@
     public void forward(ServletRequest request, ServletResponse response)
         throws ServletException, IOException
     {
-        if (System.getSecurityManager() != null) {
+        if (Globals.IS_SECURITY_ENABLED) {
             try {
                 PrivilegedForward dp = new PrivilegedForward(request,response);
                 AccessController.doPrivileged(dp);
@@ -490,7 +490,7 @@
     public void include(ServletRequest request, ServletResponse response)
         throws ServletException, IOException
     {
-        if (System.getSecurityManager() != null) {
+        if (Globals.IS_SECURITY_ENABLED) {
             try {
                 PrivilegedInclude dp = new PrivilegedInclude(request,response);
                 AccessController.doPrivileged(dp);

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterChain.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterChain.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterChain.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterChain.java Fri Feb
 9 16:54:56 2007
@@ -178,7 +178,7 @@
     public void doFilter(ServletRequest request, ServletResponse response)
         throws IOException, ServletException {
 
-        if( System.getSecurityManager() != null ) {
+        if( Globals.IS_SECURITY_ENABLED ) {
             final ServletRequest req = request;
             final ServletResponse res = response;
             try {
@@ -220,7 +220,7 @@
                 support.fireInstanceEvent(InstanceEvent.BEFORE_FILTER_EVENT,
                                           filter, request, response);
                 
-                if( System.getSecurityManager() != null ) {
+                if( Globals.IS_SECURITY_ENABLED ) {
                     final ServletRequest req = request;
                     final ServletResponse res = response;
                     Principal principal = 
@@ -274,7 +274,7 @@
             if ((request instanceof HttpServletRequest) &&
                 (response instanceof HttpServletResponse)) {
                     
-                if( System.getSecurityManager() != null ) {
+                if( Globals.IS_SECURITY_ENABLED ) {
                     final ServletRequest req = request;
                     final ServletResponse res = response;
                     Principal principal = 
@@ -336,7 +336,7 @@
     public void doFilterEvent(CometEvent event)
         throws IOException, ServletException {
 
-        if( System.getSecurityManager() != null ) {
+        if( Globals.IS_SECURITY_ENABLED ) {
             final CometEvent ev = event;
             try {
                 java.security.AccessController.doPrivileged(
@@ -402,7 +402,7 @@
                         filter, event);
                         */
 
-                if( System.getSecurityManager() != null ) {
+                if( Globals.IS_SECURITY_ENABLED ) {
                     final CometEvent ev = event;
                     Principal principal = 
                         ev.getHttpServletRequest().getUserPrincipal();
@@ -455,7 +455,7 @@
             support.fireInstanceEvent(InstanceEvent.BEFORE_SERVICE_EVENT,
                     servlet, request, response);
                     */
-            if( System.getSecurityManager() != null ) {
+            if( Globals.IS_SECURITY_ENABLED ) {
                 final CometEvent ev = event;
                 Principal principal = 
                     ev.getHttpServletRequest().getUserPrincipal();

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java Fri Feb
 9 16:54:56 2007
@@ -36,6 +36,7 @@
 
 import org.apache.AnnotationProcessor;
 import org.apache.catalina.Context;
+import org.apache.catalina.Globals;
 import org.apache.catalina.deploy.FilterDef;
 import org.apache.catalina.security.SecurityUtil;
 import org.apache.catalina.util.Enumerator;
@@ -320,7 +321,7 @@
 
         if (this.filter != null)
         {
-            if (System.getSecurityManager() != null) {
+            if (Globals.IS_SECURITY_ENABLED) {
                 try {
                     SecurityUtil.doAsPrivilege("destroy", filter); 
                 } catch(java.lang.Exception ex){                    
@@ -370,7 +371,7 @@
 
             // Release any previously allocated filter instance
             if (this.filter != null){
-                if( System.getSecurityManager() != null) {
+                if( Globals.IS_SECURITY_ENABLED) {
                     try{
                         SecurityUtil.doAsPrivilege("destroy", filter);  
                     } catch(java.lang.Exception ex){    

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java Fri Feb
 9 16:54:56 2007
@@ -58,9 +58,6 @@
     public static final String DISPATCHER_REQUEST_PATH_ATTR = 
         Globals.DISPATCHER_REQUEST_PATH_ATTR;
 
-    private static final SecurityManager securityManager = 
-        System.getSecurityManager();
-
     private static ApplicationFilterFactory factory = null;;
 
 
@@ -124,7 +121,7 @@
         
         // Create and initialize a filter chain object
         ApplicationFilterChain filterChain = null;
-        if ((securityManager == null) && (request instanceof Request)) {
+        if (!Globals.IS_SECURITY_ENABLED && (request instanceof Request)) {
             Request req = (Request) request;
             filterChain = (ApplicationFilterChain) req.getFilterChain();
             if (filterChain == null) {

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ContainerBase.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ContainerBase.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ContainerBase.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ContainerBase.java Fri Feb  9 16:54:56
2007
@@ -41,6 +41,7 @@
 import org.apache.catalina.Container;
 import org.apache.catalina.ContainerEvent;
 import org.apache.catalina.ContainerListener;
+import org.apache.catalina.Globals;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleListener;
@@ -732,7 +733,7 @@
      *  child Containers
      */
     public void addChild(Container child) {
-        if (System.getSecurityManager() != null) {
+        if (Globals.IS_SECURITY_ENABLED) {
             PrivilegedAction dp =
                 new PrivilegedAddChild(child);
             AccessController.doPrivileged(dp);

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardWrapper.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardWrapper.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardWrapper.java Fri Feb  9 16:54:56
2007
@@ -52,6 +52,7 @@
 import org.apache.catalina.Container;
 import org.apache.catalina.ContainerServlet;
 import org.apache.catalina.Context;
+import org.apache.catalina.Globals;
 import org.apache.catalina.InstanceEvent;
 import org.apache.catalina.InstanceListener;
 import org.apache.catalina.LifecycleException;
@@ -1148,7 +1149,7 @@
                 instanceSupport.fireInstanceEvent(InstanceEvent.BEFORE_INIT_EVENT,
                                                   servlet);
 
-                if( System.getSecurityManager() != null) {
+                if( Globals.IS_SECURITY_ENABLED) {
 
                     Object[] args = new Object[]{((ServletConfig)facade)};
                     SecurityUtil.doAsPrivilege("init",
@@ -1168,7 +1169,7 @@
                     req.setQueryString("jsp_precompile=true");
                     DummyResponse res = new DummyResponse();
 
-                    if( System.getSecurityManager() != null) {
+                    if( Globals.IS_SECURITY_ENABLED) {
                         Object[] args = new Object[]{req, res};
                         SecurityUtil.doAsPrivilege("service",
                                                    servlet,
@@ -1373,7 +1374,7 @@
             instanceSupport.fireInstanceEvent
               (InstanceEvent.BEFORE_DESTROY_EVENT, instance);
 
-            if( System.getSecurityManager() != null) {
+            if( Globals.IS_SECURITY_ENABLED) {
                 SecurityUtil.doAsPrivilege("destroy",
                                            instance);
                 SecurityUtil.remove(instance);                           
@@ -1421,7 +1422,7 @@
             try {
                 while (!instancePool.isEmpty()) {
                     Servlet s = (Servlet) instancePool.pop();
-                    if (System.getSecurityManager() != null) {
+                    if (Globals.IS_SECURITY_ENABLED) {
                         SecurityUtil.doAsPrivilege("destroy", s);
                         SecurityUtil.remove(instance);                           
                     } else {

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java Fri Feb  9 16:54:56
2007
@@ -788,7 +788,7 @@
      */
     private void setPermissions() {
 
-        if (System.getSecurityManager() == null)
+        if (!Globals.IS_SECURITY_ENABLED)
             return;
         if (!(container instanceof Context))
             return;

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/security/SecurityUtil.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/security/SecurityUtil.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/security/SecurityUtil.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/security/SecurityUtil.java Fri Feb  9 16:54:56
2007
@@ -375,7 +375,7 @@
      * package protection mechanism is enabled.
      */
     public static boolean isPackageProtectionEnabled(){
-        if (packageDefinitionEnabled && System.getSecurityManager() !=  null){
+        if (packageDefinitionEnabled && Globals.IS_SECURITY_ENABLED){
             return true;
         }
         return false;

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/ManagerBase.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/ManagerBase.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/ManagerBase.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/ManagerBase.java Fri Feb  9 16:54:56
2007
@@ -44,6 +44,7 @@
 
 import org.apache.catalina.Container;
 import org.apache.catalina.Engine;
+import org.apache.catalina.Globals;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Session;
 import org.apache.catalina.core.StandardContext;
@@ -506,7 +507,7 @@
     public void setRandomFile( String s ) {
         // as a hack, you can use a static file - and genarate the same
         // session ids ( good for strange debugging )
-        if (System.getSecurityManager() != null){
+        if (Globals.IS_SECURITY_ENABLED){
             randomIS = (DataInputStream)AccessController.doPrivileged(new PrivilegedSetRandomFile());
         
         } else {
             try{

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/StandardSession.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/StandardSession.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/StandardSession.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/StandardSession.java Fri Feb  9
16:54:56 2007
@@ -863,7 +863,6 @@
         id = null;
         lastAccessedTime = 0L;
         maxInactiveInterval = -1;
-        accessCount = null;
         notes.clear();
         setPrincipal(null);
         isNew = false;

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/Constants.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/Constants.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/Constants.java Fri Feb  9 16:54:56 2007
@@ -53,4 +53,12 @@
     public static final int STAGE_ENDED = 7;
 
 
+    /**
+     * Has security been turned on?
+     */
+    public static final boolean IS_SECURITY_ENABLED =
+        (System.getSecurityManager() != null);
+
+
+
 }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/Http11Processor.java Fri Feb  9 16:54:56
2007
@@ -1542,7 +1542,7 @@
 
         // Add date header
         String date = null;
-        if (System.getSecurityManager() != null){
+        if (org.apache.coyote.Constants.IS_SECURITY_ENABLED){
             date = (String)AccessController.doPrivileged(
                     new PrivilegedAction() {
                         public Object run(){

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java Fri Feb 
9 16:54:56 2007
@@ -446,7 +446,7 @@
         }
 
         // End the response status line
-        if (System.getSecurityManager() != null){
+        if (org.apache.coyote.Constants.IS_SECURITY_ENABLED){
            AccessController.doPrivileged(
                 new PrivilegedAction(){
                     public Object run(){
@@ -464,7 +464,7 @@
     }
 
     private String getMessage(final int message){
-        if (System.getSecurityManager() != null){
+        if (org.apache.coyote.Constants.IS_SECURITY_ENABLED){
            return (String)AccessController.doPrivileged(
                 new PrivilegedAction(){
                     public Object run(){

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/Constants.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/Constants.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/Constants.java Fri Feb  9 16:54:56 2007
@@ -187,4 +187,10 @@
     public static final char ESC = '\u001b';
     public static final String ESCStr = "'\\u001b'";
 
+    /**
+     * Has security been turned on?
+     */
+    public static final boolean IS_SECURITY_ENABLED = 
+        (System.getSecurityManager() != null);
+
 }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java Fri Feb  9
16:54:56 2007
@@ -133,7 +133,7 @@
 	    return;
 	}
 
-        if (System.getSecurityManager() != null) {
+        if (Constants.IS_SECURITY_ENABLED) {
             initSecurity();
         }
 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspFactoryImpl.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspFactoryImpl.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspFactoryImpl.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspFactoryImpl.java Fri Feb  9 16:54:56
2007
@@ -28,6 +28,7 @@
 import javax.servlet.jsp.JspEngineInfo;
 import javax.servlet.jsp.PageContext;
 
+import org.apache.jasper.Constants;
 import org.apache.jasper.util.SimplePool;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -56,7 +57,7 @@
 				      int bufferSize,
                                       boolean autoflush) {
 
-	if( System.getSecurityManager() != null ) {
+	if( Constants.IS_SECURITY_ENABLED ) {
 	    PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
 		(JspFactoryImpl)this, servlet, request, response, errorPageURL,
                 needsSession, bufferSize, autoflush);
@@ -71,7 +72,7 @@
     public void releasePageContext(PageContext pc) {
 	if( pc == null )
 	    return;
-        if( System.getSecurityManager() != null ) {
+        if( Constants.IS_SECURITY_ENABLED ) {
             PrivilegedReleasePageContext dp = new PrivilegedReleasePageContext(
                 (JspFactoryImpl)this,pc);
             AccessController.doPrivileged(dp);

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java Fri Feb  9
16:54:56 2007
@@ -37,6 +37,7 @@
 import javax.servlet.jsp.PageContext;
 import javax.servlet.jsp.tagext.BodyContent;
 
+import org.apache.jasper.Constants;
 import org.apache.jasper.JasperException;
 import org.apache.jasper.compiler.Localizer;
 
@@ -293,7 +294,7 @@
                                         String param, boolean ignoreMethodNF)
                                         throws JasperException
     {
-        if( System.getSecurityManager() != null ) {
+        if( Constants.IS_SECURITY_ENABLED ) {
             try {
                 PrivilegedIntrospectHelper dp =
 		    new PrivilegedIntrospectHelper(

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/security/SecurityUtil.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/security/SecurityUtil.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/security/SecurityUtil.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/security/SecurityUtil.java Fri Feb  9 16:54:56
2007
@@ -16,6 +16,8 @@
  */
 package org.apache.jasper.security;
 
+import org.apache.jasper.Constants;
+
 /**
  * Util class for Security related operations.
  *
@@ -32,7 +34,7 @@
      * package protection mechanism is enabled.
      */
     public static boolean isPackageProtectionEnabled(){
-        if (packageDefinitionEnabled && System.getSecurityManager() !=  null){
+        if (packageDefinitionEnabled && Constants.IS_SECURITY_ENABLED){
             return true;
         }
         return false;

Modified: tomcat/tc6.0.x/trunk/java/org/apache/naming/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/naming/Constants.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/naming/Constants.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/naming/Constants.java Fri Feb  9 16:54:56 2007
@@ -27,4 +27,9 @@
 
     public static final String Package = "org.apache.naming";
 
+    /**
+     * Has security been turned on?
+     */
+    public static final boolean IS_SECURITY_ENABLED =
+        (System.getSecurityManager() != null);
 }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/DirContextURLConnection.java?view=diff&rev=505593&r1=505592&r2=505593
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/DirContextURLConnection.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/naming/resources/DirContextURLConnection.java Fri
Feb  9 16:54:56 2007
@@ -59,7 +59,7 @@
         if (context == null)
             throw new IllegalArgumentException
                 ("Directory context can't be null");
-        if (System.getSecurityManager() != null) {
+        if (org.apache.naming.Constants.IS_SECURITY_ENABLED) {
             this.permission = new JndiPermission(url.toString());
 	}
         this.context = context;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message