| org.quickserver.net.server.ClientAuthenticationHandler
All known Subclasses: org.quickserver.net.server.QuickAuthenticationHandler,
ClientAuthenticationHandler | public interface ClientAuthenticationHandler (Code) | | 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
- Should have a default constructor.
- Should be thread safe.
- It should not store any data that may is associated with a particular client.
- If any client data is need to be saved from the client session,
it should be saved to a
ClientData class, which can be retrieved
using handler.getClientData() method.
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!");
}
}
author: Akshathkumar Shetty since: 1.4.6 |
askAuthentication | public AuthStatus askAuthentication(ClientHandler handler) throws IOException, AppException(Code) | | 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.
exception: java.io.IOException - if io error in socket exception: AppException - if client socket needs to be closed. AuthStatus that indicates if authorisation states, if null it is treated as authentication not yet finished. |
handleAuthentication | public AuthStatus handleAuthentication(ClientHandler handler, byte data) throws IOException, AppException(Code) | | Method called when ever a client sends binary data
before authentication.
exception: java.io.IOException - if io error in socket exception: AppException - if client socket needs to be closed. AuthStatus that indicates if authorisation states, if null it is treated as authentication not yet finished. |
|
|