History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/javax/security/auth/callback/TextOutputCallback.java (1 of 18352 files). Show all

Unified · Split

java/pkg/javax/security/auth/callback/TextOutputCallback.java+107−0
@@ -0,0 +1,107 @@
1+/*
2+ * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
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
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package javax.security.auth.callback;
27+
28+/**
29+ * <p> Underlying security services instantiate and pass a
30+ * <code>TextOutputCallback</code> to the <code>handle</code>
31+ * method of a <code>CallbackHandler</code> to display information messages,
32+ * warning messages and error messages.
33+ *
34+ * @see javax.security.auth.callback.CallbackHandler
35+ */
36+public class TextOutputCallback implements Callback, java.io.Serializable {
37+
38+ private static final long serialVersionUID = 1689502495511663102L;
39+
40+ /** Information message. */
41+ public static final int INFORMATION = 0;
42+ /** Warning message. */
43+ public static final int WARNING = 1;
44+ /** Error message. */
45+ public static final int ERROR = 2;
46+
47+ /**
48+ * @serial
49+ * @since 1.4
50+ */
51+ private int messageType;
52+ /**
53+ * @serial
54+ * @since 1.4
55+ */
56+ private String message;
57+
58+ /**
59+ * Construct a TextOutputCallback with a message type and message
60+ * to be displayed.
61+ *
62+ * <p>
63+ *
64+ * @param messageType the message type (<code>INFORMATION</code>,
65+ * <code>WARNING</code> or <code>ERROR</code>). <p>
66+ *
67+ * @param message the message to be displayed. <p>
68+ *
69+ * @exception IllegalArgumentException if <code>messageType</code>
70+ * is not either <code>INFORMATION</code>,
71+ * <code>WARNING</code> or <code>ERROR</code>,
72+ * if <code>message</code> is null,
73+ * or if <code>message</code> has a length of 0.
74+ */
75+ public TextOutputCallback(int messageType, String message) {
76+ if ((messageType != INFORMATION &&
77+ messageType != WARNING && messageType != ERROR) ||
78+ message == null || message.length() == 0)
79+ throw new IllegalArgumentException();
80+
81+ this.messageType = messageType;
82+ this.message = message;
83+ }
84+
85+ /**
86+ * Get the message type.
87+ *
88+ * <p>
89+ *
90+ * @return the message type (<code>INFORMATION</code>,
91+ * <code>WARNING</code> or <code>ERROR</code>).
92+ */
93+ public int getMessageType() {
94+ return messageType;
95+ }
96+
97+ /**
98+ * Get the message to be displayed.
99+ *
100+ * <p>
101+ *
102+ * @return the message to be displayed.
103+ */
104+ public String getMessage() {
105+ return message;
106+ }
107+}