1 31 32 package org.apache.commons.httpclient.auth; 33 34 39 public class HttpAuthRealm { 40 41 42 private String realm = null; 43 44 45 private String domain = null; 46 47 58 public HttpAuthRealm(final String domain, final String realm) { 59 this.domain = domain; 60 this.realm = realm; 61 } 62 63 70 private static boolean domainAttribMatch(final String d1, final String d2) { 71 return d1 == null || d2 == null || d1.equalsIgnoreCase(d2); 72 } 73 74 81 private static boolean realmAttribMatch(final String r1, final String r2) { 82 return r1 == null || r2 == null || r1.equals(r2); 83 } 84 85 86 89 public boolean equals(Object o) { 90 if (o == null) { 91 return false; 92 } 93 if (o == this) { 94 return true; 95 } 96 if (!(o instanceof HttpAuthRealm)) { 97 return super.equals(o); 98 } 99 HttpAuthRealm that = (HttpAuthRealm) o; 100 return 101 domainAttribMatch(this.domain, that.domain) 102 && realmAttribMatch(this.realm, that.realm); 103 } 104 105 108 public String toString() { 109 StringBuffer buffer = new StringBuffer (); 110 buffer.append("Authentication domain: '"); 111 buffer.append(this.domain); 112 buffer.append("', authentication realm: '"); 113 buffer.append(this.realm); 114 buffer.append("'"); 115 return buffer.toString(); 116 } 117 120 public int hashCode() { 121 StringBuffer buffer = new StringBuffer (); 122 buffer.append(this.domain); 123 buffer.append(this.realm); 124 return buffer.toString().hashCode(); 125 } 126 127 } 128 | Popular Tags |