You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kf...@apache.org on 2012/04/05 12:08:38 UTC

svn commit: r1309734 - in /tomcat/trunk: java/org/apache/catalina/startup/UserConfig.java webapps/docs/config/listeners.xml

Author: kfujino
Date: Thu Apr  5 10:08:38 2012
New Revision: 1309734

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

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

Modified: tomcat/trunk/java/org/apache/catalina/startup/UserConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/UserConfig.java?rev=1309734&r1=1309733&r2=1309734&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/UserConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/UserConfig.java Thu Apr  5 10:08:38 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/trunk/webapps/docs/config/listeners.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/listeners.xml?rev=1309734&r1=1309733&r2=1309734&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/listeners.xml (original)
+++ tomcat/trunk/webapps/docs/config/listeners.xml Thu Apr  5 10:08:38 2012
@@ -341,6 +341,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


Re: svn commit: r1309734 - in /tomcat/trunk: java/org/apache/catalina/startup/UserConfig.java webapps/docs/config/listeners.xml

Posted by Keiichi Fujino <kf...@apache.org>.
Thanks comments.
fixed in r1310163.

2012/4/5 Mark Thomas <ma...@apache.org>:
> On 05/04/2012 11:46, Konstantin Kolinko wrote:
>> 2012/4/5  <kf...@apache.org>:
>>> Author: kfujino
>>> Date: Thu Apr  5 10:08:38 2012
>>> New Revision: 1309734
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1309734&view=rev
>>> Log:
>>> Add new attributes of enabled and disabled to UserConfig.
>>
>> The name "enabled" is usually used for a boolean attribute that
>> disables a feature as a whole.
>>
>> Maybe name the new attributes as  "enabledUser" and "disabledUser" ?
>
> allow and deny would be consistent with other valves.
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>



-- 
Keiichi.Fujino

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


Re: svn commit: r1309734 - in /tomcat/trunk: java/org/apache/catalina/startup/UserConfig.java webapps/docs/config/listeners.xml

Posted by Mark Thomas <ma...@apache.org>.
On 05/04/2012 11:46, Konstantin Kolinko wrote:
> 2012/4/5  <kf...@apache.org>:
>> Author: kfujino
>> Date: Thu Apr  5 10:08:38 2012
>> New Revision: 1309734
>>
>> URL: http://svn.apache.org/viewvc?rev=1309734&view=rev
>> Log:
>> Add new attributes of enabled and disabled to UserConfig.
> 
> The name "enabled" is usually used for a boolean attribute that
> disables a feature as a whole.
> 
> Maybe name the new attributes as  "enabledUser" and "disabledUser" ?

allow and deny would be consistent with other valves.

Mark

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


Re: svn commit: r1309734 - in /tomcat/trunk: java/org/apache/catalina/startup/UserConfig.java webapps/docs/config/listeners.xml

Posted by Konstantin Kolinko <kn...@gmail.com>.
2012/4/5  <kf...@apache.org>:
> Author: kfujino
> Date: Thu Apr  5 10:08:38 2012
> New Revision: 1309734
>
> URL: http://svn.apache.org/viewvc?rev=1309734&view=rev
> Log:
> Add new attributes of enabled and disabled to UserConfig.

The name "enabled" is usually used for a boolean attribute that
disables a feature as a whole.

Maybe name the new attributes as  "enabledUser" and "disabledUser" ?


>
> Modified:
>    tomcat/trunk/java/org/apache/catalina/startup/UserConfig.java
>    tomcat/trunk/webapps/docs/config/listeners.xml
>
> Modified: tomcat/trunk/java/org/apache/catalina/startup/UserConfig.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/UserConfig.java?rev=1309734&r1=1309733&r2=1309734&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/catalina/startup/UserConfig.java (original)
> +++ tomcat/trunk/java/org/apache/catalina/startup/UserConfig.java Thu Apr  5 10:08:38 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;

It can be moved up by one line.
The "home" value is not needed to call isDeployEnabled().

>             results.add(executor.submit(new DeployUserDirectory(this, user, home)));
>         }
>
> @@ -348,6 +403,26 @@ public final class UserConfig
>
>     }
>

Best regards,
Konstantin Kolinko

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