--- java/classes/org/w3c/jigsaw/acl/AclPrincipal.java 1999/04/27 12:33:26 1.2 +++ java/classes/org/w3c/jigsaw/acl/AclPrincipal.java 1999/04/27 15:05:47 1.3 @@ -1,86 +1,52 @@ // AclPrincipal.java -// $Id: AclPrincipal.java,v 1.2 1999/04/27 12:33:26 bmahe Exp $ +// $Id: AclPrincipal.java,v 1.3 1999/04/27 15:05:47 bmahe Exp $ // (c) COPYRIGHT MIT, INRIA and Keio, 1999. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.jigsaw.acl; -import java.net.InetAddress; import java.security.Principal; -import java.util.Hashtable; - -import org.w3c.jigsaw.auth.AuthUser; -import org.w3c.jigsaw.auth.IPMatcher; +import java.net.InetAddress; /** - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @author Benoît Mahé (bmahe@w3.org) */ -public class AclPrincipal implements Principal { +abstract public interface AclPrincipal extends Principal { - protected String name = null; - protected String password = null; - protected String realm = null; - protected Hashtable values = null; - protected IPMatcher ipmatcher = null; - - public boolean equals(Object another) { - if (another instanceof AclPrincipal) { - return toString().equals(another.toString()); - } else { - return another.equals(this); - } - } - - public String toString() { - if (password == null) - return name; - else - return name+":"+password; - } - - public int hashCode() { - return toString().hashCode(); - } - - public String getName() { - return name; - } - - public String getRealm() { - return realm; - } - - public String getPassword() { - return password; - } - - public void setValue(String name, Object value) { - values.put(name, value); - } - - public Object getValue(String name) { - return values.get(name); - } - - public boolean matchIP(InetAddress adr) { - return (ipmatcher.lookup(adr) == Boolean.TRUE); - } - - public AclPrincipal(AuthUser user, String realm) { - this.name = user.getName(); - this.password = user.getPassword(); - this.realm = realm; - this.ipmatcher = new IPMatcher(); - this.values = new Hashtable(); - - short ips[][] = user.getIPTemplates(); - if ( ips != null ) { - for (int i = 0 ; i < ips.length ; i++) - ipmatcher.add(ips[i], Boolean.TRUE); - } - } + /** + * Get the realm associated to this principal.(could be his group) + * @return the realm name. + */ + abstract public String getRealm(); + + /** + * Get the password associated to this principal. + * @return the password + */ + abstract public String getPassword(); + + /** + * Set a parameter. + * @param name the parameter name + * @param value the parameter value + */ + abstract public void setValue(String name, Object value); + + /** + * Get a parameter value. + * @param name the parameter name. + * @return the parameter value + */ + abstract public Object getValue(String name); + + /** + * Return true if the IPadress associated to this principal match + * the given one. + * @param adr an IP adress + * @return true if the ip adress match. + */ + abstract public boolean matchIP(InetAddress adr); - }