tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kfuj...@apache.org
Subject svn commit: r1309736 - in /tomcat/tc7.0.x/trunk: java/org/apache/catalina/startup/UserConfig.java webapps/docs/changelog.xml webapps/docs/config/listeners.xml
Date Thu, 05 Apr 2012 10:18:57 GMT
Author: kfujino
Date: Thu Apr  5 10:18:56 2012
New Revision: 1309736

URL: http://svn.apache.org/viewvc?rev=1309736&view=rev
Log:
Add new attributes of enabled and disabled to UserConfig.

Modified:
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/UserConfig.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
    tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/UserConfig.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/UserConfig.java?rev=1309736&r1=1309735&r2=1309736&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/UserConfig.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/UserConfig.java Thu Apr  5 10:18:56
2012
@@ -25,6 +25,7 @@ import java.util.Enumeration;
 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 @@ public final class UserConfig
     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 final class UserConfig
 
     }
 
+    /**
+     * 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 @@ public final class UserConfig
         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 @@ public final class UserConfig
 
     }
 
+    /**
+     * 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;

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1309736&r1=1309735&r2=1309736&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Apr  5 10:18:56 2012
@@ -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>

Modified: tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml?rev=1309736&r1=1309735&r2=1309736&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml Thu Apr  5 10:18:56 2012
@@ -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">



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


Mime
View raw message