View Javadoc
1 2 package jsdsi; 3 4 import java.util.Iterator; 5 6 import jsdsi.sexp.Sexp; 7 import jsdsi.sexp.SexpList; 8 import jsdsi.sexp.SexpParseException; 9 import jsdsi.sexp.SexpUtil; 10 11 /*** 12 * An access control list (ACL) that restricts access to an object on 13 * the local system. The ACL contains a set of ACL entries that specify 14 * which principals may access the object and how. 15 * 16 * @see AclEntry 17 * 18 * @author Sameer Ajmani 19 * @author Sean Radford 20 * @version $Revision: 1.3.2.1 $ $Date: 2005/11/08 03:12:52 $ 21 */ 22 public class Acl extends Obj { 23 24 private static final long serialVersionUID = -5980365133398522076L; 25 26 /*** 27 * The entries the Acl consists of. 28 */ 29 private transient final AclEntry[] entries; 30 31 /*** 32 * Constructs a new <code>Acl</code> from given <code>AclEntry</code>s. 33 * 34 * @param e array of <code>AclEntry</code>s to create a new 35 * <code>Acl</code> from. 36 */ 37 public Acl(AclEntry[] e) { 38 assert(e != null) : "null entries"; 39 entries = e; 40 } 41 42 /*** 43 * Returns an array of <code>AclEntry</code>s. 44 * 45 * @see AclEntry 46 * 47 * @return an array of <code>AclEntry</code>s. 48 */ 49 public AclEntry[] getEntries() { 50 return entries; 51 } 52 53 /*** 54 * @see java.lang.Object#equals(Object) 55 */ 56 public boolean equals(Object o) { 57 return (o instanceof Acl) && Util.equals(entries, ((Acl) o).entries); 58 } 59 60 /*** 61 * @see java.lang.Object#hashCode() 62 */ 63 public int hashCode() { 64 return Util.hashCode(entries); 65 } 66 67 /*** 68 * Converts this <code>Acl</code> to an <code>SecpList</code>. 69 * 70 * @return an <code>SecpList</code> that represents this <code>Acl</code>. 71 */ 72 public SexpList toSexp() { 73 Sexp[] ss = new Sexp[entries.length]; 74 for (int i = 0; i < entries.length; i++) { 75 ss[i] = entries[i].toSexp(); 76 } 77 return SexpUtil.toSexp("acl", ss); 78 } 79 80 static Acl parseAcl(SexpList l) throws SexpParseException { 81 Iterator abody = SexpUtil.getBody(l); 82 AclEntry[] entries = new AclEntry[l.size() - 1]; 83 for (int i = 0; i < entries.length; i++) { 84 entries[i] = AclEntry.parseAclEntry( 85 SexpUtil.getNextList(abody, 86 "entry", 87 "acl entry")); 88 } 89 SexpUtil.checkDone(abody, "acl"); 90 return new Acl(entries); 91 } 92 }

This page was automatically generated by Maven