1 // Copyright 2007 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
6 import org.ibex.util.*;
7 import org.ibex.mail.*;
14 /** an Access Control List */
17 public static class PermissionDenied extends RuntimeException {
18 public PermissionDenied() { super(); }
21 /** an entry on an Acl; indicates permissions for a particular principal */
22 public static class Entry {
23 public final boolean read;
24 public final boolean list;
25 public final boolean write;
26 public final boolean delete;
27 public final boolean insert;
28 public final boolean lock;
29 public final boolean admin;
30 public final boolean post;
31 public final boolean flags;
32 public final boolean mkdir;
33 private String toString = null;
35 public Entry(boolean read,
57 public Entry(String asString) {
58 this.toString = asString;
59 if (asString == null) asString = "";
60 if (asString.equals("read")) asString = "rl";
61 if (asString.equals("post")) asString = "rlp";
62 if (asString.equals("write")) asString = "rlidwkpfm";
63 this.read = asString.indexOf('r') != -1;
64 this.list = asString.indexOf('l') != -1;
65 this.insert = asString.indexOf('i') != -1;
66 this.delete = asString.indexOf('d') != -1;
67 this.write = asString.indexOf('w') != -1;
68 this.lock = asString.indexOf('k') != -1;
69 this.admin = asString.indexOf('a') != -1;
70 this.post = asString.indexOf('p') != -1;
71 this.flags = asString.indexOf('f') != -1;
72 this.mkdir = asString.indexOf('m') != -1;
75 public String toString() {
76 if (toString != null) return toString;
77 StringBuffer sb = new StringBuffer();
78 if (this.read) sb.append('r');
79 if (this.list) sb.append('l');
80 if (this.insert) sb.append('i');
81 if (this.delete) sb.append('d');
82 if (this.write) sb.append('w');
83 if (this.lock) sb.append('k');
84 if (this.admin) sb.append('a');
85 if (this.post) sb.append('p');
86 if (this.flags) sb.append('f');
87 if (this.mkdir) sb.append('m');
88 return toString = sb.toString();