home *** CD-ROM | disk | FTP | other *** search
- package sun.net.www.protocol.http;
-
- import java.net.URL;
- import java.util.Hashtable;
-
- public class AuthenticationInfo {
- static Hashtable preemptiveCache = new Hashtable();
- static Hashtable cache = new Hashtable();
- String host;
- int port;
- String realm;
- String auth;
-
- public AuthenticationInfo(URL var1, String var2, String var3) {
- this.host = var1.getHost();
- this.port = var1.getPort();
- this.auth = var3;
- this.realm = var2;
- cacheInfo(this, var1);
- }
-
- public AuthenticationInfo(URL var1, String var2) {
- this.realm = "";
- this.host = var1.getHost();
- this.port = var1.getPort();
- this.auth = var2;
- cacheInfo(this, var1);
- }
-
- public AuthenticationInfo(String var1, int var2, String var3) {
- this.host = var1;
- this.port = var2;
- this.realm = var3;
- }
-
- public AuthenticationInfo(String var1, int var2, String var3, String var4) {
- this(var1, var2, var3);
- this.auth = var4;
- cacheInfo(this);
- }
-
- public static void cacheInfo(AuthenticationInfo var0) {
- cache.put(var0, var0);
- }
-
- public static void cacheInfo(AuthenticationInfo var0, URL var1) {
- cacheInfo(var0);
- preemptiveCache.put(cacheKey(var1), var0);
- }
-
- public static void uncacheInfo(AuthenticationInfo var0) {
- cache.remove(var0);
- }
-
- public static void uncacheInfo(AuthenticationInfo var0, URL var1) {
- uncacheInfo(var0);
- preemptiveCache.remove(cacheKey(var1));
- }
-
- private void dumpCaches(String var1) {
- System.err.println("\n" + var1);
- System.err.println("\nCache:\n" + cache + "\n\nPreemptiveCache:\n" + preemptiveCache + "\n");
- }
-
- public static AuthenticationInfo getAuth(URL var0) {
- AuthenticationInfo var1 = (AuthenticationInfo)preemptiveCache.get(cacheKey(var0));
- return var1;
- }
-
- public static AuthenticationInfo getAuth(URL var0, String var1) {
- AuthenticationInfo var2 = null;
- if (var1 == null) {
- var2 = getAuth(var0);
- } else {
- AuthenticationInfo var3 = new AuthenticationInfo(var0.getHost(), var0.getPort(), var1);
- var2 = (AuthenticationInfo)cache.get(var3);
- }
-
- return var2;
- }
-
- public String getAuthString() {
- return "Basic " + this.auth;
- }
-
- static String cacheKey(URL var0) {
- return var0.getHost() + ":" + var0.getPort();
- }
-
- public int hashCode() {
- return this.host.hashCode() ^ this.port ^ this.realm.hashCode();
- }
-
- public boolean equals(Object var1) {
- if (var1 instanceof AuthenticationInfo) {
- AuthenticationInfo var2 = (AuthenticationInfo)var1;
- return var2.host.equals(this.host) && var2.port == this.port && var2.realm.equals(this.realm);
- } else {
- return false;
- }
- }
-
- public String toString() {
- return "AuthenticationInfo[" + this.realm + "@" + this.host + ":" + this.port + "]->" + this.auth;
- }
- }
-