0N/A/*
2362N/A * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.security.auth.callback;
0N/A
0N/A/**
0N/A * <p> Underlying security services instantiate and pass a
0N/A * <code>TextInputCallback</code> to the <code>handle</code>
0N/A * method of a <code>CallbackHandler</code> to retrieve generic text
0N/A * information.
0N/A *
0N/A * @see javax.security.auth.callback.CallbackHandler
0N/A */
0N/Apublic class TextInputCallback implements Callback, java.io.Serializable {
0N/A
0N/A private static final long serialVersionUID = -8064222478852811804L;
0N/A
0N/A /**
0N/A * @serial
0N/A * @since 1.4
0N/A */
0N/A private String prompt;
0N/A /**
0N/A * @serial
0N/A * @since 1.4
0N/A */
0N/A private String defaultText;
0N/A /**
0N/A * @serial
0N/A * @since 1.4
0N/A */
0N/A private String inputText;
0N/A
0N/A /**
0N/A * Construct a <code>TextInputCallback</code> with a prompt.
0N/A *
0N/A * <p>
0N/A *
0N/A * @param prompt the prompt used to request the information.
0N/A *
0N/A * @exception IllegalArgumentException if <code>prompt</code> is null
0N/A * or if <code>prompt</code> has a length of 0.
0N/A */
0N/A public TextInputCallback(String prompt) {
0N/A if (prompt == null || prompt.length() == 0)
0N/A throw new IllegalArgumentException();
0N/A this.prompt = prompt;
0N/A }
0N/A
0N/A /**
0N/A * Construct a <code>TextInputCallback</code> with a prompt
0N/A * and default input value.
0N/A *
0N/A * <p>
0N/A *
0N/A * @param prompt the prompt used to request the information. <p>
0N/A *
0N/A * @param defaultText the text to be used as the default text displayed
0N/A * with the prompt.
0N/A *
0N/A * @exception IllegalArgumentException if <code>prompt</code> is null,
0N/A * if <code>prompt</code> has a length of 0,
0N/A * if <code>defaultText</code> is null
0N/A * or if <code>defaultText</code> has a length of 0.
0N/A */
0N/A public TextInputCallback(String prompt, String defaultText) {
0N/A if (prompt == null || prompt.length() == 0 ||
0N/A defaultText == null || defaultText.length() == 0)
0N/A throw new IllegalArgumentException();
0N/A
0N/A this.prompt = prompt;
0N/A this.defaultText = defaultText;
0N/A }
0N/A
0N/A /**
0N/A * Get the prompt.
0N/A *
0N/A * <p>
0N/A *
0N/A * @return the prompt.
0N/A */
0N/A public String getPrompt() {
0N/A return prompt;
0N/A }
0N/A
0N/A /**
0N/A * Get the default text.
0N/A *
0N/A * <p>
0N/A *
0N/A * @return the default text, or null if this <code>TextInputCallback</code>
0N/A * was not instantiated with <code>defaultText</code>.
0N/A */
0N/A public String getDefaultText() {
0N/A return defaultText;
0N/A }
0N/A
0N/A /**
0N/A * Set the retrieved text.
0N/A *
0N/A * <p>
0N/A *
0N/A * @param text the retrieved text, which may be null.
0N/A *
0N/A * @see #getText
0N/A */
0N/A public void setText(String text) {
0N/A this.inputText = text;
0N/A }
0N/A
0N/A /**
0N/A * Get the retrieved text.
0N/A *
0N/A * <p>
0N/A *
0N/A * @return the retrieved text, which may be null.
0N/A *
0N/A * @see #setText
0N/A */
0N/A public String getText() {
0N/A return inputText;
0N/A }
0N/A}