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.3 by tdb, Fri Dec 21 16:49:18 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  
9   /**
# Line 87 | Line 86 | public class ACL {
86       * @return whether the address was permitted by the ACL
87       */
88      public boolean check(String address) {
89 <        Iterator i = _acl.iterator();
90 <        while(i.hasNext()) {
91 <            ACLRule item = (ACLRule) i.next();
92 <            if(StringUtils.wildcardCheck(address, item._expression)) {
94 <                return item._allow;
89 >        for(int i=0; i < _acl.size(); i++) {
90 >            ACLRule rule = (ACLRule) _acl.get(i);
91 >            if(StringUtils.wildcardCheck(address, rule._expression)) {
92 >                return rule._allow;
93              }
94          }
95          return _defaultMode;
# Line 109 | Line 107 | public class ACL {
107       * @return whether the InetAddress was permitted by the ACL
108       */
109      public boolean check(InetAddress address) {
110 <        Iterator i = _acl.iterator();
111 <        while(i.hasNext()) {
112 <            ACLRule item = (ACLRule) i.next();
113 <            if(StringUtils.wildcardCheck(address.getHostName(), item._expression)) {
116 <                return item._allow;
110 >        for(int i=0; i < _acl.size(); i++) {
111 >            ACLRule rule = (ACLRule) _acl.get(i);
112 >            if(StringUtils.wildcardCheck(address.getHostName(), rule._expression)) {
113 >                return rule._allow;
114              }
115 <            if(StringUtils.wildcardCheck(address.getHostAddress(), item._expression)) {
116 <                return item._allow;
115 >            if(StringUtils.wildcardCheck(address.getHostAddress(), rule._expression)) {
116 >                return rule._allow;
117              }
118          }
119          return _defaultMode;
# Line 129 | Line 126 | public class ACL {
126       */
127      public String getStringACL() {
128          String acl = "";
129 <        Iterator i = _acl.iterator();
130 <        while(i.hasNext()) {
131 <            ACLRule item = (ACLRule) i.next();
132 <            if(item._allow) {
136 <                acl += "ALLOW:" + item._expression + " ";
129 >        for(int i=0; i < _acl.size(); i++) {
130 >            ACLRule rule = (ACLRule) _acl.get(i);
131 >            if(rule._allow) {
132 >                acl += "ALLOW:" + rule._expression + " ";
133              }
134              else {
135 <                acl += "DENY:" + item._expression + " ";
135 >                acl += "DENY:" + rule._expression + " ";
136              }
137          }
138 <        return acl.substring(0, acl.length()-1);
138 >        if(_defaultMode) {
139 >            acl += "DEFAULT:ALLOW";
140 >        }
141 >        else {
142 >            acl += "DEFAULT:DENY";
143 >        }
144 >        return acl;
145      }
146      
147      /**
# Line 176 | Line 178 | public class ACL {
178      private String _name = null;
179      
180      /**
181 <     * 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.
181 >     * The ACL is stored in this ArrayList.
182       */
183 <    private LinkedList _acl = new LinkedList();
183 >    private ArrayList _acl = new ArrayList();
184      
185      /**
186       * The default mode of this ACL.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines