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

public Class ConfirmationCallback

extends Object
implements Callback, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.security.auth.callback.Callback
Imports
java.io.IOException, .ObjectInputStream

Underlying security services instantiate and pass a ConfirmationCallback to the handle method of a CallbackHandler to ask for YES/NO, OK/CANCEL, YES/NO/CANCEL or other similar confirmations.

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

Field Summary

Modifier and TypeField and Description
public static final int
CANCEL

CANCEL option.

private final int
public static final int
ERROR

ERROR message type.

public static final int
INFORMATION

INFORMATION message type.

private final int
public static final int
NO

NO option.

public static final int
OK

OK option.

public static final int
OK_CANCEL_OPTION

OK/CANCEL confirmation option.

private String[]
private final int
private final String
private int
private static final long
public static final int
UNSPECIFIED_OPTION

Unspecified option type.

public static final int
WARNING

WARNING message type.

public static final int
YES

YES option.

public static final int
YES_NO_CANCEL_OPTION

YES/NO/CANCEL confirmation option.

public static final int
YES_NO_OPTION

YES/NO confirmation option.

Constructor Summary

AccessConstructor and Description
public
ConfirmationCallback(int
the message type (INFORMATION, WARNING or ERROR).
messageType
,
int
the option type (YES_NO_OPTION, YES_NO_CANCEL_OPTION or OK_CANCEL_OPTION).
optionType
,
int
the default option from the provided optionType (YES, NO, CANCEL or OK).
defaultOption
)

Construct a ConfirmationCallback with a message type, an option type and a default option.

public
ConfirmationCallback(int
the message type (INFORMATION, WARNING or ERROR).
messageType
,
String[]
the list of confirmation options. The array is cloned to protect against subsequent modification.
options
,
int
the default option, represented as an index into the options array.
defaultOption
)

Construct a ConfirmationCallback with a message type, a list of options and a default option.

public
ConfirmationCallback(String
the prompt used to describe the list of options.
prompt
,
int
the message type (INFORMATION, WARNING or ERROR).
messageType
,
int
the option type (YES_NO_OPTION, YES_NO_CANCEL_OPTION or OK_CANCEL_OPTION).
optionType
,
int
the default option from the provided optionType (YES, NO, CANCEL or OK).
defaultOption
)

Construct a ConfirmationCallback with a prompt, message type, an option type and a default option.

public
ConfirmationCallback(String
the prompt used to describe the list of options.
prompt
,
int
the message type (INFORMATION, WARNING or ERROR).
messageType
,
String[]
the list of confirmation options. The array is cloned to protect against subsequent modification.
options
,
int
the default option, represented as an index into the options array.
defaultOption
)

Construct a ConfirmationCallback with a prompt, message type, a list of options and a default option.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the default option, represented as YES, NO, OK or CANCEL if an optionType was specified to the constructor of this ConfirmationCallback. Otherwise, this method returns the default option as an index into the options array specified to the constructor of this ConfirmationCallback.
getDefaultOption
()

Get the default option.

public int

Returns:

the message type (INFORMATION, WARNING or ERROR).
getMessageType
()

Get the message type.

public String[]

Returns:

a copy of the list of confirmation options, or null if this ConfirmationCallback was instantiated with an optionType instead of options.
getOptions
()

Get the confirmation options.

public int

Returns:

the option type (YES_NO_OPTION, YES_NO_CANCEL_OPTION or OK_CANCEL_OPTION), or UNSPECIFIED_OPTION if this ConfirmationCallback was instantiated with options instead of an optionType.
getOptionType
()

Get the option type.

public String

Returns:

the prompt, or null if this ConfirmationCallback was instantiated without a prompt.
getPrompt
()

Get the prompt.

public int

Returns:

the selected confirmation option represented as YES, NO, OK or CANCEL if an optionType was specified to the constructor of this ConfirmationCallback. Otherwise, this method returns the selected confirmation option as an index into the options array specified to the constructor of this ConfirmationCallback.
getSelectedIndex
()

Get the selected confirmation option.

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

Restores the state of this object from the stream.

public void
setSelectedIndex(int
the selection represented as YES, NO, OK or CANCEL if an optionType was specified to the constructor of this ConfirmationCallback. Otherwise, the selection represents the index into the options array specified to the constructor of this ConfirmationCallback.
selection
)

Set the selected confirmation option.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CANCELback to summary
public static final int CANCEL

CANCEL option.

If an optionType was specified to this ConfirmationCallback, this option may be specified as a defaultOption or returned as the selected index.

defaultOptionback to summary
private final int defaultOption
Since
1.4
ERRORback to summary
public static final int ERROR

ERROR message type.

INFORMATIONback to summary
public static final int INFORMATION

INFORMATION message type.

messageTypeback to summary
private final int messageType
Since
1.4
NOback to summary
public static final int NO

NO option.

If an optionType was specified to this ConfirmationCallback, this option may be specified as a defaultOption or returned as the selected index.

OKback to summary
public static final int OK

OK option.

If an optionType was specified to this ConfirmationCallback, this option may be specified as a defaultOption or returned as the selected index.

OK_CANCEL_OPTIONback to summary
public static final int OK_CANCEL_OPTION

OK/CANCEL confirmation option.

An underlying security service specifies this as the optionType to a ConfirmationCallback constructor if it requires a confirmation which can be answered with either OK or CANCEL.

optionsback to summary
private String[] options
Since
1.4
optionTypeback to summary
private final int optionType
Since
1.4
promptback to summary
private final String prompt
Since
1.4
selectionback to summary
private int selection
Since
1.4
serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial
UNSPECIFIED_OPTIONback to summary
public static final int UNSPECIFIED_OPTION

Unspecified option type.

The getOptionType method returns this value if this ConfirmationCallback was instantiated with options instead of an optionType.

WARNINGback to summary
public static final int WARNING

WARNING message type.

YESback to summary
public static final int YES

YES option.

If an optionType was specified to this ConfirmationCallback, this option may be specified as a defaultOption or returned as the selected index.

YES_NO_CANCEL_OPTIONback to summary
public static final int YES_NO_CANCEL_OPTION

YES/NO/CANCEL confirmation option.

An underlying security service specifies this as the optionType to a ConfirmationCallback constructor if it requires a confirmation which can be answered with either YES, NO or CANCEL.

YES_NO_OPTIONback to summary
public static final int YES_NO_OPTION

YES/NO confirmation option.

An underlying security service specifies this as the optionType to a ConfirmationCallback constructor if it requires a confirmation which can be answered with either YES or NO.

Constructor Detail

ConfirmationCallbackback to summary
public ConfirmationCallback(int messageType, int optionType, int defaultOption)

Construct a ConfirmationCallback with a message type, an option type and a default option.

Underlying security services use this constructor if they require either a YES/NO, YES/NO/CANCEL or OK/CANCEL confirmation.

Parameters
messageType:int

the message type (INFORMATION, WARNING or ERROR).

optionType:int

the option type (YES_NO_OPTION, YES_NO_CANCEL_OPTION or OK_CANCEL_OPTION).

defaultOption:int

the default option from the provided optionType (YES, NO, CANCEL or OK).

Exceptions
IllegalArgumentException:
if messageType is not either INFORMATION, WARNING, or ERROR, if optionType is not either YES_NO_OPTION, YES_NO_CANCEL_OPTION, or OK_CANCEL_OPTION, or if defaultOption does not correspond to one of the options in optionType.
ConfirmationCallbackback to summary
public ConfirmationCallback(int messageType, String[] options, int defaultOption)

Construct a ConfirmationCallback with a message type, a list of options and a default option.

Underlying security services use this constructor if they require a confirmation different from the available preset confirmations provided (for example, CONTINUE/ABORT or STOP/GO). The confirmation options are listed in the options array, and are displayed by the CallbackHandler implementation in a manner consistent with the way preset options are displayed.

Parameters
messageType:int

the message type (INFORMATION, WARNING or ERROR).

options:String[]

the list of confirmation options. The array is cloned to protect against subsequent modification.

defaultOption:int

the default option, represented as an index into the options array.

Exceptions
IllegalArgumentException:
if messageType is not either INFORMATION, WARNING, or ERROR, if options is null, if options has a length of 0, if any element from options is null, if any element from options has a length of 0, or if defaultOption does not lie within the array boundaries of options.
ConfirmationCallbackback to summary
public ConfirmationCallback(String prompt, int messageType, int optionType, int defaultOption)

Construct a ConfirmationCallback with a prompt, message type, an option type and a default option.

Underlying security services use this constructor if they require either a YES/NO, YES/NO/CANCEL or OK/CANCEL confirmation.

Parameters
prompt:String

the prompt used to describe the list of options.

messageType:int

the message type (INFORMATION, WARNING or ERROR).

optionType:int

the option type (YES_NO_OPTION, YES_NO_CANCEL_OPTION or OK_CANCEL_OPTION).

defaultOption:int

the default option from the provided optionType (YES, NO, CANCEL or OK).

Exceptions
IllegalArgumentException:
if prompt is null, if prompt has a length of 0, if messageType is not either INFORMATION, WARNING, or ERROR, if optionType is not either YES_NO_OPTION, YES_NO_CANCEL_OPTION, or OK_CANCEL_OPTION, or if defaultOption does not correspond to one of the options in optionType.
ConfirmationCallbackback to summary
public ConfirmationCallback(String prompt, int messageType, String[] options, int defaultOption)

Construct a ConfirmationCallback with a prompt, message type, a list of options and a default option.

Underlying security services use this constructor if they require a confirmation different from the available preset confirmations provided (for example, CONTINUE/ABORT or STOP/GO). The confirmation options are listed in the options array, and are displayed by the CallbackHandler implementation in a manner consistent with the way preset options are displayed.

Parameters
prompt:String

the prompt used to describe the list of options.

messageType:int

the message type (INFORMATION, WARNING or ERROR).

options:String[]

the list of confirmation options. The array is cloned to protect against subsequent modification.

defaultOption:int

the default option, represented as an index into the options array.

Exceptions
IllegalArgumentException:
if prompt is null, if prompt has a length of 0, if messageType is not either INFORMATION, WARNING, or ERROR, if options is null, if options has a length of 0, if any element from options is null, if any element from options has a length of 0, or if defaultOption does not lie within the array boundaries of options.

Method Detail

getDefaultOptionback to summary
public int getDefaultOption()

Get the default option.

Returns:int

the default option, represented as YES, NO, OK or CANCEL if an optionType was specified to the constructor of this ConfirmationCallback. Otherwise, this method returns the default option as an index into the options array specified to the constructor of this ConfirmationCallback.

getMessageTypeback to summary
public int getMessageType()

Get the message type.

Returns:int

the message type (INFORMATION, WARNING or ERROR).

getOptionsback to summary
public String[] getOptions()

Get the confirmation options.

Returns:String[]

a copy of the list of confirmation options, or null if this ConfirmationCallback was instantiated with an optionType instead of options.

getOptionTypeback to summary
public int getOptionType()

Get the option type.

If this method returns UNSPECIFIED_OPTION, then this ConfirmationCallback was instantiated with options instead of an optionType. In this case, invoke the getOptions method to determine which confirmation options to display.

Returns:int

the option type (YES_NO_OPTION, YES_NO_CANCEL_OPTION or OK_CANCEL_OPTION), or UNSPECIFIED_OPTION if this ConfirmationCallback was instantiated with options instead of an optionType.

getPromptback to summary
public String getPrompt()

Get the prompt.

Returns:String

the prompt, or null if this ConfirmationCallback was instantiated without a prompt.

getSelectedIndexback to summary
public int getSelectedIndex()

Get the selected confirmation option.

Returns:int

the selected confirmation option represented as YES, NO, OK or CANCEL if an optionType was specified to the constructor of this ConfirmationCallback. Otherwise, this method returns the selected confirmation option as an index into the options array specified to the constructor of this ConfirmationCallback.

See Also
setSelectedIndex
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
setSelectedIndexback to summary
public void setSelectedIndex(int selection)

Set the selected confirmation option.

Parameters
selection:int

the selection represented as YES, NO, OK or CANCEL if an optionType was specified to the constructor of this ConfirmationCallback. Otherwise, the selection represents the index into the options array specified to the constructor of this ConfirmationCallback.

See Also
getSelectedIndex