incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r491943 - in /incubator/ftpserver/trunk: admin-gui/src/java/org/apache/ftpserver/gui/ core/src/java/org/apache/ftpserver/command/ core/src/java/org/apache/ftpserver/filesystem/ core/src/java/org/apache/ftpserver/usermanager/ core/src/test/o...
Date Tue, 02 Jan 2007 21:57:18 GMT
Author: ngn
Date: Tue Jan  2 13:57:16 2007
New Revision: 491943

URL: http://svn.apache.org/viewvc?view=rev&rev=491943
Log:
Further improvments of the authorization model. Authorizations that return a non-boolean result can now be supported in a more natural way, instead of having to retrive the permission objects.

Added:
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/TransferRateRequest.java   (with props)
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/BaseUserTest.java   (with props)
Modified:
    incubator/ftpserver/trunk/admin-gui/src/java/org/apache/ftpserver/gui/UserManagerPanel.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/APPE.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RETR.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SITE_DESCUSER.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOR.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOU.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/USER.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/filesystem/NativeFileObject.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/BaseUser.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/ConcurrentLoginPermission.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/ConcurrentLoginRequest.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/DbUserManager.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/PropertiesUserManager.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/TransferRatePermission.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/WritePermission.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/filesystem/NativeFileObjectTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/ConcurrentLoginPermissionTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/UserManagerTestTemplate.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/WritePermissionTest.java
    incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/Authority.java
    incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/User.java

Modified: incubator/ftpserver/trunk/admin-gui/src/java/org/apache/ftpserver/gui/UserManagerPanel.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/admin-gui/src/java/org/apache/ftpserver/gui/UserManagerPanel.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/admin-gui/src/java/org/apache/ftpserver/gui/UserManagerPanel.java (original)
+++ incubator/ftpserver/trunk/admin-gui/src/java/org/apache/ftpserver/gui/UserManagerPanel.java Tue Jan  2 13:57:16 2007
@@ -50,7 +50,9 @@
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.usermanager.BaseUser;
 import org.apache.ftpserver.usermanager.ConcurrentLoginPermission;
+import org.apache.ftpserver.usermanager.ConcurrentLoginRequest;
 import org.apache.ftpserver.usermanager.TransferRatePermission;
+import org.apache.ftpserver.usermanager.TransferRateRequest;
 import org.apache.ftpserver.usermanager.WritePermission;
 import org.apache.ftpserver.usermanager.WriteRequest;
 
@@ -537,31 +539,30 @@
                     passwordChkBox.setSelected(false);
                     directoryTxt.setText(user.getHomeDirectory());
                     enabledChkBox.setSelected(user.getEnabled());
-                    writeChkBox.setSelected(user.authorize(new WriteRequest()));
+                    writeChkBox.setSelected(user.authorize(new WriteRequest()) != null);
                     
                     
+                    TransferRateRequest transferRateRequest = new TransferRateRequest();
+                    transferRateRequest = (TransferRateRequest) user.authorize(transferRateRequest);
                     
-                    Authority[] maxTransferRates = user.getAuthorities(TransferRatePermission.class);
-                    
-                    if(maxTransferRates.length > 0) {
-                        setByteRateCombo(uploadLst, ((TransferRatePermission)maxTransferRates[0]).getMaxUploadRate());
-                        setByteRateCombo(downloadLst, ((TransferRatePermission)maxTransferRates[0]).getMaxDownloadRate());
+                    if(transferRateRequest != null) {
+                        setByteRateCombo(uploadLst, transferRateRequest.getMaxUploadRate());
+                        setByteRateCombo(downloadLst, transferRateRequest.getMaxDownloadRate());
                     } else {
                         setByteRateCombo(uploadLst, 0);
                         setByteRateCombo(downloadLst, 0);
                     }
                     
-                    Authority[] concurrentLoginPermissions = user.getAuthorities(ConcurrentLoginPermission.class);
+                    ConcurrentLoginRequest concurrentLoginRequest = new ConcurrentLoginRequest(0, 0);
+                    concurrentLoginRequest = (ConcurrentLoginRequest) user.authorize(concurrentLoginRequest);
                     
-                    if(concurrentLoginPermissions.length > 0) {
-                        setLoginNumberCombo(loginNumberLst, ((ConcurrentLoginPermission)concurrentLoginPermissions[0]).getMaxConcurrentLogins());
-                        setLoginPerIPCombo(loginPerIPLst, ((ConcurrentLoginPermission)concurrentLoginPermissions[0]).getMaxConcurrentLoginsPerIP());
+                    if(concurrentLoginRequest != null) {
+                        setLoginNumberCombo(loginNumberLst, concurrentLoginRequest.getMaxConcurrentLogins());
+                        setLoginPerIPCombo(loginPerIPLst, concurrentLoginRequest.getMaxConcurrentLoginsPerIP());
                     } else {
                         setLoginNumberCombo(loginNumberLst, 0);
                         setLoginPerIPCombo(loginPerIPLst, 0);
                     }
-                    
-                    
 
                     setIdleTimeCombo(idleLst, user.getMaxIdleTime());
                 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/APPE.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/APPE.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/APPE.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/APPE.java Tue Jan  2 13:57:16 2007
@@ -38,6 +38,7 @@
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.interfaces.ServerFtpStatistics;
 import org.apache.ftpserver.usermanager.TransferRatePermission;
+import org.apache.ftpserver.usermanager.TransferRateRequest;
 import org.apache.ftpserver.util.IoUtils;
 
 /**
@@ -148,11 +149,13 @@
                 bos = IoUtils.getBufferedOutputStream( file.createOutputStream(offset) );
                     
                 // transfer data
-                Authority[] maxUploadRates = session.getUser().getAuthorities(TransferRatePermission.class);
+                
+                TransferRateRequest transferRateRequest = new TransferRateRequest();
+                transferRateRequest = (TransferRateRequest) session.getUser().authorize(transferRateRequest);
                 
                 int maxRate = 0;
-                if(maxUploadRates.length > 0) {
-                    maxRate = ((TransferRatePermission)maxUploadRates[0]).getMaxUploadRate();
+                if(transferRateRequest != null) {
+                    maxRate = transferRateRequest.getMaxUploadRate();
                 }
                 
                 long transSz = handler.transfer(bis, bos, maxRate);

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RETR.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RETR.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RETR.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RETR.java Tue Jan  2 13:57:16 2007
@@ -40,6 +40,7 @@
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.interfaces.ServerFtpStatistics;
 import org.apache.ftpserver.usermanager.TransferRatePermission;
+import org.apache.ftpserver.usermanager.TransferRateRequest;
 import org.apache.ftpserver.util.IoUtils;
 
 /**
@@ -149,11 +150,12 @@
                 bos = IoUtils.getBufferedOutputStream(os);
                 
                 // transfer data
-                Authority[] maxDownloadRates = session.getUser().getAuthorities(TransferRatePermission.class);
+                TransferRateRequest transferRateRequest = new TransferRateRequest();
+                transferRateRequest = (TransferRateRequest) session.getUser().authorize(transferRateRequest);
             
                 int maxRate = 0;
-                if(maxDownloadRates.length > 0) {
-                    maxRate = ((TransferRatePermission)maxDownloadRates[0]).getMaxDownloadRate();
+                if(transferRateRequest != null) {
+                    maxRate = transferRateRequest.getMaxDownloadRate();
                 }
                 
                 long transSz = handler.transfer(bis, bos, maxRate);

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SITE_DESCUSER.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SITE_DESCUSER.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SITE_DESCUSER.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/SITE_DESCUSER.java Tue Jan  2 13:57:16 2007
@@ -30,6 +30,7 @@
 import org.apache.ftpserver.ftplet.UserManager;
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.usermanager.TransferRatePermission;
+import org.apache.ftpserver.usermanager.TransferRateRequest;
 import org.apache.ftpserver.usermanager.WriteRequest;
 
 /**
@@ -96,12 +97,12 @@
         sb.append("enableflag      : ").append(user.getEnabled()).append("\n");
         sb.append("idletime        : ").append(user.getMaxIdleTime()).append("\n");
         
-        TransferRatePermission[] maxTransferRates = (TransferRatePermission[]) 
-            user.getAuthorities(TransferRatePermission.class);
+        TransferRateRequest transferRateRequest = new TransferRateRequest();
+        transferRateRequest = (TransferRateRequest) session.getUser().authorize(transferRateRequest);
         
-        if(maxTransferRates.length > 0) {
-            sb.append("uploadrate      : ").append(maxTransferRates[0].getMaxUploadRate()).append("\n");
-            sb.append("downloadrate    : ").append(maxTransferRates[0].getMaxDownloadRate()).append("\n");
+        if(transferRateRequest != null) {
+            sb.append("uploadrate      : ").append(transferRateRequest.getMaxUploadRate()).append("\n");
+            sb.append("downloadrate    : ").append(transferRateRequest.getMaxDownloadRate()).append("\n");
         } else {
             sb.append("uploadrate      : 0\n");
             sb.append("downloadrate    : 0\n");

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOR.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOR.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOR.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOR.java Tue Jan  2 13:57:16 2007
@@ -38,6 +38,7 @@
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.interfaces.ServerFtpStatistics;
 import org.apache.ftpserver.usermanager.TransferRatePermission;
+import org.apache.ftpserver.usermanager.TransferRateRequest;
 import org.apache.ftpserver.util.IoUtils;
 
 /**
@@ -138,11 +139,12 @@
                 bos = IoUtils.getBufferedOutputStream( file.createOutputStream(skipLen) );
                 
                 // transfer data
-                Authority[] maxUploadRates = session.getUser().getAuthorities(TransferRatePermission.class);
-            
+                TransferRateRequest transferRateRequest = new TransferRateRequest();
+                transferRateRequest = (TransferRateRequest) session.getUser().authorize(transferRateRequest);
+                
                 int maxRate = 0;
-                if(maxUploadRates.length > 0) {
-                    maxRate = ((TransferRatePermission)maxUploadRates[0]).getMaxUploadRate();
+                if(transferRateRequest != null) {
+                    maxRate = transferRateRequest.getMaxUploadRate();
                 }
                 long transSz = handler.transfer(bis, bos, maxRate);
                 

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOU.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOU.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOU.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOU.java Tue Jan  2 13:57:16 2007
@@ -40,6 +40,7 @@
 import org.apache.ftpserver.interfaces.FtpServerContext;
 import org.apache.ftpserver.interfaces.ServerFtpStatistics;
 import org.apache.ftpserver.usermanager.TransferRatePermission;
+import org.apache.ftpserver.usermanager.TransferRateRequest;
 import org.apache.ftpserver.util.IoUtils;
 
 /**
@@ -143,11 +144,12 @@
                 bos = IoUtils.getBufferedOutputStream( file.createOutputStream(0L) );
 
                 // transfer data
-                Authority[] maxUploadRates = session.getUser().getAuthorities(TransferRatePermission.class);
+                TransferRateRequest transferRateRequest = new TransferRateRequest();
+                transferRateRequest = (TransferRateRequest) session.getUser().authorize(transferRateRequest);
                 
                 int maxRate = 0;
-                if(maxUploadRates.length > 0) {
-                    maxRate = ((TransferRatePermission)maxUploadRates[0]).getMaxUploadRate();
+                if(transferRateRequest != null) {
+                    maxRate = transferRateRequest.getMaxUploadRate();
                 }
                 long transSz = handler.transfer(bis, bos, maxRate);
                 

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/USER.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/USER.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/USER.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/USER.java Tue Jan  2 13:57:16 2007
@@ -115,7 +115,7 @@
                         stat.getCurrentUserLoginNumber(configUser) + 1,
                         stat.getCurrentUserLoginNumber(configUser, session.getRemoteAddress()) + 1);
                 
-                if(!configUser.authorize(loginRequest)) {
+                if(configUser.authorize(loginRequest) == null) {
                     out.send(421, "USER.login", null);
                     return;
                 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/filesystem/NativeFileObject.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/filesystem/NativeFileObject.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/filesystem/NativeFileObject.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/filesystem/NativeFileObject.java Tue Jan  2 13:57:16 2007
@@ -188,7 +188,7 @@
      * Check file write permission.
      */
     public boolean hasWritePermission() {
-        if(!user.authorize(new WriteRequest(getFullName()))) {
+        if(user.authorize(new WriteRequest(getFullName())) == null) {
             return false;
         }
         

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/BaseUser.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/BaseUser.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/BaseUser.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/BaseUser.java Tue Jan  2 13:57:16 2007
@@ -169,19 +169,31 @@
     /**
      * @see User#authorize(AuthorizationRequest)
      */
-    public boolean authorize(AuthorizationRequest request) {
+    public AuthorizationRequest authorize(AuthorizationRequest request) {
         Authority[] authorities = getAuthorities();
         
+        boolean someoneCouldAuthorize = false;
         for (int i = 0; i < authorities.length; i++) {
             Authority authority = authorities[i];
             
             if(authority.canAuthorize(request)) {
-                return authority.authorize(request);
+                someoneCouldAuthorize = true;
+                
+                request = authority.authorize(request);
+                
+                // authorization failed, return null
+                if(request == null) {
+                    return null;
+                }
             }
             
         }
         
-        return false;
+        if(someoneCouldAuthorize) {
+            return request;
+        } else {
+            return null;
+        }
     }
 
     public Authority[] getAuthorities(Class clazz) {

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/ConcurrentLoginPermission.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/ConcurrentLoginPermission.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/ConcurrentLoginPermission.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/ConcurrentLoginPermission.java Tue Jan  2 13:57:16 2007
@@ -38,20 +38,23 @@
     /**
      * @see Authority#authorize(AuthorizationRequest)
      */
-    public boolean authorize(AuthorizationRequest request) {
+    public AuthorizationRequest authorize(AuthorizationRequest request) {
         if (request instanceof ConcurrentLoginRequest) {
             ConcurrentLoginRequest concurrentLoginRequest = (ConcurrentLoginRequest) request;
             
             if(maxConcurrentLogins != 0 && maxConcurrentLogins < concurrentLoginRequest.getConcurrentLogins()) {
-                return false; 
+                return null; 
             } else if(maxConcurrentLoginsPerIP != 0 
                     && maxConcurrentLoginsPerIP < concurrentLoginRequest.getConcurrentLoginsFromThisIP()) {
-                return false;
+                return null;
             } else {
-                return true;
+                concurrentLoginRequest.setMaxConcurrentLogins(maxConcurrentLogins);
+                concurrentLoginRequest.setMaxConcurrentLoginsPerIP(maxConcurrentLoginsPerIP);
+                
+                return concurrentLoginRequest;
             }
         } else {
-            return false;
+            return null;
         }
     }
 
@@ -60,19 +63,5 @@
      */
     public boolean canAuthorize(AuthorizationRequest request) {
         return request instanceof ConcurrentLoginRequest;
-    }
-
-    /**
-     * @return the maxConcurrentLogins
-     */
-    public int getMaxConcurrentLogins() {
-        return maxConcurrentLogins;
-    }
-
-    /**
-     * @return the maxConcurrentLoginsPerIP
-     */
-    public int getMaxConcurrentLoginsPerIP() {
-        return maxConcurrentLoginsPerIP;
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/ConcurrentLoginRequest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/ConcurrentLoginRequest.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/ConcurrentLoginRequest.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/ConcurrentLoginRequest.java Tue Jan  2 13:57:16 2007
@@ -22,12 +22,17 @@
 import org.apache.ftpserver.ftplet.AuthorizationRequest;
 
 /**
- * Class representing a write request
+ * Class representing a request to log in a number of concurrent times
  */
 public class ConcurrentLoginRequest implements AuthorizationRequest {
    
     private int concurrentLogins;
     private int concurrentLoginsFromThisIP;
+    
+    private int maxConcurrentLogins = 0;
+    private int maxConcurrentLoginsPerIP = 0;
+    
+
     /**
      * @param concurrentLogins
      * @param concurrentLoginsFromThisIP
@@ -38,15 +43,53 @@
         this.concurrentLoginsFromThisIP = concurrentLoginsFromThisIP;
     }
     /**
-     * @return the concurrentLogins
+     * The number of concurrent logins requested
+     * @return the concurrentLogins The number of current concurrent logins
      */
     public int getConcurrentLogins() {
         return concurrentLogins;
     }
     /**
+     * The number of concurrent logins from this IP requested
      * @return the concurrentLoginsFromThisIP
+     *   The number of current concurrent logins from this IP
      */
     public int getConcurrentLoginsFromThisIP() {
         return concurrentLoginsFromThisIP;
+    }
+    
+    /**
+     * The maximum allowed concurrent logins for this user, or
+     * 0 if no limit is set. This is normally populated by 
+     * {@link ConcurrentLoginPermission}
+     * @return The maximum allowed concurrent logins
+     */
+    public int getMaxConcurrentLogins() {
+        return maxConcurrentLogins;
+    }
+    /**
+     * Set the maximum allowed concurrent logins for this user
+     * @param maxConcurrentLogins Set max allowed concurrent connections
+     */
+    void setMaxConcurrentLogins(int maxConcurrentLogins) {
+        this.maxConcurrentLogins = maxConcurrentLogins;
+    }
+    
+    /**
+     * The maximum allowed concurrent logins per IP for this user, or
+     * 0 if no limit is set. This is normally populated by 
+     * {@link ConcurrentLoginPermission}
+     * @return The maximum allowed concurrent logins per IP
+     */
+    public int getMaxConcurrentLoginsPerIP() {
+        return maxConcurrentLoginsPerIP;
+    }
+    /**
+     * Set the maximum allowed concurrent logins per IP for this user
+     * @param maxConcurrentLoginsPerIP 
+     *     Set max allowed concurrent connections per IP
+     */
+    void setMaxConcurrentLoginsPerIP(int maxConcurrentLoginsPerIP) {
+        this.maxConcurrentLoginsPerIP = maxConcurrentLoginsPerIP;
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/DbUserManager.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/DbUserManager.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/DbUserManager.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/DbUserManager.java Tue Jan  2 13:57:16 2007
@@ -270,29 +270,29 @@
             map.put( ATTR_MAX_IDLE_TIME, new Integer(user.getMaxIdleTime()) );
             
             
+            TransferRateRequest transferRateRequest = new TransferRateRequest();
+            transferRateRequest = (TransferRateRequest) user.authorize(transferRateRequest);
             
-            Authority[] maxTransferRates = user.getAuthorities(TransferRatePermission.class);
-            
-            if(maxTransferRates.length > 0) {
-                map.put( ATTR_MAX_UPLOAD_RATE, new Integer(((TransferRatePermission)maxTransferRates[0]).getMaxUploadRate()) );
-                map.put( ATTR_MAX_DOWNLOAD_RATE, new Integer(((TransferRatePermission)maxTransferRates[0]).getMaxDownloadRate()) ); 
+            if(transferRateRequest != null) {
+                map.put( ATTR_MAX_UPLOAD_RATE, new Integer(transferRateRequest.getMaxUploadRate()) );
+                map.put( ATTR_MAX_DOWNLOAD_RATE, new Integer(transferRateRequest.getMaxDownloadRate()) ); 
             } else {
                 map.put( ATTR_MAX_UPLOAD_RATE, new Integer(0));
                 map.put( ATTR_MAX_DOWNLOAD_RATE, new Integer(0) ); 
             }
 
+            // request that always will succeed
+            ConcurrentLoginRequest concurrentLoginRequest = new ConcurrentLoginRequest(0, 0);
+            concurrentLoginRequest = (ConcurrentLoginRequest) user.authorize(concurrentLoginRequest);
             
-            Authority[] concurrentLoginPermissions = user.getAuthorities(ConcurrentLoginPermission.class);
-            
-            if(concurrentLoginPermissions.length > 0) {
+            if(concurrentLoginRequest != null) {
                 map.put( ATTR_MAX_LOGIN_NUMBER, 
-                        new Integer(((ConcurrentLoginPermission)concurrentLoginPermissions[0]).getMaxConcurrentLogins()));
+                        new Integer(concurrentLoginRequest.getMaxConcurrentLogins()));
                 map.put( ATTR_MAX_LOGIN_PER_IP, 
-                        new Integer(((ConcurrentLoginPermission)concurrentLoginPermissions[0]).getMaxConcurrentLoginsPerIP()));
+                        new Integer(concurrentLoginRequest.getMaxConcurrentLoginsPerIP()));
             } else {
                 map.put( ATTR_MAX_LOGIN_NUMBER, new Integer(0));
                 map.put( ATTR_MAX_LOGIN_PER_IP, new Integer(0));
-                
             }
             
 

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/PropertiesUserManager.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/PropertiesUserManager.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/PropertiesUserManager.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/PropertiesUserManager.java Tue Jan  2 13:57:16 2007
@@ -124,26 +124,31 @@
        }
        userDataProp.setProperty(thisPrefix + ATTR_HOME,              home);
        userDataProp.setProperty(thisPrefix + ATTR_ENABLE,            usr.getEnabled());
-       userDataProp.setProperty(thisPrefix + ATTR_WRITE_PERM,        usr.authorize(new WriteRequest()));
+       userDataProp.setProperty(thisPrefix + ATTR_WRITE_PERM,        usr.authorize(new WriteRequest()) != null);
        userDataProp.setProperty(thisPrefix + ATTR_MAX_IDLE_TIME,     usr.getMaxIdleTime());
        
-       Authority[] maxTransferRates = usr.getAuthorities(TransferRatePermission.class);
+       TransferRateRequest transferRateRequest = new TransferRateRequest();
+       transferRateRequest = (TransferRateRequest) usr.authorize(transferRateRequest);
        
-       if(maxTransferRates.length > 0) {
+       if(transferRateRequest != null) {
            userDataProp.setProperty(thisPrefix + ATTR_MAX_UPLOAD_RATE,   
-                   ((TransferRatePermission)maxTransferRates[0]).getMaxUploadRate());
+                   transferRateRequest.getMaxUploadRate());
            userDataProp.setProperty(thisPrefix + ATTR_MAX_DOWNLOAD_RATE, 
-                   ((TransferRatePermission)maxTransferRates[0]).getMaxDownloadRate());
+                   transferRateRequest.getMaxDownloadRate());
        } else {
            userDataProp.remove(thisPrefix + ATTR_MAX_UPLOAD_RATE);
            userDataProp.remove(thisPrefix + ATTR_MAX_DOWNLOAD_RATE);       
        }
        
-       Authority[] concurrentLoginPermissions = usr.getAuthorities(ConcurrentLoginPermission.class);
+       // request that always will succeed
+       ConcurrentLoginRequest concurrentLoginRequest = new ConcurrentLoginRequest(0, 0);
+       concurrentLoginRequest = (ConcurrentLoginRequest) usr.authorize(concurrentLoginRequest);
        
-       if(concurrentLoginPermissions.length > 0) {
-           userDataProp.setProperty(thisPrefix + ATTR_MAX_LOGIN_NUMBER, ((ConcurrentLoginPermission)concurrentLoginPermissions[0]).getMaxConcurrentLogins());
-           userDataProp.setProperty(thisPrefix + ATTR_MAX_LOGIN_PER_IP, ((ConcurrentLoginPermission)concurrentLoginPermissions[0]).getMaxConcurrentLoginsPerIP());
+       if(concurrentLoginRequest != null) {
+           userDataProp.setProperty(thisPrefix + ATTR_MAX_LOGIN_NUMBER, 
+                   concurrentLoginRequest.getMaxConcurrentLogins());
+           userDataProp.setProperty(thisPrefix + ATTR_MAX_LOGIN_PER_IP, 
+                   concurrentLoginRequest.getMaxConcurrentLoginsPerIP());
        } else {
            userDataProp.remove(thisPrefix + ATTR_MAX_LOGIN_NUMBER);
            userDataProp.remove(thisPrefix + ATTR_MAX_LOGIN_PER_IP);   

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/TransferRatePermission.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/TransferRatePermission.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/TransferRatePermission.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/TransferRatePermission.java Tue Jan  2 13:57:16 2007
@@ -38,31 +38,23 @@
     /**
      * @see Authority#authorize(AuthorizationRequest)
      */
-    public boolean authorize(AuthorizationRequest request) {
-        return false;
+    public AuthorizationRequest authorize(AuthorizationRequest request) {
+        if (request instanceof TransferRateRequest) {
+            TransferRateRequest transferRateRequest = (TransferRateRequest) request;
+            
+            transferRateRequest.setMaxDownloadRate(maxDownloadRate);
+            transferRateRequest.setMaxUploadRate(maxUploadRate);
+            
+            return transferRateRequest;
+        } else {
+            return null;
+        }
     }
 
     /**
      * @see Authority#canAuthorize(AuthorizationRequest)
      */
     public boolean canAuthorize(AuthorizationRequest request) {
-        return false;
+        return request instanceof TransferRateRequest;
     }
-
-    /**
-     * @return the maxUploadRate
-     */
-    public int getMaxUploadRate() {
-        return maxUploadRate;
-    }
-
-    /**
-     * @return the maxUploadRate
-     */
-    public int getMaxDownloadRate() {
-        return maxDownloadRate;
-    }
-   
-
-    
 }

Added: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/TransferRateRequest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/TransferRateRequest.java?view=auto&rev=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/TransferRateRequest.java (added)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/TransferRateRequest.java Tue Jan  2 13:57:16 2007
@@ -0,0 +1,58 @@
+/*
+ * 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.ftpserver.usermanager;
+
+import org.apache.ftpserver.ftplet.AuthorizationRequest;
+
+/**
+ * Request for getting the maximum allowed transfer rates for a user
+ */
+public class TransferRateRequest implements AuthorizationRequest {
+
+    private int maxDownloadRate = 0;
+    private int maxUploadRate = 0;
+    
+    /**
+     * @return the maxDownloadRate
+     */
+    public int getMaxDownloadRate() {
+        return maxDownloadRate;
+    }
+    /**
+     * @param maxDownloadRate the maxDownloadRate to set
+     */
+    public void setMaxDownloadRate(int maxDownloadRate) {
+        this.maxDownloadRate = maxDownloadRate;
+    }
+    /**
+     * @return the maxUploadRate
+     */
+    public int getMaxUploadRate() {
+        return maxUploadRate;
+    }
+    /**
+     * @param maxUploadRate the maxUploadRate to set
+     */
+    public void setMaxUploadRate(int maxUploadRate) {
+        this.maxUploadRate = maxUploadRate;
+    }
+    
+    
+}

Propchange: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/TransferRateRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/WritePermission.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/WritePermission.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/WritePermission.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/usermanager/WritePermission.java Tue Jan  2 13:57:16 2007
@@ -47,15 +47,19 @@
     /**
      * @see Authority#authorize(AuthorizationRequest)
      */
-    public boolean authorize(AuthorizationRequest request) {
+    public AuthorizationRequest authorize(AuthorizationRequest request) {
         if(request instanceof WriteRequest) {
             WriteRequest writeRequest = (WriteRequest) request;
             
             String requestFile = writeRequest.getFile();
 
-            return requestFile.startsWith(permissionRoot);
+            if(requestFile.startsWith(permissionRoot)) {
+                return writeRequest;
+            } else {
+                return null;
+            }
         } else {
-            return false;
+            return null;
         }
     }
 

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/filesystem/NativeFileObjectTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/filesystem/NativeFileObjectTest.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/filesystem/NativeFileObjectTest.java (original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/filesystem/NativeFileObjectTest.java Tue Jan  2 13:57:16 2007
@@ -47,8 +47,8 @@
 
     public static class AlwaysAuthorizedUser extends BaseUser {
 
-        public boolean authorize(AuthorizationRequest request) {
-            return true;
+        public AuthorizationRequest authorize(AuthorizationRequest request) {
+            return request;
         }
         
     }

Added: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/BaseUserTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/BaseUserTest.java?view=auto&rev=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/BaseUserTest.java (added)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/BaseUserTest.java Tue Jan  2 13:57:16 2007
@@ -0,0 +1,117 @@
+/*
+ * 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.ftpserver.usermanager;
+
+
+
+import org.apache.ftpserver.ftplet.Authority;
+import org.apache.ftpserver.ftplet.AuthorizationRequest;
+
+import junit.framework.TestCase;
+
+public class BaseUserTest extends TestCase {
+    
+    private static final Authority ALWAYS_ALLOW_AUTHORITY = new Authority() {
+        public AuthorizationRequest authorize(AuthorizationRequest request) {
+            return request;
+        }
+
+        public boolean canAuthorize(AuthorizationRequest request) {
+            return true;
+        }
+    };
+
+    private static final Authority NEVER_ALLOW_AUTHORITY = new Authority() {
+        public AuthorizationRequest authorize(AuthorizationRequest request) {
+            return null;
+        }
+        
+        public boolean canAuthorize(AuthorizationRequest request) {
+            return true;
+        }
+    };
+
+    private static final Authority CANT_AUTHORITY = new Authority() {
+        public AuthorizationRequest authorize(AuthorizationRequest request) {
+            return null;
+        }
+        
+        public boolean canAuthorize(AuthorizationRequest request) {
+            return false;
+        }
+    };
+    
+    private static final AuthorizationRequest REQUEST = new AuthorizationRequest(){};
+    
+    private BaseUser user = new BaseUser();
+    
+    public void testAllow() {
+        Authority[] authorities = new Authority[]{
+                ALWAYS_ALLOW_AUTHORITY
+        };
+        
+        
+        user.setAuthorities(authorities);
+        
+        assertSame(REQUEST, user.authorize(REQUEST));
+    }
+
+    public void testDisallow() {
+        Authority[] authorities = new Authority[]{
+                NEVER_ALLOW_AUTHORITY
+        };
+        
+        user.setAuthorities(authorities);
+        
+        assertNull(user.authorize(REQUEST));
+    }
+
+    public void testMultipleDisallowLast() {
+        Authority[] authorities = new Authority[]{
+                ALWAYS_ALLOW_AUTHORITY,
+                NEVER_ALLOW_AUTHORITY
+        };
+        
+        user.setAuthorities(authorities);
+        
+        assertNull(user.authorize(REQUEST));
+    }
+
+    public void testMultipleAllowLast() {
+        Authority[] authorities = new Authority[]{
+                NEVER_ALLOW_AUTHORITY,
+                ALWAYS_ALLOW_AUTHORITY
+        };
+        
+        user.setAuthorities(authorities);
+        
+        assertNull(user.authorize(REQUEST));
+    }
+
+    public void testNonCanAuthorize() {
+        Authority[] authorities = new Authority[]{
+                CANT_AUTHORITY
+        };
+        
+        user.setAuthorities(authorities);
+        
+        assertNull(user.authorize(REQUEST));
+    }
+}

Propchange: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/BaseUserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/ConcurrentLoginPermissionTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/ConcurrentLoginPermissionTest.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/ConcurrentLoginPermissionTest.java (original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/ConcurrentLoginPermissionTest.java Tue Jan  2 13:57:16 2007
@@ -36,42 +36,42 @@
         ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4, 2);
         ConcurrentLoginRequest request = new ConcurrentLoginRequest(1, 1);
         
-        assertTrue(permission.authorize(request));
+        assertNotNull(permission.authorize(request));
     }
 
     public void testMaxValuesBoth() {
         ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4, 2);
         ConcurrentLoginRequest request = new ConcurrentLoginRequest(4, 2);
         
-        assertTrue(permission.authorize(request));
+        assertNotNull(permission.authorize(request));
     }
 
     public void testMaxLoginsTooLarge() {
         ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4, 2);
         ConcurrentLoginRequest request = new ConcurrentLoginRequest(5, 2);
         
-        assertFalse(permission.authorize(request));
+        assertNull(permission.authorize(request));
     }
 
     public void testMaxLoginsPerIPTooLarge() {
         ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4, 2);
         ConcurrentLoginRequest request = new ConcurrentLoginRequest(3, 3);
         
-        assertFalse(permission.authorize(request));
+        assertNull(permission.authorize(request));
     }
 
     public void testAllowAnyMaxLogins() {
         ConcurrentLoginPermission permission = new ConcurrentLoginPermission(0, 2);
         ConcurrentLoginRequest request = new ConcurrentLoginRequest(5, 2);
         
-        assertTrue(permission.authorize(request));
+        assertNotNull(permission.authorize(request));
     }
 
     public void testAllowAnyMaxLoginsPerIP() {
         ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4, 0);
         ConcurrentLoginRequest request = new ConcurrentLoginRequest(3, 3);
         
-        assertTrue(permission.authorize(request));
+        assertNotNull(permission.authorize(request));
     }
     
 }

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/UserManagerTestTemplate.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/UserManagerTestTemplate.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/UserManagerTestTemplate.java (original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/UserManagerTestTemplate.java Tue Jan  2 13:57:16 2007
@@ -140,7 +140,7 @@
         assertEquals(0, getMaxLoginNumber(user));
         assertEquals(0, getMaxLoginPerIP(user));
         assertEquals(0, getMaxUploadRate(user));
-        assertFalse(user.authorize(new WriteRequest()));
+        assertNull(user.authorize(new WriteRequest()));
         assertTrue(user.getEnabled());
     }
 
@@ -155,7 +155,7 @@
         assertEquals(3, getMaxLoginNumber(user));
         assertEquals(4, getMaxLoginPerIP(user));
         assertEquals(5, getMaxUploadRate(user));
-        assertTrue(user.authorize(new WriteRequest()));
+        assertNotNull(user.authorize(new WriteRequest()));
         assertFalse(user.getEnabled());
     }
 
@@ -164,40 +164,44 @@
     }
 
     private int getMaxDownloadRate(User user) {
-        Authority[] maxTransferRates = user.getAuthorities(TransferRatePermission.class);
+        TransferRateRequest transferRateRequest = new TransferRateRequest();
+        transferRateRequest = (TransferRateRequest) user.authorize(transferRateRequest);
     
-        if(maxTransferRates.length > 0) {
-            return ((TransferRatePermission)maxTransferRates[0]).getMaxDownloadRate();
+        if(transferRateRequest != null) {
+            return transferRateRequest.getMaxDownloadRate();
         } else {
             return 0;
         }
     }
 
     private int getMaxUploadRate(User user) {
-        Authority[] maxTransferRates = user.getAuthorities(TransferRatePermission.class);
+        TransferRateRequest transferRateRequest = new TransferRateRequest();
+        transferRateRequest = (TransferRateRequest) user.authorize(transferRateRequest);
     
-        if(maxTransferRates.length > 0) {
-            return ((TransferRatePermission)maxTransferRates[0]).getMaxUploadRate();
+        if(transferRateRequest != null) {
+            return transferRateRequest.getMaxUploadRate();
         } else {
             return 0;
         } 
     }
 
     private int getMaxLoginNumber(User user) {
-        Authority[] concurrentLoginPermissions = user.getAuthorities(ConcurrentLoginPermission.class);
+        ConcurrentLoginRequest  concurrentLoginRequest = new ConcurrentLoginRequest(0, 0);
+        concurrentLoginRequest = (ConcurrentLoginRequest) user.authorize(concurrentLoginRequest);
         
-        if(concurrentLoginPermissions.length > 0) {
-            return ((ConcurrentLoginPermission)concurrentLoginPermissions[0]).getMaxConcurrentLogins();
+        if(concurrentLoginRequest != null) {
+            return concurrentLoginRequest.getMaxConcurrentLogins();
         } else {
             return 0;
         } 
     }
 
     private int getMaxLoginPerIP(User user) {
-        Authority[] concurrentLoginPermissions = user.getAuthorities(ConcurrentLoginPermission.class);
+        ConcurrentLoginRequest  concurrentLoginRequest = new ConcurrentLoginRequest(0, 0);
+        concurrentLoginRequest = (ConcurrentLoginRequest) user.authorize(concurrentLoginRequest);
         
-        if(concurrentLoginPermissions.length > 0) {
-            return ((ConcurrentLoginPermission)concurrentLoginPermissions[0]).getMaxConcurrentLoginsPerIP();
+        if(concurrentLoginRequest != null) {
+            return concurrentLoginRequest.getMaxConcurrentLoginsPerIP();
         } else {
             return 0;
         } 
@@ -229,7 +233,7 @@
         assertNull(actualUser.getPassword());
         assertEquals(user.getHomeDirectory(), actualUser.getHomeDirectory());
         assertEquals(user.getEnabled(), actualUser.getEnabled());
-        assertTrue(user.authorize(new WriteRequest()));
+        assertNotNull(user.authorize(new WriteRequest()));
         assertEquals(getMaxDownloadRate(user), getMaxDownloadRate(actualUser));
         assertEquals(user.getMaxIdleTime(), actualUser.getMaxIdleTime());
         assertEquals(getMaxLoginNumber(user), getMaxLoginNumber(actualUser));
@@ -253,7 +257,7 @@
         assertEquals(0, getMaxLoginNumber(actualUser));
         assertEquals(0, getMaxLoginPerIP(actualUser));
         assertEquals(0, getMaxUploadRate(actualUser));
-        assertFalse(user.authorize(new WriteRequest()));
+        assertNull(user.authorize(new WriteRequest()));
         assertTrue(actualUser.getEnabled());
     }
 
@@ -272,7 +276,7 @@
         assertNull(actualUser.getPassword());
         assertEquals("/", actualUser.getHomeDirectory());
         assertEquals(true, actualUser.getEnabled());
-        assertFalse(user.authorize(new WriteRequest()));
+        assertNull(user.authorize(new WriteRequest()));
         assertEquals(0, getMaxDownloadRate(actualUser));
         assertEquals(0, actualUser.getMaxIdleTime());
         assertEquals(0, getMaxLoginNumber(actualUser));

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/WritePermissionTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/WritePermissionTest.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/WritePermissionTest.java (original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/usermanager/WritePermissionTest.java Tue Jan  2 13:57:16 2007
@@ -29,17 +29,17 @@
     public void testRootDir() throws Exception {
         WritePermission permission = new WritePermission("/");
         
-        assertTrue(permission.authorize(new WriteRequest("/")));    
+        assertNotNull(permission.authorize(new WriteRequest("/")));    
     }
     
     
     public void testDirs() throws Exception {
         WritePermission permission = new WritePermission("/bar");
         
-        assertFalse(permission.authorize(new WriteRequest("/foo")));    
-        assertFalse(permission.authorize(new WriteRequest("/foo/bar")));    
-        assertTrue(permission.authorize(new WriteRequest("/bar")));    
-        assertTrue(permission.authorize(new WriteRequest("/bar/foo")));    
+        assertNull(permission.authorize(new WriteRequest("/foo")));    
+        assertNull(permission.authorize(new WriteRequest("/foo/bar")));    
+        assertNotNull(permission.authorize(new WriteRequest("/bar")));    
+        assertNotNull(permission.authorize(new WriteRequest("/bar/foo")));    
     }
 
 }

Modified: incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/Authority.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/Authority.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/Authority.java (original)
+++ incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/Authority.java Tue Jan  2 13:57:16 2007
@@ -39,5 +39,5 @@
      *   If the request can not be authorized (as checked by {@link #canAuthorize(AuthorizationRequest)} 
      *   by this Authority, false is returned.
      */
-    boolean authorize(AuthorizationRequest request);
+    AuthorizationRequest authorize(AuthorizationRequest request);
 }

Modified: incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/User.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/User.java?view=diff&rev=491943&r1=491942&r2=491943
==============================================================================
--- incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/User.java (original)
+++ incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/User.java Tue Jan  2 13:57:16 2007
@@ -48,9 +48,10 @@
     /**
      * Authorize a {@link AuthorizationRequest} for this user
      * @param request The {@link AuthorizationRequest} to authorize
-     * @return True if the user is allowed to perform the action, false otherwise
+     * @return A populated AuthorizationRequest if the user was 
+     * authorized, null otherwise.
      */
-    boolean authorize(AuthorizationRequest request);
+    AuthorizationRequest authorize(AuthorizationRequest request);
     
     /**
      * Get the maximum idle time in seconds. Zero or less idle time means no limit.



Mime
View raw message