From 283fad393c4ae2a01f1607ec58d381dfcd6231ce Mon Sep 17 00:00:00 2001 From: markt Date: Sat, 11 Dec 2010 21:14:45 +0000 Subject: [PATCH] o.a.tomcat.util.net should not depend on o.a.catalina git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1044723 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tomcat/util/net/AbstractEndpoint.java | 7 +++-- java/org/apache/tomcat/util/net/Constants.java | 33 ++++++++++++++++++++++ java/org/apache/tomcat/util/net/JIoEndpoint.java | 5 ++-- .../tomcat/util/net/jsse/JSSESocketFactory.java | 9 +++--- res/checkstyle/org-import-control.xml | 1 - 5 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 java/org/apache/tomcat/util/net/Constants.java diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java b/java/org/apache/tomcat/util/net/AbstractEndpoint.java index ada095122..ff77f30d0 100644 --- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java +++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java @@ -28,7 +28,6 @@ import java.util.concurrent.TimeUnit; import javax.net.ssl.KeyManagerFactory; -import org.apache.catalina.Globals; import org.apache.coyote.RequestGroupInfo; import org.apache.juli.logging.Log; import org.apache.tomcat.util.IntrospectionUtils; @@ -586,7 +585,8 @@ public abstract class AbstractEndpoint { private String keystoreFile = System.getProperty("user.home")+"/.keystore"; public String getKeystoreFile() { return keystoreFile;} public void setKeystoreFile(String s ) { - String file = adjustRelativePath(s, System.getProperty(Globals.CATALINA_BASE_PROP)); + String file = adjustRelativePath(s, + System.getProperty(Constants.CATALINA_BASE_PROP)); this.keystoreFile = file; } @@ -633,7 +633,8 @@ public abstract class AbstractEndpoint { private String truststoreFile = System.getProperty("javax.net.ssl.trustStore"); public String getTruststoreFile() {return truststoreFile;} public void setTruststoreFile(String s) { - String file = adjustRelativePath(s, System.getProperty(Globals.CATALINA_BASE_PROP)); + String file = adjustRelativePath(s, + System.getProperty(Constants.CATALINA_BASE_PROP)); this.truststoreFile = file; } diff --git a/java/org/apache/tomcat/util/net/Constants.java b/java/org/apache/tomcat/util/net/Constants.java new file mode 100644 index 000000000..67ed4935a --- /dev/null +++ b/java/org/apache/tomcat/util/net/Constants.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tomcat.util.net; + +public class Constants { + + /** + * Name of the system property containing + * the tomcat instance installation path + */ + public static final String CATALINA_BASE_PROP = "catalina.base"; + + + /** + * Has security been turned on? + */ + public static final boolean IS_SECURITY_ENABLED = + (System.getSecurityManager() != null); +} diff --git a/java/org/apache/tomcat/util/net/JIoEndpoint.java b/java/org/apache/tomcat/util/net/JIoEndpoint.java index 38893e613..23fa87c10 100644 --- a/java/org/apache/tomcat/util/net/JIoEndpoint.java +++ b/java/org/apache/tomcat/util/net/JIoEndpoint.java @@ -28,7 +28,6 @@ import java.util.Iterator; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.RejectedExecutionException; -import org.apache.catalina.Globals; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.ExceptionUtils; @@ -508,7 +507,7 @@ public class JIoEndpoint extends AbstractEndpoint { ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { //threads should not be created by the webapp classloader - if (Globals.IS_SECURITY_ENABLED) { + if (Constants.IS_SECURITY_ENABLED) { PrivilegedAction pa = new PrivilegedSetTccl( getClass().getClassLoader()); AccessController.doPrivileged(pa); @@ -522,7 +521,7 @@ public class JIoEndpoint extends AbstractEndpoint { } getExecutor().execute(proc); }finally { - if (Globals.IS_SECURITY_ENABLED) { + if (Constants.IS_SECURITY_ENABLED) { PrivilegedAction pa = new PrivilegedSetTccl(loader); AccessController.doPrivileged(pa); } else { diff --git a/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java b/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java index 7e8ca6fe2..7a6a60880 100644 --- a/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java +++ b/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java @@ -58,8 +58,8 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509KeyManager; -import org.apache.catalina.Globals; import org.apache.tomcat.util.net.AbstractEndpoint; +import org.apache.tomcat.util.net.Constants; import org.apache.tomcat.util.net.ServerSocketFactory; import org.apache.tomcat.util.res.StringManager; @@ -370,8 +370,8 @@ public class JSSESocketFactory implements ServerSocketFactory { "".equalsIgnoreCase(path))) { File keyStoreFile = new File(path); if (!keyStoreFile.isAbsolute()) { - keyStoreFile = new File(System.getProperty(Globals.CATALINA_BASE_PROP), - path); + keyStoreFile = new File(System.getProperty( + Constants.CATALINA_BASE_PROP), path); } istream = new FileInputStream(keyStoreFile); } @@ -612,7 +612,8 @@ public class JSSESocketFactory implements ServerSocketFactory { File crlFile = new File(crlf); if( !crlFile.isAbsolute() ) { - crlFile = new File(System.getProperty(Globals.CATALINA_BASE_PROP), crlf); + crlFile = new File( + System.getProperty(Constants.CATALINA_BASE_PROP), crlf); } Collection crls = null; InputStream is = null; diff --git a/res/checkstyle/org-import-control.xml b/res/checkstyle/org-import-control.xml index ea23ff999..e5f488f44 100644 --- a/res/checkstyle/org-import-control.xml +++ b/res/checkstyle/org-import-control.xml @@ -91,7 +91,6 @@ - -- 2.11.0