KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > security > auth > message > callback > PasswordValidationCallback


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package javax.security.auth.message.callback;
23
24 import javax.security.auth.callback.Callback JavaDoc;
25
26 //$Id: PasswordValidationCallback.java 45179 2006-05-23 20:18:57Z asaldhana $
27

28 /**
29  * Callback for PasswordValidation.
30  * @author <a HREF="mailto:Anil.Saldhana@jboss.org">Anil Saldhana</a>
31  * @author Charlie Lai, Ron Monzillo (Javadoc for JSR-196)
32  * @since May 11, 2006
33  * @version $Revision: 45179 $
34  */

35 public class PasswordValidationCallback implements Callback JavaDoc
36 {
37    private String JavaDoc username;
38    private char[] password;
39    
40    private boolean resultOfAuthentication = false;
41    
42    /**
43     * Create a new PasswordValidationCallback.
44     *
45     * @param username the username to authenticate
46     * @param password the user’s password, which may be null.
47     */

48    public PasswordValidationCallback(String JavaDoc username, char[] password)
49    {
50       this.username = username;
51       this.password = password;
52    }
53    
54    /**
55     * Clear the password.
56     */

57    public void clearPassword()
58    {
59       this.password = null;
60    }
61    
62    /**
63     * Get the password.
64     * <b>Note</b> that this method returns a reference to the password. If a clone
65     * of the array is created it is the caller’s responsibility to zero out
66     * the password information after it is no longer needed.
67     *
68     * @return the password, which may be null.
69     */

70    public char[] getPassword()
71    {
72       return this.password;
73    }
74    
75    /**
76     * Get the authentication result.
77     * @return true if authentication succeeded, false otherwise
78     */

79    public boolean getResult()
80    {
81       return this.resultOfAuthentication;
82    }
83    
84    /**
85     * Get the username.
86     * @return the username.
87     */

88    public String JavaDoc getUsername()
89    {
90       return this.username;
91    }
92    
93    /**
94     * Set the authentication result.
95     *
96     * @param result true if authentication succeeded, false otherwise
97     */

98    public void setResult(boolean result)
99    {
100       this.resultOfAuthentication = result;
101    }
102 }
103
Popular Tags