PasswordCallbackpublic class PasswordCallback extends Object implements Serializable, CallbackIs used in conjunction with a {@link CallbackHandler} to retrieve a password
when needed. |
Fields Summary |
---|
private static final long | serialVersionUID | private String | prompt | boolean | echoOn | private char[] | inputPassword |
Constructors Summary |
---|
public PasswordCallback(String prompt, boolean echoOn)Creates a new {@code PasswordCallback} instance.
super();
setPrompt(prompt);
this.echoOn = echoOn;
|
Methods Summary |
---|
public void | clearPassword()Clears the password stored in this {@code PasswordCallback}.
if (inputPassword != null) {
Arrays.fill(inputPassword, '\u0000");
}
| public char[] | getPassword()Returns the password. The security service that needs the password
usually calls this method once the {@link CallbackHandler} has finished
its work.
if (inputPassword != null) {
char[] tmp = new char[inputPassword.length];
System.arraycopy(inputPassword, 0, tmp, 0, tmp.length);
return tmp;
}
return null;
| public java.lang.String | getPrompt()Returns the prompt that was specified when creating this {@code
PasswordCallback}
return prompt;
| public boolean | isEchoOn()Queries whether this {@code PasswordCallback} expects user input to be
echoed, which is specified during the creation of the object.
return echoOn;
| public void | setPassword(char[] password)Sets the password. The {@link CallbackHandler} that performs the actual
provisioning or input of the password needs to call this method to hand
back the password to the security service that requested it.
if (password == null) {
this.inputPassword = password;
} else {
inputPassword = new char[password.length];
System.arraycopy(password, 0, inputPassword, 0, inputPassword.length);
}
| private void | setPrompt(java.lang.String prompt)
if (prompt == null || prompt.length() == 0) {
throw new IllegalArgumentException(Messages.getString("auth.14")); //$NON-NLS-1$
}
this.prompt = prompt;
|
|