KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > net > PasswordAuthentication


1 /*
2  * @(#)PasswordAuthentication.java 1.15 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.net;
9
10
11 /**
12  * The class PasswordAuthentication is a data holder that is used by
13  * Authenticator. It is simply a repository for a user name and a password.
14  *
15  * @see java.net.Authenticator
16  * @see java.net.Authenticator#getPasswordAuthentication()
17  *
18  * @author Bill Foote
19  * @version 1.15, 12/19/03
20  * @since 1.2
21  */

22
23 public final class PasswordAuthentication {
24
25     private String JavaDoc userName;
26     private char[] password;
27
28     /**
29      * Creates a new <code>PasswordAuthentication</code> object from the given
30      * user name and password.
31      *
32      * <p> Note that the given user password is cloned before it is stored in
33      * the new <code>PasswordAuthentication</code> object.
34      *
35      * @param userName the user name
36      * @param password the user's password
37      */

38     public PasswordAuthentication(String JavaDoc userName, char[] password) {
39     this.userName = userName;
40     this.password = (char[])password.clone();
41     }
42
43     /**
44      * Returns the user name.
45      *
46      * @return the user name
47      */

48     public String JavaDoc getUserName() {
49     return userName;
50     }
51
52     /**
53      * Returns the user password.
54      *
55      * <p> Note that this method returns a reference to the password. It is
56      * the caller's responsibility to zero out the password information after
57      * it is no longer needed.
58      *
59      * @return the password
60      */

61     public char[] getPassword() {
62     return password;
63     }
64 }
65
66
Popular Tags