stateblock JavaAppletFileACLs augments RFileSystem {
addstate RFileSystem.readACL: String[];
addstate RFileSystem.writeACL: String[];
addstate RFileSystem.initReadACL: boolean = false;
addstate RFileSystem.initWriteACL: boolean = false;
helper accessPermitted (acls: String [], path: String) returns boolean {
for (int i = acls.length ; i-- > 0 ;) {
if (path.startsWith (acls[i])) {
// debugMessage ("Match acl path: " + path + " / " + acls[i]);
return true;
}
}
return false;
}
helper parseACL (v: java.util.Vector, path: String, defaultPath: String) {
String sep = System.getProperty("path.separator");
StringTokenizer t = new StringTokenizer(path, sep);
// debugMessage ("Parsing acls: " + path);
while (t.hasMoreTokens()) {
String dir = t.nextToken();
if (dir.startsWith("~")) {
// debugMessage ("Adding acl: " + dir);
String homedir = System.getProperty ("user.home");
String fname = homedir + dir.substring (1);
// debugMessage ("==> " + fname);
v.addElement (fname);
} else if (dir.equals("+")) {
if (defaultPath != null) {
parseACL(v, defaultPath, null);
}
} else {
// debugMessage ("Adding acl: " + dir);
v.addElement(dir);
}
}
}
helper doParseACL (path: String, defaultPath: String) returns String[] {
// debugMessage ("Parse ACL: " + path + " / " + defaultPath);
if (path == null) {
return new String[0];
}
if (path.equals ("*")) {
return null;
}
Vector v = new Vector();
parseACL(v, path, defaultPath);
int size = v.size ();
String acl[] = new String [size];
v.copyInto(acl);
return acl;
}
helper initReadACLs () {
// debugMessage ("Initializing read acls...");
util.Assert.assert (!initReadACL);
readACL = doParseACL (System.getProperty("acl.read"),
System.getProperty("acl.read.default"));
initReadACL = true;
}
helper initWriteACLs () {
util.Assert.assert (!initWriteACL);
writeACL = doParseACL (System.getProperty("acl.write"),
System.getProperty("acl.write.default"));
initWriteACL = true;
}
}
Naccio Home Page
University of Virginia, Computer Science