jdk/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java
author avstepan
Mon, 16 Mar 2015 19:09:13 +0400
changeset 29492 a4bf9a570035
parent 25859 3317bb8137f4
child 45434 4582657c7260
permissions -rw-r--r--
8028266: Tidy warnings cleanup for packages java.security/javax.security Summary: some tidy warnings in docs were fixed Reviewed-by: mullan, wetmore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
     2
 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.security.auth.callback;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * <p> Underlying security services instantiate and pass a
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    30
 * {@code ConfirmationCallback} to the {@code handle}
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    31
 * method of a {@code CallbackHandler} to ask for YES/NO,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * OK/CANCEL, YES/NO/CANCEL or other similar confirmations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * @see javax.security.auth.callback.CallbackHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
public class ConfirmationCallback implements Callback, java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    private static final long serialVersionUID = -9095656433782481624L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
     * Unspecified option type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    43
     * <p> The {@code getOptionType} method returns this
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    44
     * value if this {@code ConfirmationCallback} was instantiated
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    45
     * with {@code options} instead of an {@code optionType}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    public static final int UNSPECIFIED_OPTION          = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * YES/NO confirmation option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * <p> An underlying security service specifies this as the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    53
     * {@code optionType} to a {@code ConfirmationCallback}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * constructor if it requires a confirmation which can be answered
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    55
     * with either {@code YES} or {@code NO}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public static final int YES_NO_OPTION               = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * YES/NO/CANCEL confirmation confirmation option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * <p> An underlying security service specifies this as the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    63
     * {@code optionType} to a {@code ConfirmationCallback}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * constructor if it requires a confirmation which can be answered
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    65
     * with either {@code YES}, {@code NO} or {@code CANCEL}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public static final int YES_NO_CANCEL_OPTION        = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * OK/CANCEL confirmation confirmation option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * <p> An underlying security service specifies this as the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    73
     * {@code optionType} to a {@code ConfirmationCallback}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * constructor if it requires a confirmation which can be answered
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    75
     * with either {@code OK} or {@code CANCEL}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public static final int OK_CANCEL_OPTION            = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * YES option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    82
     * <p> If an {@code optionType} was specified to this
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    83
     * {@code ConfirmationCallback}, this option may be specified as a
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    84
     * {@code defaultOption} or returned as the selected index.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public static final int YES                         = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * NO option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    91
     * <p> If an {@code optionType} was specified to this
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    92
     * {@code ConfirmationCallback}, this option may be specified as a
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    93
     * {@code defaultOption} or returned as the selected index.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public static final int NO                          = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * CANCEL option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   100
     * <p> If an {@code optionType} was specified to this
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   101
     * {@code ConfirmationCallback}, this option may be specified as a
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   102
     * {@code defaultOption} or returned as the selected index.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public static final int CANCEL                      = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * OK option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   109
     * <p> If an {@code optionType} was specified to this
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   110
     * {@code ConfirmationCallback}, this option may be specified as a
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   111
     * {@code defaultOption} or returned as the selected index.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    public static final int OK                          = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    /** INFORMATION message type.  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public static final int INFORMATION                 = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /** WARNING message type. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public static final int WARNING                     = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /** ERROR message type. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public static final int ERROR                       = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    private String prompt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    private int messageType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    private int optionType = UNSPECIFIED_OPTION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    private int defaultOption;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    private String[] options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    private int selection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   155
     * Construct a {@code ConfirmationCallback} with a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * message type, an option type and a default option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * <p> Underlying security services use this constructor if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * they require either a YES/NO, YES/NO/CANCEL or OK/CANCEL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * confirmation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   162
     * @param messageType the message type ({@code INFORMATION},
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   163
     *                  {@code WARNING} or {@code ERROR}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   165
     * @param optionType the option type ({@code YES_NO_OPTION},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   166
     *                  {@code YES_NO_CANCEL_OPTION} or
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   167
     *                  {@code OK_CANCEL_OPTION}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @param defaultOption the default option
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   170
     *                  from the provided optionType ({@code YES},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   171
     *                  {@code NO}, {@code CANCEL} or
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   172
     *                  {@code OK}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @exception IllegalArgumentException if messageType is not either
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   175
     *                  {@code INFORMATION}, {@code WARNING},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   176
     *                  or {@code ERROR}, if optionType is not either
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   177
     *                  {@code YES_NO_OPTION},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   178
     *                  {@code YES_NO_CANCEL_OPTION}, or
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   179
     *                  {@code OK_CANCEL_OPTION},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   180
     *                  or if {@code defaultOption}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *                  does not correspond to one of the options in
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   182
     *                  {@code optionType}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    public ConfirmationCallback(int messageType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                int optionType, int defaultOption) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        if (messageType < INFORMATION || messageType > ERROR ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            optionType < YES_NO_OPTION || optionType > OK_CANCEL_OPTION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        switch (optionType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        case YES_NO_OPTION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            if (defaultOption != YES && defaultOption != NO)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        case YES_NO_CANCEL_OPTION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            if (defaultOption != YES && defaultOption != NO &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                defaultOption != CANCEL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        case OK_CANCEL_OPTION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            if (defaultOption != OK && defaultOption != CANCEL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        this.messageType = messageType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        this.optionType = optionType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        this.defaultOption = defaultOption;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /**
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   213
     * Construct a {@code ConfirmationCallback} with a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * message type, a list of options and a default option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * <p> Underlying security services use this constructor if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * they require a confirmation different from the available preset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * confirmations provided (for example, CONTINUE/ABORT or STOP/GO).
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   219
     * The confirmation options are listed in the {@code options} array,
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   220
     * and are displayed by the {@code CallbackHandler} implementation
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * in a manner consistent with the way preset options are displayed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   223
     * @param messageType the message type ({@code INFORMATION},
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   224
     *                  {@code WARNING} or {@code ERROR}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   226
     * @param options the list of confirmation options.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @param defaultOption the default option, represented as an index
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   229
     *                  into the {@code options} array.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @exception IllegalArgumentException if messageType is not either
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   232
     *                  {@code INFORMATION}, {@code WARNING},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   233
     *                  or {@code ERROR}, if {@code options} is null,
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   234
     *                  if {@code options} has a length of 0,
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   235
     *                  if any element from {@code options} is null,
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   236
     *                  if any element from {@code options}
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   237
     *                  has a length of 0, or if {@code defaultOption}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *                  does not lie within the array boundaries of
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   239
     *                  {@code options}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public ConfirmationCallback(int messageType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                String[] options, int defaultOption) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        if (messageType < INFORMATION || messageType > ERROR ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            options == null || options.length == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            defaultOption < 0 || defaultOption >= options.length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        for (int i = 0; i < options.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            if (options[i] == null || options[i].length() == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        this.messageType = messageType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        this.options = options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        this.defaultOption = defaultOption;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /**
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   260
     * Construct a {@code ConfirmationCallback} with a prompt,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * message type, an option type and a default option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * <p> Underlying security services use this constructor if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * they require either a YES/NO, YES/NO/CANCEL or OK/CANCEL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * confirmation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     *
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   267
     * @param prompt the prompt used to describe the list of options.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   269
     * @param messageType the message type ({@code INFORMATION},
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   270
     *                  {@code WARNING} or {@code ERROR}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   272
     * @param optionType the option type ({@code YES_NO_OPTION},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   273
     *                  {@code YES_NO_CANCEL_OPTION} or
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   274
     *                  {@code OK_CANCEL_OPTION}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @param defaultOption the default option
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   277
     *                  from the provided optionType ({@code YES},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   278
     *                  {@code NO}, {@code CANCEL} or
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   279
     *                  {@code OK}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   281
     * @exception IllegalArgumentException if {@code prompt} is null,
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   282
     *                  if {@code prompt} has a length of 0,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     *                  if messageType is not either
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   284
     *                  {@code INFORMATION}, {@code WARNING},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   285
     *                  or {@code ERROR}, if optionType is not either
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   286
     *                  {@code YES_NO_OPTION},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   287
     *                  {@code YES_NO_CANCEL_OPTION}, or
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   288
     *                  {@code OK_CANCEL_OPTION},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   289
     *                  or if {@code defaultOption}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *                  does not correspond to one of the options in
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   291
     *                  {@code optionType}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public ConfirmationCallback(String prompt, int messageType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                int optionType, int defaultOption) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        if (prompt == null || prompt.length() == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            messageType < INFORMATION || messageType > ERROR ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            optionType < YES_NO_OPTION || optionType > OK_CANCEL_OPTION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        switch (optionType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        case YES_NO_OPTION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            if (defaultOption != YES && defaultOption != NO)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        case YES_NO_CANCEL_OPTION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            if (defaultOption != YES && defaultOption != NO &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                defaultOption != CANCEL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        case OK_CANCEL_OPTION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            if (defaultOption != OK && defaultOption != CANCEL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        this.prompt = prompt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        this.messageType = messageType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        this.optionType = optionType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        this.defaultOption = defaultOption;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /**
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   324
     * Construct a {@code ConfirmationCallback} with a prompt,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * message type, a list of options and a default option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * <p> Underlying security services use this constructor if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * they require a confirmation different from the available preset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * confirmations provided (for example, CONTINUE/ABORT or STOP/GO).
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   330
     * The confirmation options are listed in the {@code options} array,
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   331
     * and are displayed by the {@code CallbackHandler} implementation
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * in a manner consistent with the way preset options are displayed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   334
     * @param prompt the prompt used to describe the list of options.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   336
     * @param messageType the message type ({@code INFORMATION},
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   337
     *                  {@code WARNING} or {@code ERROR}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     *
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   339
     * @param options the list of confirmation options.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * @param defaultOption the default option, represented as an index
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   342
     *                  into the {@code options} array.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   344
     * @exception IllegalArgumentException if {@code prompt} is null,
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   345
     *                  if {@code prompt} has a length of 0,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *                  if messageType is not either
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   347
     *                  {@code INFORMATION}, {@code WARNING},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   348
     *                  or {@code ERROR}, if {@code options} is null,
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   349
     *                  if {@code options} has a length of 0,
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   350
     *                  if any element from {@code options} is null,
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   351
     *                  if any element from {@code options}
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   352
     *                  has a length of 0, or if {@code defaultOption}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     *                  does not lie within the array boundaries of
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   354
     *                  {@code options}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    public ConfirmationCallback(String prompt, int messageType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                String[] options, int defaultOption) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        if (prompt == null || prompt.length() == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            messageType < INFORMATION || messageType > ERROR ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            options == null || options.length == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            defaultOption < 0 || defaultOption >= options.length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        for (int i = 0; i < options.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            if (options[i] == null || options[i].length() == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        this.prompt = prompt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        this.messageType = messageType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        this.options = options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        this.defaultOption = defaultOption;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * Get the prompt.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   379
     * @return the prompt, or null if this {@code ConfirmationCallback}
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   380
     *          was instantiated without a {@code prompt}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    public String getPrompt() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        return prompt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * Get the message type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   389
     * @return the message type ({@code INFORMATION},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   390
     *          {@code WARNING} or {@code ERROR}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    public int getMessageType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        return messageType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * Get the option type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   399
     * <p> If this method returns {@code UNSPECIFIED_OPTION}, then this
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   400
     * {@code ConfirmationCallback} was instantiated with
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   401
     * {@code options} instead of an {@code optionType}.
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   402
     * In this case, invoke the {@code getOptions} method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * to determine which confirmation options to display.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   405
     * @return the option type ({@code YES_NO_OPTION},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   406
     *          {@code YES_NO_CANCEL_OPTION} or
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   407
     *          {@code OK_CANCEL_OPTION}), or
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   408
     *          {@code UNSPECIFIED_OPTION} if this
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   409
     *          {@code ConfirmationCallback} was instantiated with
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   410
     *          {@code options} instead of an {@code optionType}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    public int getOptionType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        return optionType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * Get the confirmation options.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * @return the list of confirmation options, or null if this
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   420
     *          {@code ConfirmationCallback} was instantiated with
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   421
     *          an {@code optionType} instead of {@code options}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    public String[] getOptions() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        return options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * Get the default option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * @return the default option, represented as
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   431
     *          {@code YES}, {@code NO}, {@code OK} or
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   432
     *          {@code CANCEL} if an {@code optionType}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     *          was specified to the constructor of this
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   434
     *          {@code ConfirmationCallback}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     *          Otherwise, this method returns the default option as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     *          an index into the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   437
     *          {@code options} array specified to the constructor
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   438
     *          of this {@code ConfirmationCallback}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    public int getDefaultOption() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        return defaultOption;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * Set the selected confirmation option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   447
     * @param selection the selection represented as {@code YES},
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   448
     *          {@code NO}, {@code OK} or {@code CANCEL}
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   449
     *          if an {@code optionType} was specified to the constructor
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   450
     *          of this {@code ConfirmationCallback}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     *          Otherwise, the selection represents the index into the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   452
     *          {@code options} array specified to the constructor
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   453
     *          of this {@code ConfirmationCallback}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * @see #getSelectedIndex
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    public void setSelectedIndex(int selection) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        this.selection = selection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * Get the selected confirmation option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @return the selected confirmation option represented as
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   465
     *          {@code YES}, {@code NO}, {@code OK} or
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   466
     *          {@code CANCEL} if an {@code optionType}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *          was specified to the constructor of this
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   468
     *          {@code ConfirmationCallback}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     *          Otherwise, this method returns the selected confirmation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *          option as an index into the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   471
     *          {@code options} array specified to the constructor
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   472
     *          of this {@code ConfirmationCallback}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * @see #setSelectedIndex
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    public int getSelectedIndex() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        return selection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
}