1 package fr.jayasoft.ivy.util; 2 3 8 public class Credentials { 9 private String _realm; 10 private String _host; 11 private String _userName; 12 private String _passwd; 13 14 public Credentials(String realm, String host, String userName, String passwd) { 15 _realm = realm; 16 _host = host; 17 _userName = userName; 18 _passwd = passwd; 19 } 20 21 public String getHost() { 22 return _host; 23 } 24 public String getPasswd() { 25 return _passwd; 26 } 27 public String getRealm() { 28 return _realm; 29 } 30 public String getUserName() { 31 return _userName; 32 } 33 34 public static String buildKey(String realm, String host) { 35 if (realm == null || "".equals(realm.trim())) { 36 return host; 37 } else { 38 return realm + "@" + host; 39 } 40 } 41 42 public String toString() { 43 return getKey() + " " + getUserName() + "/" + getPasswd(); 44 } 45 46 public boolean equals(Object o) { 47 if(o == null) { 48 return false; 49 } 50 51 if(o instanceof Credentials) { 52 Credentials c = (Credentials) o; 53 return getKey().equals(c.getKey()); 54 } 55 56 return false; 57 } 58 59 public int hashCode() { 60 return getKey().hashCode(); 61 } 62 63 public String getKey() { 64 return buildKey(_realm, _host); 65 } 66 } 67 | Popular Tags |