1 23 24 package com.sun.enterprise.security.auth.login; 25 26 31 32 public class PasswordCredential { 33 private String username; 34 private String password; 35 private String realm; 36 private boolean readOnly = false; 37 40 private byte[] target_name = {}; 41 42 47 public PasswordCredential(String user, String password, String realm) 48 { 49 this.username = user; 50 this.password = password; 51 this.realm = realm; 52 53 if (this.username == null ) { this.username = ""; } 54 if (this.password == null ) { this.password = ""; } 55 if (this.realm == null ) { this.realm = ""; } 56 } 57 58 59 63 public PasswordCredential(String user, String password, 64 String realm, byte[] target_name) 65 { 66 this(user, password, realm); 67 this.target_name = target_name; 68 readOnly = true; 69 } 70 71 72 76 public String getRealm() { 77 return realm; 78 } 79 80 81 85 public String getUser() { 86 return username; 87 } 88 89 public void setRealm(String realm){ 90 if(!readOnly){ 91 this.realm = realm; 92 } 93 } 94 95 99 public String getPassword() { 100 return password; 101 } 102 103 104 108 public byte[] getTargetName() { 109 return this.target_name; 110 } 111 112 118 public boolean equals(Object o) { 119 if(o instanceof PasswordCredential) { 120 PasswordCredential pc = (PasswordCredential) o; 121 if(pc.getUser().equals(username) && 122 pc.getPassword().equals(password) && 123 pc.getRealm().equals(realm)) { 124 return true; 125 } 126 } 127 return false; 128 } 129 130 131 135 public int hashCode() { 136 return username.hashCode() + password.hashCode() + realm.hashCode(); 137 } 138 139 140 143 public String toString() { 144 String s = "Realm=" + realm; 145 s = s + " Username=" + username; 146 s = s + " Password=" + "########"; 147 s = s + " TargetName = " + target_name; 148 return s; 149 } 150 151 } 152 | Popular Tags |