public interface ClientAuthenticationHandler
Recommendations to be followed when implementing ClientAuthenticationHandler
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!");
}
}
Modifier and Type | Method and Description |
---|---|
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.
|
AuthStatus askAuthentication(ClientHandler handler) throws java.io.IOException, AppException
java.io.IOException
- if io error in socketAppException
- if client socket needs to be closed.AuthStatus handleAuthentication(ClientHandler handler, java.lang.String data) throws java.io.IOException, AppException
java.io.IOException
- if io error in socketAppException
- if client socket needs to be closed.AuthStatus handleAuthentication(ClientHandler handler, java.lang.Object data) throws java.io.IOException, AppException
java.io.IOException
- if io error in socketAppException
- if client socket needs to be closed.AuthStatus handleAuthentication(ClientHandler handler, byte[] data) throws java.io.IOException, AppException
java.io.IOException
- if io error in socketAppException
- if client socket needs to be closed.Copyright © 2003-2014 QuickServer.org