1 /* |
1 /* |
2 * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
25 |
25 |
26 package javax.security.auth.callback; |
26 package javax.security.auth.callback; |
27 |
27 |
28 /** |
28 /** |
29 * <p> Underlying security services instantiate and pass a |
29 * <p> Underlying security services instantiate and pass a |
30 * <code>TextInputCallback</code> to the <code>handle</code> |
30 * {@code TextInputCallback} to the {@code handle} |
31 * method of a <code>CallbackHandler</code> to retrieve generic text |
31 * method of a {@code CallbackHandler} to retrieve generic text |
32 * information. |
32 * information. |
33 * |
33 * |
34 * @see javax.security.auth.callback.CallbackHandler |
34 * @see javax.security.auth.callback.CallbackHandler |
35 */ |
35 */ |
36 public class TextInputCallback implements Callback, java.io.Serializable { |
36 public class TextInputCallback implements Callback, java.io.Serializable { |
52 * @since 1.4 |
52 * @since 1.4 |
53 */ |
53 */ |
54 private String inputText; |
54 private String inputText; |
55 |
55 |
56 /** |
56 /** |
57 * Construct a <code>TextInputCallback</code> with a prompt. |
57 * Construct a {@code TextInputCallback} with a prompt. |
58 * |
58 * |
59 * <p> |
59 * <p> |
60 * |
60 * |
61 * @param prompt the prompt used to request the information. |
61 * @param prompt the prompt used to request the information. |
62 * |
62 * |
63 * @exception IllegalArgumentException if <code>prompt</code> is null |
63 * @exception IllegalArgumentException if {@code prompt} is null |
64 * or if <code>prompt</code> has a length of 0. |
64 * or if {@code prompt} has a length of 0. |
65 */ |
65 */ |
66 public TextInputCallback(String prompt) { |
66 public TextInputCallback(String prompt) { |
67 if (prompt == null || prompt.length() == 0) |
67 if (prompt == null || prompt.length() == 0) |
68 throw new IllegalArgumentException(); |
68 throw new IllegalArgumentException(); |
69 this.prompt = prompt; |
69 this.prompt = prompt; |
70 } |
70 } |
71 |
71 |
72 /** |
72 /** |
73 * Construct a <code>TextInputCallback</code> with a prompt |
73 * Construct a {@code TextInputCallback} with a prompt |
74 * and default input value. |
74 * and default input value. |
75 * |
75 * |
76 * <p> |
76 * <p> |
77 * |
77 * |
78 * @param prompt the prompt used to request the information. <p> |
78 * @param prompt the prompt used to request the information. <p> |
79 * |
79 * |
80 * @param defaultText the text to be used as the default text displayed |
80 * @param defaultText the text to be used as the default text displayed |
81 * with the prompt. |
81 * with the prompt. |
82 * |
82 * |
83 * @exception IllegalArgumentException if <code>prompt</code> is null, |
83 * @exception IllegalArgumentException if {@code prompt} is null, |
84 * if <code>prompt</code> has a length of 0, |
84 * if {@code prompt} has a length of 0, |
85 * if <code>defaultText</code> is null |
85 * if {@code defaultText} is null |
86 * or if <code>defaultText</code> has a length of 0. |
86 * or if {@code defaultText} has a length of 0. |
87 */ |
87 */ |
88 public TextInputCallback(String prompt, String defaultText) { |
88 public TextInputCallback(String prompt, String defaultText) { |
89 if (prompt == null || prompt.length() == 0 || |
89 if (prompt == null || prompt.length() == 0 || |
90 defaultText == null || defaultText.length() == 0) |
90 defaultText == null || defaultText.length() == 0) |
91 throw new IllegalArgumentException(); |
91 throw new IllegalArgumentException(); |