01: // SimplePrincipal.java
02: // $Id: SimplePrincipal.java,v 1.3 2000/06/21 14:11:24 ylafon Exp $
03: // (c) COPYRIGHT MIT, INRIA and Keio, 2000.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigsaw.acl;
07:
08: import java.security.Principal;
09: import java.util.Hashtable;
10: import java.net.InetAddress;
11:
12: /**
13: * The most simple principal, it takes only the realm name, username
14: * and passwd as arguments
15: */
16: public class SimplePrincipal implements AclPrincipal {
17: protected String name = null;
18: protected String password = null;
19: protected String realm = null;
20: protected Hashtable values = null;
21:
22: public boolean equals(Object another) {
23: if (another instanceof SimplePrincipal) {
24: return toString().equals(another.toString());
25: } else {
26: return another.equals(this );
27: }
28: }
29:
30: public String toString() {
31: if (password == null)
32: return name;
33: else
34: return name + ":" + password;
35: }
36:
37: public int hashCode() {
38: return toString().hashCode();
39: }
40:
41: public String getName() {
42: return name;
43: }
44:
45: public String getRealm() {
46: return realm;
47: }
48:
49: public String getPassword() {
50: return password;
51: }
52:
53: public void setValue(String name, Object value) {
54: values.put(name, value);
55: }
56:
57: public Object getValue(String name) {
58: return values.get(name);
59: }
60:
61: public boolean matchIP(InetAddress adr) {
62: return false;
63: }
64:
65: public SimplePrincipal(String name, String password, String realm) {
66: this .name = name;
67: this .password = password;
68: this .realm = realm;
69: this .values = new Hashtable();
70: }
71: }
|