}
private Acl parse(Principal owner, String name, String input) {
boolean negative = false;
Principal principal = null;
List permissions = new ArrayList();
Acl acl = new Acl(owner, name);
int PERMISSIONS = 1;
int PRINCIPAL = 2;
int state = PRINCIPAL;
for (StringTokenizer stringTokenizer = new StringTokenizer(input, " \n{}", true);
stringTokenizer.hasMoreTokens();) {
String t = stringTokenizer.nextToken();
if (" ".equals(t) || "\n".equals(t)) {
// do nothing
} else if ("{".equals(t)) {
state = PERMISSIONS;
} else if ("}".equals(t)) {
state = PRINCIPAL;
AclEntry entry = new AclEntry(principal);
Iterator iterator = permissions.iterator();
while (iterator.hasNext()) {
Permission permission = (Permission) iterator.next();
entry.addPermission(permission);
}
if (negative) {
entry.setNegativePermissions();
negative = false;
}
acl.addEntry(owner, entry);
permissions = new ArrayList();
principal = null;
} else if (state == PRINCIPAL) {
if (t.startsWith("-")) {
negative = true;
t = t.substring(1);
}
// handle "- principal" and "-principal"
if (!"".equals(t)) {
principal = new Principal(t);
}
} else if (state == PERMISSIONS) {
permissions.add(new Permission(t));
}
}