KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > echoserver > EchoServerQuickAuthenticator


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) 2003-2005 QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
10  * For questions, suggestions, bug-reports, enhancement-requests etc.
11  * visit http://www.quickserver.org
12  *
13  */

14
15 package echoserver;
16
17 import org.quickserver.net.server.*;
18 import java.io.*;
19 import org.quickserver.net.AppException;
20
21 /**
22  * Try to use EchoAuthenticatorHandler
23  */

24 public class EchoServerQuickAuthenticator extends QuickAuthenticator {
25
26     public boolean askAuthorisation(ClientHandler clientHandler)
27             throws IOException, AppException {
28         String JavaDoc username = askStringInput(clientHandler, "User Name :");
29         //no need to check for null done by QuickAuthenticator
30

31         String JavaDoc password = askStringInput(clientHandler, "Password :");
32         //no need to check for null done by QuickAuthenticator
33

34         if(username.equals(password)) {
35             sendString(clientHandler, "Auth OK");
36             return true;
37         } else {
38             sendString(clientHandler, "Auth Failed");
39             return false;
40         }
41     }
42 }
43
Popular Tags