jdk/src/share/classes/javax/security/auth/callback/NameCallback.java
changeset 18830 90956ead732f
parent 5506 202f599c92aa
equal deleted inserted replaced
18829:ec84f0c313b0 18830:90956ead732f
     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>NameCallback</code> to the <code>handle</code>
    30  * {@code NameCallback} to the {@code handle}
    31  * method of a <code>CallbackHandler</code> to retrieve name information.
    31  * method of a {@code CallbackHandler} to retrieve name information.
    32  *
    32  *
    33  * @see javax.security.auth.callback.CallbackHandler
    33  * @see javax.security.auth.callback.CallbackHandler
    34  */
    34  */
    35 public class NameCallback implements Callback, java.io.Serializable {
    35 public class NameCallback implements Callback, java.io.Serializable {
    36 
    36 
    51      * @since 1.4
    51      * @since 1.4
    52      */
    52      */
    53     private String inputName;
    53     private String inputName;
    54 
    54 
    55     /**
    55     /**
    56      * Construct a <code>NameCallback</code> with a prompt.
    56      * Construct a {@code NameCallback} with a prompt.
    57      *
    57      *
    58      * <p>
    58      * <p>
    59      *
    59      *
    60      * @param prompt the prompt used to request the name.
    60      * @param prompt the prompt used to request the name.
    61      *
    61      *
    62      * @exception IllegalArgumentException if <code>prompt</code> is null
    62      * @exception IllegalArgumentException if {@code prompt} is null
    63      *                  or if <code>prompt</code> has a length of 0.
    63      *                  or if {@code prompt} has a length of 0.
    64      */
    64      */
    65     public NameCallback(String prompt) {
    65     public NameCallback(String prompt) {
    66         if (prompt == null || prompt.length() == 0)
    66         if (prompt == null || prompt.length() == 0)
    67             throw new IllegalArgumentException();
    67             throw new IllegalArgumentException();
    68         this.prompt = prompt;
    68         this.prompt = prompt;
    69     }
    69     }
    70 
    70 
    71     /**
    71     /**
    72      * Construct a <code>NameCallback</code> with a prompt
    72      * Construct a {@code NameCallback} with a prompt
    73      * and default name.
    73      * and default name.
    74      *
    74      *
    75      * <p>
    75      * <p>
    76      *
    76      *
    77      * @param prompt the prompt used to request the information. <p>
    77      * @param prompt the prompt used to request the information. <p>
    78      *
    78      *
    79      * @param defaultName the name to be used as the default name displayed
    79      * @param defaultName the name to be used as the default name displayed
    80      *                  with the prompt.
    80      *                  with the prompt.
    81      *
    81      *
    82      * @exception IllegalArgumentException if <code>prompt</code> is null,
    82      * @exception IllegalArgumentException if {@code prompt} is null,
    83      *                  if <code>prompt</code> has a length of 0,
    83      *                  if {@code prompt} has a length of 0,
    84      *                  if <code>defaultName</code> is null,
    84      *                  if {@code defaultName} is null,
    85      *                  or if <code>defaultName</code> has a length of 0.
    85      *                  or if {@code defaultName} has a length of 0.
    86      */
    86      */
    87     public NameCallback(String prompt, String defaultName) {
    87     public NameCallback(String prompt, String defaultName) {
    88         if (prompt == null || prompt.length() == 0 ||
    88         if (prompt == null || prompt.length() == 0 ||
    89             defaultName == null || defaultName.length() == 0)
    89             defaultName == null || defaultName.length() == 0)
    90             throw new IllegalArgumentException();
    90             throw new IllegalArgumentException();
   107     /**
   107     /**
   108      * Get the default name.
   108      * Get the default name.
   109      *
   109      *
   110      * <p>
   110      * <p>
   111      *
   111      *
   112      * @return the default name, or null if this <code>NameCallback</code>
   112      * @return the default name, or null if this {@code NameCallback}
   113      *          was not instantiated with a <code>defaultName</code>.
   113      *          was not instantiated with a {@code defaultName}.
   114      */
   114      */
   115     public String getDefaultName() {
   115     public String getDefaultName() {
   116         return defaultName;
   116         return defaultName;
   117     }
   117     }
   118 
   118