1 14 15 package echoserver; 16 17 import org.quickserver.net.server.*; 18 import java.io.*; 19 import org.quickserver.net.AppException; 20 21 public class EchoServerAuthenticator extends ServerAuthenticator { 22 23 public boolean askAuthorisation() throws IOException, AppException { 24 pout.println("User Name :"); 25 username=in.readLine(); 26 if(username==null) { 27 throw new IOException("Lost Connection"); 28 } 30 31 pout.println("Password :"); 32 password=in.readLine(); 33 if(password ==null) { 34 throw new IOException("Lost Connection"); 35 } 37 38 if(username.equals(password)) { 39 pout.println("Auth OK"); 40 return true; 41 } else { 42 pout.println("Auth Failed"); 43 return false; 44 } 45 } 46 } 47 | Popular Tags |