01: /*
02: * @(#)PasswordAuthentication.java 1.17 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package java.net;
29:
30: /**
31: * The class PasswordAuthentication is a data holder that is used by
32: * Authenticator. It is simply a repository for a user name and a password.
33: *
34: * @see java.net.Authenticator
35: * @see java.net.Authenticator#getPasswordAuthentication()
36: *
37: * @version 1.10, 02/02/00
38: * @since 1.2
39: */
40:
41: public final class PasswordAuthentication {
42:
43: private String userName;
44: private char[] password;
45:
46: /**
47: * Creates a new <code>PasswordAuthentication</code> object from the given
48: * user name and password.
49: *
50: * <p> Note that the given user password is cloned before it is stored in
51: * the new <code>PasswordAuthentication</code> object.
52: *
53: * @param userName the user name
54: * @param password the user's password
55: */
56: public PasswordAuthentication(String userName, char[] password) {
57: this .userName = userName;
58: this .password = (char[]) password.clone();
59: }
60:
61: /**
62: * Returns the user name.
63: *
64: * @return the user name
65: */
66: public String getUserName() {
67: return userName;
68: }
69:
70: /**
71: * Returns the user password.
72: *
73: * <p> Note that this method returns a reference to the password. It is
74: * the caller's responsibility to zero out the password information after
75: * it is no longer needed.
76: *
77: * @return the password
78: */
79: public char[] getPassword() {
80: return password;
81: }
82: }
|