1 7 8 package javax.security.auth.callback; 9 10 18 public class PasswordCallback implements Callback , java.io.Serializable { 19 20 private static final long serialVersionUID = 2267422647454909926L; 21 22 26 private String prompt; 27 31 private boolean echoOn; 32 36 private char[] inputPassword; 37 38 53 public PasswordCallback(String prompt, boolean echoOn) { 54 if (prompt == null || prompt.length() == 0) 55 throw new IllegalArgumentException (); 56 57 this.prompt = prompt; 58 this.echoOn = echoOn; 59 } 60 61 68 public String getPrompt() { 69 return prompt; 70 } 71 72 81 public boolean isEchoOn() { 82 return echoOn; 83 } 84 85 97 public void setPassword(char[] password) { 98 this.inputPassword = (password == null ? 99 null : (char[])password.clone()); 100 } 101 102 113 public char[] getPassword() { 114 return (inputPassword == null? 115 null : (char[])inputPassword.clone()); 116 } 117 118 121 public void clearPassword() { 122 if (inputPassword != null) { 123 for (int i = 0; i < inputPassword.length; i++) 124 inputPassword[i] = ' '; 125 } 126 } 127 } 128 | Popular Tags |