01: /*
02: * CoadunationLib: The coaduntion implementation library.
03: * Copyright (C) 2006 Rift IT Contracting
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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;
30: import java.util.HashMap;
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 username = null;
48: private String password = null;
49:
50: /**
51: * Creates a new instance of PasswordInfoHandler
52: */
53: public PasswordInfoHandler(String username, String password) {
54: this .username = username;
55: this .password = password;
56: }
57:
58: /**
59: * This method returns the authentication type required.
60: *
61: * @return The string containing the authentication type.
62: */
63: public String getAuthType() {
64: return AuthTypes.PASSWORD;
65: }
66:
67: /**
68: * This method return the information required to perform the login.
69: *
70: * @return The map containing the authentication information.
71: * @exception LoginException
72: */
73: public Map getInfo() throws LoginException {
74: Map parameters = new HashMap();
75: parameters.put(AuthValues.USERNAME, username);
76: parameters.put(AuthValues.PASSWORD, password);
77: return parameters;
78: }
79: }
|