FileDocCategorySizeDatePackage
PasswordCallback.javaAPI DocJava SE 5 API2984Fri Aug 26 14:57:48 BST 2005javax.security.auth.callback

PasswordCallback

public class PasswordCallback extends Object implements Callback, Serializable

Underlying security services instantiate and pass a PasswordCallback to the handle method of a CallbackHandler to retrieve password information.

version
1.18, 12/19/03
see
javax.security.auth.callback.CallbackHandler

Fields Summary
private static final long
serialVersionUID
private String
prompt
private boolean
echoOn
private char[]
inputPassword
Constructors Summary
public PasswordCallback(String prompt, boolean echoOn)
Construct a PasswordCallback with a prompt and a boolean specifying whether the password should be displayed as it is being typed.

param
prompt the prompt used to request the password.

param
echoOn true if the password should be displayed as it is being typed.
exception
IllegalArgumentException if prompt is null or if prompt has a length of 0.


                                             			           			           
         
	if (prompt == null || prompt.length() == 0)
	    throw new IllegalArgumentException();

	this.prompt = prompt;
	this.echoOn = echoOn;
    
Methods Summary
public voidclearPassword()
Clear the retrieved password.

	if (inputPassword != null) {
	    for (int i = 0; i < inputPassword.length; i++)
		inputPassword[i] = ' ";
	}
    
public char[]getPassword()
Get the retrieved password.

This method returns a copy of the retrieved password.

return
the retrieved password, which may be null.
see
#setPassword

	return (inputPassword == null?
			null : (char[])inputPassword.clone());
    
public java.lang.StringgetPrompt()
Get the prompt.

return
the prompt.

	return prompt;
    
public booleanisEchoOn()
Return whether the password should be displayed as it is being typed.

return
the whether the password should be displayed as it is being typed.

	return echoOn;
    
public voidsetPassword(char[] password)
Set the retrieved password.

This method makes a copy of the input password before storing it.

param
password the retrieved password, which may be null.
see
#getPassword

	this.inputPassword = (password == null ?
			null : (char[])password.clone());