// Copyright 2007 the Contributors, as shown in the revision logs. // Licensed under the Apache Public Source License 2.0 ("the License"). // You may not use this file except in compliance with the License. package org.ibex.mail; import org.ibex.util.*; import org.ibex.mail.*; import org.ibex.js.*; import java.io.*; import java.net.*; import java.util.*; import java.text.*; /** an Access Control List */ public class Acl { public static class PermissionDenied extends RuntimeException { public PermissionDenied() { super(); } } /** an entry on an Acl; indicates permissions for a particular principal */ public static class Entry { public final boolean read; public final boolean list; public final boolean write; public final boolean delete; public final boolean insert; public final boolean lock; public final boolean admin; public final boolean post; public final boolean flags; public final boolean mkdir; private String toString = null; public Entry(boolean read, boolean list, boolean insert, boolean delete, boolean write, boolean lock, boolean admin, boolean post, boolean flags, boolean mkdir) { this.read = read; this.list = list; this.write = write; this.delete = delete; this.insert = insert; this.lock = lock; this.admin = admin; this.post = post; this.flags = flags; this.mkdir = mkdir; } public Entry(String asString) { this.toString = asString; if (asString == null) asString = ""; if (asString.equals("read")) asString = "rl"; if (asString.equals("post")) asString = "rlp"; if (asString.equals("write")) asString = "rlidwkpfm"; this.read = asString.indexOf('r') != -1; this.list = asString.indexOf('l') != -1; this.insert = asString.indexOf('i') != -1; this.delete = asString.indexOf('d') != -1; this.write = asString.indexOf('w') != -1; this.lock = asString.indexOf('k') != -1; this.admin = asString.indexOf('a') != -1; this.post = asString.indexOf('p') != -1; this.flags = asString.indexOf('f') != -1; this.mkdir = asString.indexOf('m') != -1; } public String toString() { if (toString != null) return toString; StringBuffer sb = new StringBuffer(); if (this.read) sb.append('r'); if (this.list) sb.append('l'); if (this.insert) sb.append('i'); if (this.delete) sb.append('d'); if (this.write) sb.append('w'); if (this.lock) sb.append('k'); if (this.admin) sb.append('a'); if (this.post) sb.append('p'); if (this.flags) sb.append('f'); if (this.mkdir) sb.append('m'); return toString = sb.toString(); } } }