Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/security/auth/callback/TextOutputCallback.java
38918 views
/*1* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.security.auth.callback;2627/**28* <p> Underlying security services instantiate and pass a29* {@code TextOutputCallback} to the {@code handle}30* method of a {@code CallbackHandler} to display information messages,31* warning messages and error messages.32*33* @see javax.security.auth.callback.CallbackHandler34*/35public class TextOutputCallback implements Callback, java.io.Serializable {3637private static final long serialVersionUID = 1689502495511663102L;3839/** Information message. */40public static final int INFORMATION = 0;41/** Warning message. */42public static final int WARNING = 1;43/** Error message. */44public static final int ERROR = 2;4546/**47* @serial48* @since 1.449*/50private int messageType;51/**52* @serial53* @since 1.454*/55private String message;5657/**58* Construct a TextOutputCallback with a message type and message59* to be displayed.60*61* <p>62*63* @param messageType the message type ({@code INFORMATION},64* {@code WARNING} or {@code ERROR}). <p>65*66* @param message the message to be displayed. <p>67*68* @exception IllegalArgumentException if {@code messageType}69* is not either {@code INFORMATION},70* {@code WARNING} or {@code ERROR},71* if {@code message} is null,72* or if {@code message} has a length of 0.73*/74public TextOutputCallback(int messageType, String message) {75if ((messageType != INFORMATION &&76messageType != WARNING && messageType != ERROR) ||77message == null || message.length() == 0)78throw new IllegalArgumentException();7980this.messageType = messageType;81this.message = message;82}8384/**85* Get the message type.86*87* <p>88*89* @return the message type ({@code INFORMATION},90* {@code WARNING} or {@code ERROR}).91*/92public int getMessageType() {93return messageType;94}9596/**97* Get the message to be displayed.98*99* <p>100*101* @return the message to be displayed.102*/103public String getMessage() {104return message;105}106}107108109