KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > freecs > auth > IAuthenticator


1 /**
2  * Copyright (C) 2003 Manfred Andres
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */

18 package freecs.auth;
19
20 import java.util.Properties JavaDoc;
21
22 import freecs.core.User;
23 import freecs.interfaces.IRequest;
24
25
26 /**
27  * Implementing class has to take care of reading and updating chattime and other data.
28  * You better extend AbstractAuthenticator to use this interface.
29  */

30
31 public interface IAuthenticator {
32    
33     /**
34      * called when the server is starting up or the config file changes
35      */

36     public abstract void init (Properties JavaDoc props, String JavaDoc additionalPrefix) throws Exception JavaDoc;
37
38        
39    /**
40     * this is called when the server is going down expectedly
41     * close every connection and clean up stuff before stopping
42     * @throws Exception to let the log-file know that there was an error
43     */

44    public abstract void shutdown () throws Exception JavaDoc;
45    
46    /**
47     * get's called on an attempt to log in
48     *
49     * @param usr the user name of the user wanting to log in
50     * @param pwd the password of the user wanting to log in
51     * @param cookie the cookie associated with the user's browser
52     * @return the newly constructed User on success || null otherwhise
53     * @throws Exception if something unexpected happens
54     */

55    public abstract User loginUser (String JavaDoc username, String JavaDoc password, String JavaDoc cookie, IRequest request) throws Exception JavaDoc;
56    
57    /**
58     * (re-)checks an existing user object and sets all properties
59     * that haven't yet been set on the user object. this method can be
60     * used if the actual authentication has already been done through a
61     * custom authenticator but data like chatcolor etc still needs to be
62     * fetched from the db.
63     */

64    public abstract User loginUser (User u, String JavaDoc username, String JavaDoc password, IRequest request) throws Exception JavaDoc;
65
66    
67    /**
68     * every action which has to be done to log out a user (update chattime and color, ...)
69     * has to be done here
70     * @param u the user wanting to log out
71     * @throws Exception if something unexpected happens
72     */

73    public abstract void logoutUser (User u) throws Exception JavaDoc;
74 }
Popular Tags