KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > security > login > handlers > PasswordInfoHandler


1 /*
2  * CoadunationLib: The coaduntion implementation library.
3  * Copyright (C) 2006 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * PasswordInfoHandler.java
20  *
21  * This class will handle a basic password login if both user name and password
22  * are supplied when the class is instanciated.
23  */

24
25 // the package path for the source file
26
package com.rift.coad.lib.security.login.handlers;
27
28 // java imports
29
import java.util.Map JavaDoc;
30 import java.util.HashMap JavaDoc;
31
32 // coadunation imports
33
import com.rift.coad.lib.security.login.AuthValues;
34 import com.rift.coad.lib.security.login.AuthTypes;
35 import com.rift.coad.lib.security.login.LoginInfoHandler;
36 import com.rift.coad.lib.security.login.LoginException;
37
38 /**
39  * This class will handle a basic password login if both user name and password
40  * are supplied when the class is instanciated.
41  *
42  * @author Brett Chaldecott
43  */

44 public class PasswordInfoHandler implements LoginInfoHandler {
45     
46     // the classes private member variables
47
private String JavaDoc username = null;
48     private String JavaDoc password = null;
49     
50     /**
51      * Creates a new instance of PasswordInfoHandler
52      */

53     public PasswordInfoHandler(String JavaDoc username, String JavaDoc password) {
54         this.username = username;
55         this.password = password;
56     }
57     
58     
59     /**
60      * This method returns the authentication type required.
61      *
62      * @return The string containing the authentication type.
63      */

64     public String JavaDoc getAuthType() {
65         return AuthTypes.PASSWORD;
66     }
67             
68     
69     
70     /**
71      * This method return the information required to perform the login.
72      *
73      * @return The map containing the authentication information.
74      * @exception LoginException
75      */

76     public Map JavaDoc getInfo() throws LoginException {
77         Map JavaDoc parameters = new HashMap JavaDoc();
78         parameters.put(AuthValues.USERNAME,username);
79         parameters.put(AuthValues.PASSWORD,password);
80         return parameters;
81     }
82 }
83
Popular Tags