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 |
18 |
|
* @author $Author$ |
19 |
|
* @version $Id$ |
20 |
|
*/ |
21 |
< |
public class ACL { |
21 |
> |
public class ACL implements Serializable { |
22 |
|
|
23 |
|
//---FINAL ATTRIBUTES--- |
24 |
|
|
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 |
|
|
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. |
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 |
|
/** |