PasswordCallback
Stay organized with collections
Save and categorize content based on your preferences.
Underlying security services instantiate and pass a
PasswordCallback
to the handle
method of a CallbackHandler
to retrieve password information.
Public Constructor Summary
|
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.
|
Public Method Summary
void
|
|
char[]
|
|
String
|
|
boolean
|
isEchoOn()
Return whether the password
should be displayed as it is being typed.
|
void
|
setPassword(char[] password)
Set the retrieved password.
|
Inherited Method Summary
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals( Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(long timeout, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long timeout)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
Public Constructors
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 |
the prompt used to request the password. |
echoOn |
true if the password should be displayed
as it is being typed. |
Public Methods
public
void
clearPassword
()
Clear the retrieved password.
public
char[]
getPassword
()
Get the retrieved password.
This method returns a copy of the retrieved password.
Returns
- the retrieved password, which may be null.
public
boolean
isEchoOn
()
Return whether the password
should be displayed as it is being typed.
Returns
- the whether the password
should be displayed as it is being typed.
public
void
setPassword
(char[] password)
Set the retrieved password.
This method makes a copy of the input password
before storing it.
Parameters
password |
the retrieved password, which may be null. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003ePasswordCallback\u003c/code\u003e is used by security services to retrieve password information from a \u003ccode\u003eCallbackHandler\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to set and get the password, prompt, and echo status.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetPassword()\u003c/code\u003e method returns a copy of the password for security reasons.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eclearPassword()\u003c/code\u003e method can be used to erase the stored password after use.\u003c/p\u003e\n"],["\u003cp\u003eThe constructor requires a prompt and a boolean indicating whether the password should be echoed.\u003c/p\u003e\n"]]],[],null,["public class **PasswordCallback** extends [Object](../../../../../reference/java/lang/Object.html) \nimplements [Callback](../../../../../reference/javax/security/auth/callback/Callback.html) [Serializable](../../../../../reference/java/io/Serializable.html) \n\u003cbr /\u003e\n\nUnderlying security services instantiate and pass a\n`PasswordCallback` to the `handle`\nmethod of a `CallbackHandler` to retrieve password information. \n\nSee Also\n\n- [CallbackHandler](../../../../../reference/javax/security/auth/callback/CallbackHandler.html) \n\nPublic Constructor Summary\n\n|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [PasswordCallback](../../../../../reference/javax/security/auth/callback/PasswordCallback.html#PasswordCallback(java.lang.String,%20boolean))([String](../../../../../reference/java/lang/String.html) prompt, boolean echoOn) Construct a `PasswordCallback` with a prompt and a boolean specifying whether the password should be displayed as it is being typed. |\n\nPublic Method Summary\n\n|----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void | [clearPassword](../../../../../reference/javax/security/auth/callback/PasswordCallback.html#clearPassword())() Clear the retrieved password. |\n| char\\[\\] | [getPassword](../../../../../reference/javax/security/auth/callback/PasswordCallback.html#getPassword())() Get the retrieved password. |\n| [String](../../../../../reference/java/lang/String.html) | [getPrompt](../../../../../reference/javax/security/auth/callback/PasswordCallback.html#getPrompt())() Get the prompt. |\n| boolean | [isEchoOn](../../../../../reference/javax/security/auth/callback/PasswordCallback.html#isEchoOn())() Return whether the password should be displayed as it is being typed. |\n| void | [setPassword](../../../../../reference/javax/security/auth/callback/PasswordCallback.html#setPassword(char[]))(char\\[\\] password) Set the retrieved password. |\n\nInherited Method Summary \nFrom class [java.lang.Object](../../../../../reference/java/lang/Object.html) \n\n|-------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Object](../../../../../reference/java/lang/Object.html) | [clone](../../../../../reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |\n| boolean | [equals](../../../../../reference/java/lang/Object.html#equals(java.lang.Object))([Object](../../../../../reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |\n| void | [finalize](../../../../../reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |\n| final [Class](../../../../../reference/java/lang/Class.html)\\\u003c?\\\u003e | [getClass](../../../../../reference/java/lang/Object.html#getClass())() Returns the unique instance of [Class](../../../../../reference/java/lang/Class.html) that represents this object's class. |\n| int | [hashCode](../../../../../reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |\n| final void | [notify](../../../../../reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| final void | [notifyAll](../../../../../reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| [String](../../../../../reference/java/lang/String.html) | [toString](../../../../../reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |\n| final void | [wait](../../../../../reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../../reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../../reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |\n\nPublic Constructors \n\npublic\n**PasswordCallback**\n([String](../../../../../reference/java/lang/String.html) prompt, boolean echoOn) \nConstruct a `PasswordCallback` with a prompt\nand a boolean specifying whether the password should be displayed\nas it is being typed.\n\n\u003cbr /\u003e\n\nParameters\n\n| prompt | the prompt used to request the password. \u003cbr /\u003e |\n| echoOn | true if the password should be displayed as it is being typed. |\n|--------|----------------------------------------------------------------|\n\nThrows\n\n| [IllegalArgumentException](../../../../../reference/java/lang/IllegalArgumentException.html) | if `prompt` is null or if `prompt` has a length of 0. |\n|----------------------------------------------------------------------------------------------|-------------------------------------------------------|\n\nPublic Methods \n\npublic void\n**clearPassword**\n() \nClear the retrieved password. \n\npublic char\\[\\]\n**getPassword**\n() \nGet the retrieved password.\n\nThis method returns a copy of the retrieved password.\n\n\u003cbr /\u003e\n\nReturns\n\n- the retrieved password, which may be null. \n\nSee Also\n\n- [setPassword(char[])](../../../../../reference/javax/security/auth/callback/PasswordCallback.html#setPassword(char[])) \n\npublic [String](../../../../../reference/java/lang/String.html)\n**getPrompt**\n() \nGet the prompt.\n\n\u003cbr /\u003e\n\nReturns\n\n- the prompt. \n\npublic boolean\n**isEchoOn**\n() \nReturn whether the password\nshould be displayed as it is being typed.\n\n\u003cbr /\u003e\n\nReturns\n\n- the whether the password should be displayed as it is being typed. \n\npublic void\n**setPassword**\n(char\\[\\] password) \nSet the retrieved password.\n\nThis method makes a copy of the input *password*\nbefore storing it.\n\n\u003cbr /\u003e\n\nParameters\n\n| password | the retrieved password, which may be null. |\n|----------|--------------------------------------------|\n\nSee Also\n\n- [getPassword()](../../../../../reference/javax/security/auth/callback/PasswordCallback.html#getPassword())"]]