/* * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javax.security.auth.callback; /** *
Underlying security services instantiate and pass a
* TextInputCallback
to the handle
* method of a CallbackHandler
to retrieve generic text
* information.
*
* @see javax.security.auth.callback.CallbackHandler
*/
public class TextInputCallback implements Callback, java.io.Serializable {
private static final long serialVersionUID = -8064222478852811804L;
/**
* @serial
* @since 1.4
*/
private String prompt;
/**
* @serial
* @since 1.4
*/
private String defaultText;
/**
* @serial
* @since 1.4
*/
private String inputText;
/**
* Construct a TextInputCallback
with a prompt.
*
*
*
* @param prompt the prompt used to request the information.
*
* @exception IllegalArgumentException if prompt
is null
* or if prompt
has a length of 0.
*/
public TextInputCallback(String prompt) {
if (prompt == null || prompt.length() == 0)
throw new IllegalArgumentException();
this.prompt = prompt;
}
/**
* Construct a TextInputCallback
with a prompt
* and default input value.
*
*
* * @param prompt the prompt used to request the information.
*
* @param defaultText the text to be used as the default text displayed
* with the prompt.
*
* @exception IllegalArgumentException if prompt
is null,
* if prompt
has a length of 0,
* if defaultText
is null
* or if defaultText
has a length of 0.
*/
public TextInputCallback(String prompt, String defaultText) {
if (prompt == null || prompt.length() == 0 ||
defaultText == null || defaultText.length() == 0)
throw new IllegalArgumentException();
this.prompt = prompt;
this.defaultText = defaultText;
}
/**
* Get the prompt.
*
*
* * @return the prompt. */ public String getPrompt() { return prompt; } /** * Get the default text. * *
*
* @return the default text, or null if this TextInputCallback
* was not instantiated with defaultText
.
*/
public String getDefaultText() {
return defaultText;
}
/**
* Set the retrieved text.
*
*
* * @param text the retrieved text, which may be null. * * @see #getText */ public void setText(String text) { this.inputText = text; } /** * Get the retrieved text. * *
* * @return the retrieved text, which may be null. * * @see #setText */ public String getText() { return inputText; } }