1 31 32 package org.apache.commons.httpclient; 33 34 44 public class UsernamePasswordCredentials implements Credentials { 45 46 48 51 public UsernamePasswordCredentials() { 52 } 53 54 55 61 public UsernamePasswordCredentials(String usernamePassword) { 62 int atColon = usernamePassword.indexOf(':'); 63 if (atColon >= 0) { 64 this.userName = usernamePassword.substring(0, atColon); 65 this.password = usernamePassword.substring(atColon + 1); 66 } else { 67 this.userName = usernamePassword; 68 } 69 } 70 71 72 78 public UsernamePasswordCredentials(String userName, String password) { 79 this.userName = userName; 80 this.password = password; 81 } 82 83 85 88 private String userName; 89 90 91 94 private String password; 95 96 97 99 100 106 public void setUserName(String userName) { 107 this.userName = userName; 108 } 109 110 111 117 public String getUserName() { 118 return userName; 119 } 120 121 122 128 public void setPassword(String password) { 129 this.password = password; 130 } 131 132 133 139 public String getPassword() { 140 return password; 141 } 142 143 144 149 public String toString() { 150 StringBuffer result = new StringBuffer (); 151 result.append((this.userName == null) ? "null" : this.userName); 152 result.append(":"); 153 result.append((this.password == null) ? "null" : this.password); 154 return result.toString(); 155 } 156 157 } 158 159 | Popular Tags |