Package javax.security.auth.callback
Class PasswordCallback
java.lang.Object
javax.security.auth.callback.PasswordCallback
- All Implemented Interfaces:
Serializable,Callback
public class PasswordCallback extends Object implements Callback, Serializable
Used in conjunction with a
CallbackHandler to retrieve a password
when needed.- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description PasswordCallback(String prompt, boolean echoOn)Creates a newPasswordCallbackinstance. -
Method Summary
Modifier and Type Method Description voidclearPassword()Clears the password stored in thisPasswordCallback.char[]getPassword()Returns the password.StringgetPrompt()Returns the prompt that was specified when creating thisPasswordCallbackbooleanisEchoOn()Queries whether thisPasswordCallbackexpects user input to be echoed, which is specified during the creation of the object.voidsetPassword(char[] password)Sets the password.
-
Constructor Details
-
PasswordCallback
Creates a newPasswordCallbackinstance.- Parameters:
prompt- the message that should be displayed to the userechoOn- determines whether the user input should be echoed
-
-
Method Details
-
getPrompt
Returns the prompt that was specified when creating thisPasswordCallback- Returns:
- the prompt
-
isEchoOn
public boolean isEchoOn()Queries whether thisPasswordCallbackexpects user input to be echoed, which is specified during the creation of the object.- Returns:
trueif (and only if) user input should be echoed
-
setPassword
public void setPassword(char[] password)Sets the password. TheCallbackHandlerthat 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.- Parameters:
password- the password. A copy of this is stored, so subsequent changes to the input array do not affect thePasswordCallback.
-
getPassword
public char[] getPassword()Returns the password. The security service that needs the password usually calls this method once theCallbackHandlerhas finished its work.- Returns:
- the password. A copy of the internal password is created and returned, so subsequent changes to the internal password do not affect the result.
-
clearPassword
public void clearPassword()Clears the password stored in thisPasswordCallback.
-