Annotation of java/classes/org/w3c/jigsaw/acl/AuthUserPrincipal.java, revision 1.3
1.1 bmahe 1: // AuthUserPrincipal.java
1.3 ! ylafon 2: // $Id: AuthUserPrincipal.java,v 1.2 2000/08/16 21:37:33 ylafon Exp $
1.1 bmahe 3: // (c) COPYRIGHT MIT, INRIA and Keio, 1999.
4: // Please first read the full copyright statement in file COPYRIGHT.html
5:
6: package org.w3c.jigsaw.acl;
7:
8: import java.net.InetAddress;
9: import java.util.Hashtable;
10: import org.w3c.jigsaw.auth.AuthUser;
11: import org.w3c.jigsaw.auth.IPMatcher;
12:
13: /**
1.3 ! ylafon 14: * @author Benoît Mahé (bmahe@w3.org)
! 15: * @version $Revision: 1.2 $
1.1 bmahe 16: */
17: public class AuthUserPrincipal implements AclPrincipal {
1.2 ylafon 18:
1.3 ! ylafon 19: protected String name = null;
! 20: protected String password = null;
! 21: protected String realm = null;
! 22: protected Hashtable values = null;
1.1 bmahe 23: protected IPMatcher ipmatcher = null;
24:
25: public boolean equals(Object another) {
1.3 ! ylafon 26: if (another instanceof AuthUserPrincipal) {
! 27: return toString().equals(another.toString());
! 28: } else {
! 29: return another.equals(this);
! 30: }
1.1 bmahe 31: }
32:
33: public String toString() {
1.3 ! ylafon 34: if (password == null)
! 35: return name;
! 36: else
! 37: return name + ":" + password;
1.1 bmahe 38: }
39:
40: public int hashCode() {
1.3 ! ylafon 41: return toString().hashCode();
1.1 bmahe 42: }
43:
44: public String getName() {
1.3 ! ylafon 45: return name;
1.1 bmahe 46: }
47:
48: public String getRealm() {
1.3 ! ylafon 49: return realm;
1.1 bmahe 50: }
51:
52: public String getPassword() {
1.3 ! ylafon 53: return password;
1.1 bmahe 54: }
55:
56: public void setValue(String name, Object value) {
1.3 ! ylafon 57: values.put(name, value);
1.1 bmahe 58: }
59:
60: public Object getValue(String name) {
1.3 ! ylafon 61: return values.get(name);
1.1 bmahe 62: }
63:
64: public boolean matchIP(InetAddress adr) {
1.3 ! ylafon 65: return (ipmatcher.lookup(adr) == Boolean.TRUE);
1.1 bmahe 66: }
67:
68: public AuthUserPrincipal(AuthUser user, String realm) {
1.3 ! ylafon 69: this.name = user.getName();
! 70: this.password = user.getPassword();
! 71: this.realm = realm;
! 72: this.ipmatcher = new IPMatcher();
! 73: this.values = new Hashtable();
! 74:
! 75: short ips[][] = user.getIPTemplates();
! 76: if (ips != null) {
! 77: for (short[] ip : ips) {
! 78: ipmatcher.add(ip, Boolean.TRUE);
! 79: }
! 80: }
1.1 bmahe 81: }
82:
1.3 ! ylafon 83:
1.1 bmahe 84: }
1.2 ylafon 85:
1.1 bmahe 86:
Webmaster