QuickServer
v1.4.7

org.quickserver.net.server
Interface ClientAuthenticationHandler

All Known Implementing Classes:
QuickAuthenticationHandler

public interface ClientAuthenticationHandler

This interface defines a class that can be used by QuickServer to authenticate a client when new connection is made to QuickServer.

Recommendations to be followed when implementing ClientAuthenticationHandler

Ex:

package echoserver;

import java.net.*;
import java.io.*;
import org.quickserver.net.server.ClientAuthenticationHandler;
import org.quickserver.net.server.ClientHandler;

public class EchoAuthenticationHandler 
                implements ClientAuthenticationHandler {

        public AuthStatus askAuthentication(ClientHandler handler) 
                throws IOException, AppException {
                handler.sendClientMsg("Password :");
                return null;
        }

        public AuthStatus handleAuthentication(ClientHandler handler, String data) 
                        throws IOException, AppException {
                if(data.equals("password"))
                        return AuthStatus.SUCCESS;
                else
                        return AuthStatus.FAILURE;
        }

        public AuthStatus handleAuthentication(ClientHandler handler, Object data) 
                        throws IOException, AppException {
                if(true) throw new IOException("Object mode not implemented!");
        }

        public AuthStatus handleAuthentication(ClientHandler handler, byte data[]) 
                        throws IOException {
                if(true) throw new IOException("Byte mode not implemented!");
        }
}

Since:
1.4.6
Author:
Akshathkumar Shetty

Method Summary
 AuthStatus askAuthentication(ClientHandler handler)
          Method called first time after gotConnected() method is caled on ClientEventHandler, if Authenticator is set.
 AuthStatus handleAuthentication(ClientHandler handler, byte[] data)
          Method called when ever a client sends binary data before authentication.
 AuthStatus handleAuthentication(ClientHandler handler, java.lang.Object data)
          Method called when ever a client sends Object data before authentication.
 AuthStatus handleAuthentication(ClientHandler handler, java.lang.String data)
          Method called when ever a client sends character/string data before authentication.
 

Method Detail

askAuthentication

public AuthStatus askAuthentication(ClientHandler handler)
                             throws java.io.IOException,
                                    AppException
Method called first time after gotConnected() method is caled on ClientEventHandler, if Authenticator is set. Should be used to initate a authorisation process, like asking for username.

Returns:
AuthStatus that indicates if authorisation states, if null it is treated as authentication not yet finished.
Throws:
java.io.IOException - if io error in socket
AppException - if client socket needs to be closed.

handleAuthentication

public AuthStatus handleAuthentication(ClientHandler handler,
                                       java.lang.String data)
                                throws java.io.IOException,
                                       AppException
Method called when ever a client sends character/string data before authentication.

Returns:
AuthStatus that indicates if authorisation states, if null it is treated as authentication not yet finished.
Throws:
java.io.IOException - if io error in socket
AppException - if client socket needs to be closed.

handleAuthentication

public AuthStatus handleAuthentication(ClientHandler handler,
                                       java.lang.Object data)
                                throws java.io.IOException,
                                       AppException
Method called when ever a client sends Object data before authentication.

Returns:
AuthStatus that indicates if authorisation states, if null it is treated as authentication not yet finished.
Throws:
java.io.IOException - if io error in socket
AppException - if client socket needs to be closed.

handleAuthentication

public AuthStatus handleAuthentication(ClientHandler handler,
                                       byte[] data)
                                throws java.io.IOException,
                                       AppException
Method called when ever a client sends binary data before authentication.

Returns:
AuthStatus that indicates if authorisation states, if null it is treated as authentication not yet finished.
Throws:
java.io.IOException - if io error in socket
AppException - if client socket needs to be closed.

QuickServer
v1.4.7

Copyright © 2003-2006 QuickServer.org