ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/ACL/ACL.java
(Generate patch)

Comparing experimental/server/ACL/ACL.java (file contents):
Revision 1.2 by tdb, Thu Dec 20 00:59:54 2001 UTC vs.
Revision 1.4 by tdb, Sun Dec 23 00:29:33 2001 UTC

# Line 3 | Line 3
3  
4   //---IMPORTS---
5   import uk.org.iscream.cms.server.util.*;
6 < import java.util.LinkedList;
7 < import java.util.Iterator;
6 > import java.util.ArrayList;
7   import java.net.InetAddress;
8 + import java.io.Serializable;
9  
10   /**
11   * Access Control List for use primarily
# Line 18 | Line 18 | import java.net.InetAddress;
18   * @author  $Author$
19   * @version $Id$
20   */
21 < public class ACL {
21 > public class ACL implements Serializable {
22  
23   //---FINAL ATTRIBUTES---
24  
# Line 87 | Line 87 | public class ACL {
87       * @return whether the address was permitted by the ACL
88       */
89      public boolean check(String address) {
90 <        Iterator i = _acl.iterator();
91 <        while(i.hasNext()) {
92 <            ACLRule item = (ACLRule) i.next();
93 <            if(StringUtils.wildcardCheck(address, item._expression)) {
94 <                return item._allow;
90 >        for(int i=0; i < _acl.size(); i++) {
91 >            ACLRule rule = (ACLRule) _acl.get(i);
92 >            if(StringUtils.wildcardCheck(address, rule._expression)) {
93 >                return rule._allow;
94              }
95          }
96          return _defaultMode;
# Line 109 | Line 108 | public class ACL {
108       * @return whether the InetAddress was permitted by the ACL
109       */
110      public boolean check(InetAddress address) {
111 <        Iterator i = _acl.iterator();
112 <        while(i.hasNext()) {
113 <            ACLRule item = (ACLRule) i.next();
114 <            if(StringUtils.wildcardCheck(address.getHostName(), item._expression)) {
116 <                return item._allow;
111 >        for(int i=0; i < _acl.size(); i++) {
112 >            ACLRule rule = (ACLRule) _acl.get(i);
113 >            if(StringUtils.wildcardCheck(address.getHostName(), rule._expression)) {
114 >                return rule._allow;
115              }
116 <            if(StringUtils.wildcardCheck(address.getHostAddress(), item._expression)) {
117 <                return item._allow;
116 >            if(StringUtils.wildcardCheck(address.getHostAddress(), rule._expression)) {
117 >                return rule._allow;
118              }
119          }
120          return _defaultMode;
# Line 129 | Line 127 | public class ACL {
127       */
128      public String getStringACL() {
129          String acl = "";
130 <        Iterator i = _acl.iterator();
131 <        while(i.hasNext()) {
132 <            ACLRule item = (ACLRule) i.next();
133 <            if(item._allow) {
136 <                acl += "ALLOW:" + item._expression + " ";
130 >        for(int i=0; i < _acl.size(); i++) {
131 >            ACLRule rule = (ACLRule) _acl.get(i);
132 >            if(rule._allow) {
133 >                acl += "ALLOW:" + rule._expression + " ";
134              }
135              else {
136 <                acl += "DENY:" + item._expression + " ";
136 >                acl += "DENY:" + rule._expression + " ";
137              }
138          }
139 <        return acl.substring(0, acl.length()-1);
139 >        if(_defaultMode) {
140 >            acl += "DEFAULT:ALLOW";
141 >        }
142 >        else {
143 >            acl += "DEFAULT:DENY";
144 >        }
145 >        return acl;
146      }
147      
148      /**
# Line 176 | Line 179 | public class ACL {
179      private String _name = null;
180      
181      /**
182 <     * The ACL is stored in this LinkedList.
180 <     * This is ideal as the list is always searched
181 <     * from beginning to end in an iterative fashion.
182 >     * The ACL is stored in this ArrayList.
183       */
184 <    private LinkedList _acl = new LinkedList();
184 >    private ArrayList _acl = new ArrayList();
185      
186      /**
187       * The default mode of this ACL.
# Line 194 | Line 195 | public class ACL {
195      /**
196       * Wrapper class for an ACL rule.
197       */
198 <    private class ACLRule {
198 >    private class ACLRule implements Serializable {
199          
200          /**
201           * Construct an ACL rule.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines