You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/02/28 11:25:46 UTC
[tomcat] branch 7.0.x updated: The '$' in the class name of
Digester$EnvironmentPropertySource...(#244)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push:
new 8900e3f The '$' in the class name of Digester$EnvironmentPropertySource...(#244)
8900e3f is described below
commit 8900e3f20ae231a0691ae73c26b0fb88693f5a0f
Author: Bernd Bohmann <bo...@apache.org>
AuthorDate: Fri Feb 28 12:09:04 2020 +0100
The '$' in the class name of Digester$EnvironmentPropertySource...(#244)
The '$' in the class name of Digester$EnvironmentPropertySource is not
really shell friendly for unix environments. The class should not a
inner class.
---
java/org/apache/tomcat/util/digester/Digester.java | 28 +++-----
.../util/digester/EnvironmentPropertySource.java | 78 ++++++++++++++++++++++
webapps/docs/changelog.xml | 7 ++
webapps/docs/config/systemprops.xml | 2 +-
4 files changed, 96 insertions(+), 19 deletions(-)
diff --git a/java/org/apache/tomcat/util/digester/Digester.java b/java/org/apache/tomcat/util/digester/Digester.java
index 1d65db7..dbbb4db 100644
--- a/java/org/apache/tomcat/util/digester/Digester.java
+++ b/java/org/apache/tomcat/util/digester/Digester.java
@@ -175,24 +175,16 @@ public class Digester extends DefaultHandler2 {
}
}
-
- public static class EnvironmentPropertySource implements IntrospectionUtils.SecurePropertySource {
-
- @Override
- public String getProperty(String key) {
- return null;
- }
-
- @Override
- public String getProperty(String key, ClassLoader classLoader) {
- if (classLoader instanceof PermissionCheck) {
- Permission p = new RuntimePermission("getenv." + key, null);
- if (!((PermissionCheck) classLoader).check(p)) {
- return null;
- }
- }
- return System.getenv(key);
- }
+ /**
+ * A {@link org.apache.tomcat.util.IntrospectionUtils.SecurePropertySource}
+ * that uses environment variables to resolve expressions. Still available
+ * for backwards compatibility.
+ *
+ * @deprecated Use {@link org.apache.tomcat.util.digester.EnvironmentPropertySource}
+ * This will be removed in Tomcat 10 onwards.
+ */
+ @Deprecated
+ public static class EnvironmentPropertySource extends org.apache.tomcat.util.digester.EnvironmentPropertySource {
}
diff --git a/java/org/apache/tomcat/util/digester/EnvironmentPropertySource.java b/java/org/apache/tomcat/util/digester/EnvironmentPropertySource.java
new file mode 100644
index 0000000..6b4138c
--- /dev/null
+++ b/java/org/apache/tomcat/util/digester/EnvironmentPropertySource.java
@@ -0,0 +1,78 @@
+/*
+ * 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.digester;
+
+import java.security.Permission;
+
+import org.apache.tomcat.util.IntrospectionUtils;
+import org.apache.tomcat.util.security.PermissionCheck;
+
+/**
+ * A {@link org.apache.tomcat.util.IntrospectionUtils.SecurePropertySource}
+ * that uses environment variables to resolve expressions.
+ *
+ * <p><strong>Usage example:</strong></p>
+ *
+ * Configure the certificate with environment variables.
+ *
+ * <pre>
+ * {@code
+ * <SSLHostConfig>
+ * <Certificate certificateKeyFile="${CERTIFICATE_KEY_FILE}"
+ * certificateFile="${CERTIFICATE_FILE}"
+ * certificateChainFile="${CERTIFICATE_CHAIN_FILE}"
+ * type="RSA" />
+ * </SSLHostConfig> }
+ * </pre>
+ *
+ * How to configure:
+ * <pre>
+ * {@code
+ * echo "org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource" >> conf/catalina.properties}
+ * </pre>
+ * or add this to {@code CATALINA_OPTS}
+ *
+ * <pre>
+ * {@code
+ * -Dorg.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource}
+ * </pre>
+ *
+ * <b>NOTE</b>: When configured the PropertySource for resolving expressions
+ * from system properties is still active.
+ *
+ * @see Digester
+ *
+ * @see <a href="https://tomcat.apache.org/tomcat-9.0-doc/config/systemprops.html#Property_replacements">Tomcat Configuration Reference System Properties</a>
+ */
+public class EnvironmentPropertySource implements IntrospectionUtils.SecurePropertySource {
+
+ @Override
+ public String getProperty(String key) {
+ return null;
+ }
+
+ @Override
+ public String getProperty(String key, ClassLoader classLoader) {
+ if (classLoader instanceof PermissionCheck) {
+ Permission p = new RuntimePermission("getenv." + key, null);
+ if (!((PermissionCheck) classLoader).check(p)) {
+ return null;
+ }
+ }
+ return System.getenv(key);
+ }
+}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 4f643b1..be66eac 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -84,6 +84,13 @@
Fix SCI support regression that was caused by a JAR path lookup error
in the classloader findResources. (remm)
</fix>
+ <scode>
+ Rename <code>org.apache.tomcat.util.digester.Digester$EnvironmentPropertySource</code>
+ to
+ <code>org.apache.tomcat.util.digester.EnvironmentPropertySource</code>.
+ The old class is still available but deprecated. Patch provided by Bernd
+ Bohmann. (markt)
+ </scode>
</changelog>
</subsection>
<subsection name="Coyote">
diff --git a/webapps/docs/config/systemprops.xml b/webapps/docs/config/systemprops.xml
index 049b22c..72a88eb 100644
--- a/webapps/docs/config/systemprops.xml
+++ b/webapps/docs/config/systemprops.xml
@@ -46,7 +46,7 @@
<p>Use this to add a property source, that will be invoked when
<code>${parameter}</code> denoted parameters are found in the XML files
that Tomcat parses.</p>
- <p><code>org.apache.tomcat.util.digester.Digester$EnvironmentPropertySource</code>
+ <p><code>org.apache.tomcat.util.digester.EnvironmentPropertySource</code>
can be used to replace parameters from the process' environment
variables, e.g. injected ConfigMaps or Secret objects in container
based systems like OpenShift or Kubernetes.</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org