Top Description Fields Constructors Methods
javax.security.auth.callback

public Class PasswordCallback

extends Object
implements Callback, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.security.auth.callback.Callback
Imports
java.io.IOException, .InvalidObjectException, .ObjectInputStream, java.lang.ref.Cleaner, java.util.Arrays, jdk.internal.ref.CleanerFactory

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

Since
1.4
See Also
javax.security.auth.callback.CallbackHandler

Field Summary

Modifier and TypeField and Description
private transient Cleaner.Cleanable
private final boolean
private char[]
private final String
private static final long

Constructor Summary

AccessConstructor and Description
public
PasswordCallback(String
the prompt used to request the password.
prompt
,
boolean
true if the password should be displayed as it is being typed.
echoOn
)

Construct a PasswordCallback with a prompt and a boolean specifying whether the password should be displayed as it is being typed.

Method Summary

Modifier and TypeMethod and Description
private static Runnable
cleanerFor(char[] password)

public void
clearPassword()

Clear the retrieved password.

public char[]

Returns:

the retrieved password, which may be null.
getPassword
()

Get the retrieved password.

public String

Returns:

the prompt.
getPrompt
()

Get the prompt.

public boolean

Returns:

the whether the password should be displayed as it is being typed.
isEchoOn
()

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

private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
stream
)

Restores the state of this object from the stream.

public void
setPassword(char[]
the retrieved password, which may be null.
password
)

Set the retrieved password.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cleanableback to summary
private transient Cleaner.Cleanable cleanable
echoOnback to summary
private final boolean echoOn
Since
1.4
inputPasswordback to summary
private char[] inputPassword
Since
1.4
promptback to summary
private final String prompt
Since
1.4
serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial

Constructor Detail

PasswordCallbackback to 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.

Parameters
prompt:String

the prompt used to request the password.

echoOn:boolean

true if the password should be displayed as it is being typed.

Exceptions
IllegalArgumentException:
if prompt is null or if prompt has a length of 0.

Method Detail

cleanerForback to summary
private static Runnable cleanerFor(char[] password)
clearPasswordback to summary
public void clearPassword()

Clear the retrieved password.

getPasswordback to summary
public char[] getPassword()

Get the retrieved password.

This method returns a copy of the retrieved password.

Returns:char[]

the retrieved password, which may be null.

See Also
setPassword
getPromptback to summary
public String getPrompt()

Get the prompt.

Returns:String

the prompt.

isEchoOnback to summary
public boolean isEchoOn()

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

Returns:boolean

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

readObjectback to summary
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException

Restores the state of this object from the stream.

Parameters
stream:ObjectInputStream

the ObjectInputStream from which data is read

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded
setPasswordback to summary
public void setPassword(char[] password)

Set the retrieved password.

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

Parameters
password:char[]

the retrieved password, which may be null.

See Also
getPassword