home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / ie4 / IE4 / JAVI386.CAB / classr.exe / sun / net / www / http / AuthenticationInfo.class (.txt) next >
Encoding:
Java Class File  |  1997-01-31  |  2.5 KB  |  84 lines

  1. package sun.net.www.http;
  2.  
  3. import java.net.URL;
  4. import java.util.Hashtable;
  5.  
  6. public class AuthenticationInfo {
  7.    String host;
  8.    int port;
  9.    String realm;
  10.    String auth;
  11.    static Hashtable cache = new Hashtable();
  12.    static Hashtable preemptiveCache = new Hashtable();
  13.  
  14.    public static void cacheInfo(AuthenticationInfo var0) {
  15.       cache.put(var0, var0);
  16.    }
  17.  
  18.    public static void uncacheInfo(AuthenticationInfo var0) {
  19.       cache.remove(var0);
  20.    }
  21.  
  22.    public static void cacheInfo(AuthenticationInfo var0, URL var1) {
  23.       cacheInfo(var0);
  24.       preemptiveCache.put(var1, var0);
  25.    }
  26.  
  27.    public static void uncacheInfo(AuthenticationInfo var0, URL var1) {
  28.       uncacheInfo(var0);
  29.       preemptiveCache.remove(var1);
  30.    }
  31.  
  32.    public static AuthenticationInfo getAuth(URL var0) {
  33.       AuthenticationInfo var1 = (AuthenticationInfo)preemptiveCache.get(var0);
  34.       return var1;
  35.    }
  36.  
  37.    public static AuthenticationInfo getAuth(URL var0, String var1) {
  38.       AuthenticationInfo var2 = (AuthenticationInfo)cache.get(new AuthenticationInfo(var0.getHost(), var0.getPort(), var1));
  39.       return var2;
  40.    }
  41.  
  42.    public AuthenticationInfo(URL var1, String var2, String var3) {
  43.       this(var1, var3);
  44.       this.realm = var2;
  45.    }
  46.  
  47.    public AuthenticationInfo(URL var1, String var2) {
  48.       this.realm = "";
  49.       this.host = var1.getHost();
  50.       this.port = var1.getPort();
  51.       this.auth = var2;
  52.       cacheInfo(this, var1);
  53.    }
  54.  
  55.    public AuthenticationInfo(String var1, int var2, String var3) {
  56.       this.host = var1;
  57.       this.port = var2;
  58.       this.realm = var3;
  59.    }
  60.  
  61.    public AuthenticationInfo(String var1, int var2, String var3, String var4) {
  62.       this(var1, var2, var3);
  63.       this.auth = var4;
  64.       cacheInfo(this);
  65.    }
  66.  
  67.    public int hashCode() {
  68.       return this.host.hashCode() ^ this.port ^ this.realm.hashCode();
  69.    }
  70.  
  71.    public boolean equals(Object var1) {
  72.       if (var1 instanceof AuthenticationInfo) {
  73.          AuthenticationInfo var2 = (AuthenticationInfo)var1;
  74.          return var2.host.equals(this.host) && var2.port == this.port && var2.realm.equals(this.realm);
  75.       } else {
  76.          return false;
  77.       }
  78.    }
  79.  
  80.    public String toString() {
  81.       return "AuthenticationInfo[" + this.realm + "@" + this.host + ":" + this.port + "] -> " + this.auth;
  82.    }
  83. }
  84.