1 package jsdsi;
2
3 import java.net.URI;
4
5 import jsdsi.sexp.SexpList;
6 import jsdsi.sexp.SexpParseException;
7
8 /***
9 * A principal: an entity that can define names and can grant and
10 * receive authorizations. Represented by a public key.
11 *
12 * @author Sameer Ajmani
13 * @author Sean Radford
14 * @version $Revision: 1.3.2.1 $ $Date: 2005/11/08 03:12:52 $
15 */
16 public abstract class Principal
17 extends Obj
18 implements Subject, java.security.Principal {
19
20 private static final long serialVersionUID = 4007409383894718535L;
21
22 /***
23 * Compares this <code>Principal</code> with another.
24 *
25 * @param p another principal to compare this one with.
26 * @return <code>true</code> if both principal are the same (with
27 * respect to their public key), <code>false</code> otherwise.
28 */
29 public abstract boolean samePrincipalAs(Principal p);
30
31 /***
32 * @see java.security.Principal#getName()
33 */
34 public String getName() {
35 return toString();
36 }
37
38 public abstract URI[] getURIs();
39
40 static Principal parsePrincipal(SexpList l) throws SexpParseException {
41 // a principal doesn't have it's own "principal" block
42 String type = l.getType();
43 if (type.equals("public-key"))
44 return PublicKey.parsePublicKey(l);
45 if (type.equals("hash"))
46 return PublicKeyHash.parsePublicKeyHash(l);
47
48 throw new SexpParseException("unrecognized principal type: " + type);
49 }
50 }
This page was automatically generated by Maven