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.3 by tdb, Fri Dec 21 16:49:18 2001 UTC vs.
Revision 1.6 by tdb, Mon Dec 24 04:17:29 2001 UTC

# Line 5 | Line 5
5   import uk.org.iscream.cms.server.util.*;
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 17 | 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 120 | Line 121 | public class ACL {
121      }
122      
123      /**
124 <     * Gets the ACL as a String for debugging.
124 >     * Gives a String representation of this ACL.
125       *
126       * @return A String representation of this ACL.
127       */
128 <    public String getStringACL() {
129 <        String acl = "";
128 >    public String toString() {
129 >        StringBuffer acl = new StringBuffer();
130 >        acl.append("{");
131          for(int i=0; i < _acl.size(); i++) {
132 <            ACLRule rule = (ACLRule) _acl.get(i);
133 <            if(rule._allow) {
132 <                acl += "ALLOW:" + rule._expression + " ";
133 <            }
134 <            else {
135 <                acl += "DENY:" + rule._expression + " ";
136 <            }
132 >            acl.append((ACLRule) _acl.get(i));
133 >            acl.append(",");
134          }
135          if(_defaultMode) {
136 <            acl += "DEFAULT:ALLOW";
136 >            acl.append("DEFAULT=ALLOW");
137          }
138          else {
139 <            acl += "DEFAULT:DENY";
139 >            acl.append("DEFAULT=DENY");
140          }
141 <        return acl;
141 >        acl.append("}");
142 >        return acl.toString();
143      }
146    
147    /**
148     * Overrides the {@link java.lang.Object#toString() Object.toString()}
149     * method to provide clean logging (every class should have this).
150     *
151     * This uses the uk.org.iscream.cms.server.util.FormatName class
152     * to format the toString()
153     *
154     * @return the name of this class and its CVS revision
155     */
156    public String toString() {
157        return FormatName.getName(
158            _name,
159            getClass().getName(),
160            REVISION);
161    }
144  
145   //---PRIVATE METHODS---
146  
# Line 194 | Line 176 | public class ACL {
176      /**
177       * Wrapper class for an ACL rule.
178       */
179 <    private class ACLRule {
179 >    private class ACLRule implements Serializable {
180          
181          /**
182           * Construct an ACL rule.
# Line 205 | Line 187 | public class ACL {
187          private ACLRule(boolean allow, String expression) {
188              _allow = allow;
189              _expression = expression;
190 +        }
191 +        
192 +        /**
193 +         * Returns a String representation of this rule.
194 +         *
195 +         * @return A String representation of this rule.
196 +         */
197 +        public String toString() {
198 +            if(_allow) {
199 +                return _expression + "=ALLOW";
200 +            }
201 +            else {
202 +                return _expression + "=DENY";
203 +            }
204          }
205          
206          /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines