Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add new attributes of enabled and disabled to UserConfig.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk@1309736 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit f55fe59416a7f97012dce8bab29c0a62bf34aa4a 1 parent 5605951
Keiichi Fujino authored
View
75 java/org/apache/catalina/startup/UserConfig.java
@@ -25,6 +25,7 @@
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
+import java.util.regex.Pattern;
import org.apache.catalina.Context;
import org.apache.catalina.Host;
@@ -99,6 +100,15 @@
private String userClass =
"org.apache.catalina.startup.PasswdUserDatabase";
+ /**
+ * A regular expression defining user who deployment is allowed.
+ */
+ protected Pattern enabled = null;
+
+ /**
+ * A regular expression defining user who deployment is denied.
+ */
+ protected Pattern disabled = null;
// ------------------------------------------------------------- Properties
@@ -210,6 +220,50 @@ public void setUserClass(String userClass) {
}
+ /**
+ * Return the regular expression used to test for user who deployment is allowed.
+ */
+ public String getEnabled() {
+ if (enabled == null) return null;
+ return enabled.toString();
+ }
+
+
+ /**
+ * Set the regular expression used to test for user who deployment is allowed.
+ *
+ * @param enabled The new enabled expression
+ */
+ public void setEnabled(String enabled) {
+ if (enabled == null || enabled.length() == 0) {
+ this.enabled = null;
+ } else {
+ this.enabled = Pattern.compile(enabled);
+ }
+ }
+
+
+ /**
+ * Return the regular expression used to test for user who deployment is denied.
+ */
+ public String getDisabled() {
+ if (disabled == null) return null;
+ return disabled.toString();
+ }
+
+
+ /**
+ * Set the regular expression used to test for user who deployment is denied.
+ *
+ * @param disabled The new disabled expression
+ */
+ public void setDisabled(String disabled) {
+ if (disabled == null || disabled.length() == 0) {
+ this.disabled = null;
+ } else {
+ this.disabled = Pattern.compile(disabled);
+ }
+ }
// --------------------------------------------------------- Public Methods
@@ -270,6 +324,7 @@ private void deploy() {
while (users.hasMoreElements()) {
String user = users.nextElement();
String home = database.getHome(user);
+ if (!isDeployEnabled(user)) continue;
results.add(executor.submit(new DeployUserDirectory(this, user, home)));
}
@@ -348,6 +403,26 @@ private void stop() {
}
+ /**
+ * Test enabled and disabled rules for the provided user.
+ *
+ * @return <code>true</code> if this user is allowed to deploy,
+ * <code>false</code> otherwise
+ */
+ private boolean isDeployEnabled(String user) {
+ if (disabled != null && disabled.matcher(user).matches()) {
+ return false;
+ }
+ if (enabled != null) {
+ if (enabled.matcher(user).matches()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
private static class DeployUserDirectory implements Runnable {
private UserConfig config;
View
9 webapps/docs/changelog.xml
@@ -53,6 +53,15 @@
They eventually become mixed with the numbered issues. (I.e., numbered
issues to not "pop up" wrt. others).
-->
+<section name="Tomcat 7.0.28 (markt)">
+ <subsection name="Catalina">
+ <changelog>
+ <add>
+ Add new attributes of enabled and disabled to UserConfig. (kfujino)
+ </add>
+ </changelog>
+ </subsection>
+</section>
<section name="Tomcat 7.0.27 (markt)">
<subsection name="Catalina">
<changelog>
View
54 webapps/docs/config/listeners.xml
@@ -340,6 +340,60 @@
</subsection>
+ <subsection name="UserConfig - org.apache.catalina.startup.UserConfig">
+
+ <p>The <strong>UserConfig</strong> provides feature of User Web Applications.
+ User Web Applications map a request URI starting with a tilde character ("~")
+ and a username to a directory (commonly named public_html) in that user's
+ home directory on the server.</p>
+
+ <p>See the <a href="host.html#User Web Applications">User Web Applications</a>
+ special feature on the <strong>Host</strong> element for more information.</p>
+
+ <p>The following additional attributes are supported by the
+ <strong>UserConfig</strong>:</p>
+
+ <attributes>
+
+ <attribute name="directoryName" required="false">
+ <p>The directory name to be searched for within each user home directory.
+ The default is <code>public_html</code>.</p>
+ </attribute>
+
+ <attribute name="userClass" required="false">
+ <p>The class name of the user database class.
+ There are currently two user database, the
+ <code>org.apache.catalina.startup.PasswdUserDatabase</code> is used on a
+ Unix system that uses the /etc/passwd file to identify valid users.
+ The <code>org.apache.catalina.startup.HomesUserDatabase</code> is used on
+ a server where /etc/passwd is not in use. HomesUserDatabase deploy all
+ directories found in a specified base directory.</p>
+ </attribute>
+
+ <attribute name="homeBase" required="false">
+ <p>The base directory containing user home directories.This is effective
+ only when <code>org.apache.catalina.startup.HomesUserDatabase</code> is
+ used.</p>
+ </attribute>
+
+ <attribute name="enabled" required="false">
+ <p>A regular expression defining user who deployment is allowed. If this
+ attribute is specified, the user to deploy must match for this pattern.
+ If this attribute is not specified, all users will be deployed unless the
+ user matches a disabled pattern.</p>
+ </attribute>
+
+ <attribute name="disabled" required="false">
+ <p>A regular expression defining user who deployment is denied. If this
+ attribute is specified, the user to deploy must not match for this
+ pattern. If this attribute is not specified, deployment of user will be
+ governed by a enabled attribute.</p>
+ </attribute>
+
+ </attributes>
+
+ </subsection>
+
</section>
<section name="Additional Implementations">
Please sign in to comment.
Something went wrong with that request. Please try again.