Diff for /java/classes/org/w3c/jigsaw/acl/AuthUserPrincipal.java between versions 1.2 and 1.3

version 1.2, 2000/08/16 21:37:33 version 1.3, 2012/06/16 15:48:44
Line 6 Line 6
 package org.w3c.jigsaw.acl;  package org.w3c.jigsaw.acl;
   
 import java.net.InetAddress;  import java.net.InetAddress;
 import java.security.Principal;  
 import java.util.Hashtable;  import java.util.Hashtable;
   
 import org.w3c.jigsaw.auth.AuthUser;  import org.w3c.jigsaw.auth.AuthUser;
 import org.w3c.jigsaw.auth.IPMatcher;  import org.w3c.jigsaw.auth.IPMatcher;
   
 /**  /**
    * @author Benoît Mahé (bmahe@w3.org)
  * @version $Revision$   * @version $Revision$
  * @author  Benoît Mahé (bmahe@w3.org)  
  */   */
 public class AuthUserPrincipal implements AclPrincipal {  public class AuthUserPrincipal implements AclPrincipal {
   
     protected String    name      = null;      protected String name = null;
     protected String    password  = null;      protected String password = null;
     protected String    realm     = null;      protected String realm = null;
     protected Hashtable values    = null;      protected Hashtable values = null;
     protected IPMatcher ipmatcher = null;      protected IPMatcher ipmatcher = null;
   
     public boolean equals(Object another) {      public boolean equals(Object another) {
         if (another instanceof AuthUserPrincipal) {          if (another instanceof AuthUserPrincipal) {
             return toString().equals(another.toString());              return toString().equals(another.toString());
         } else {          } else {
             return another.equals(this);              return another.equals(this);
         }          }
     }      }
   
     public String toString() {      public String toString() {
         if (password == null)          if (password == null)
             return name;              return name;
         else          else
             return name+":"+password;              return name + ":" + password;
     }      }
   
     public int hashCode() {      public int hashCode() {
         return toString().hashCode();          return toString().hashCode();
     }      }
   
     public String getName() {      public String getName() {
         return name;          return name;
     }      }
   
     public String getRealm() {      public String getRealm() {
         return realm;          return realm;
     }      }
   
     public String getPassword() {      public String getPassword() {
         return password;          return password;
     }      }
   
     public void setValue(String name, Object value) {      public void setValue(String name, Object value) {
         values.put(name, value);          values.put(name, value);
     }      }
   
     public Object getValue(String name) {      public Object getValue(String name) {
         return values.get(name);          return values.get(name);
     }      }
   
     public boolean matchIP(InetAddress adr) {      public boolean matchIP(InetAddress adr) {
         return (ipmatcher.lookup(adr) == Boolean.TRUE);          return (ipmatcher.lookup(adr) == Boolean.TRUE);
     }      }
   
     public AuthUserPrincipal(AuthUser user, String realm) {      public AuthUserPrincipal(AuthUser user, String realm) {
         this.name      = user.getName();          this.name = user.getName();
         this.password  = user.getPassword();          this.password = user.getPassword();
         this.realm     = realm;          this.realm = realm;
         this.ipmatcher = new IPMatcher();          this.ipmatcher = new IPMatcher();
         this.values    = new Hashtable();          this.values = new Hashtable();
   
         short ips[][]  = user.getIPTemplates();          short ips[][] = user.getIPTemplates();
         if ( ips != null ) {          if (ips != null) {
             for (int i = 0 ; i < ips.length ; i++)               for (short[] ip : ips) {
                 ipmatcher.add(ips[i], Boolean.TRUE);                  ipmatcher.add(ip, Boolean.TRUE);
         }              }
           }
     }      }
   
      
 }  }
   
   

Removed from v.1.2  
changed lines
  Added in v.1.3


Webmaster