|
QuickServer v1.4.5 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.quickserver.net.server.QuickAuthenticator
This class is used to authenticate a client when it connects to QuickServer. Only single instance of this class will be used per QuickServer to handle all authentication. Should have a default constructor.
Ex:
package echoserver;
import org.quickserver.net.server.*;
import java.io.*;
public class EchoServerQuickAuthenticator extends QuickAuthenticator {
public boolean askAuthorisation(ClientHandler clientHandler)
throws IOException {
String username = askStringInput(clientHandler, "User Name :");
String password = askStringInput(clientHandler, "Password :");
if(username==null || password ==null)
return false;
if(username.equals(password)) {
sendString(clientHandler, "Auth OK");
return true;
} else {
sendString(clientHandler, "Auth Failed");
return false;
}
}
}
Constructor Summary | |
QuickAuthenticator()
|
Method Summary | |
abstract boolean |
askAuthorisation(ClientHandler clientHandler)
This method is called by QuickServer
if ServerAuthenticator was set, to authenticate any client
connection. |
byte[] |
askBinaryInput(ClientHandler clientHandler,
byte[] msg)
Sends the given binary data to the client and reads binary data input. |
java.lang.String |
askByteInput(ClientHandler clientHandler,
java.lang.String msg)
Prints the given message to the client and reads a line of input. |
java.lang.Object |
askObjectInput(ClientHandler clientHandler,
java.lang.Object msg)
Prints the given message to the client and reads a Object from input. |
java.lang.String |
askStringInput(ClientHandler clientHandler,
java.lang.String msg)
Prints the given message to the client and reads a line of input. |
void |
sendBinary(ClientHandler clientHandler,
byte[] msg)
Sends the given binary data to the client. |
void |
sendByte(ClientHandler clientHandler,
java.lang.String msg)
Prints the given message to the client. |
void |
sendObject(ClientHandler clientHandler,
java.lang.Object msg)
Sends the given object to the client. |
void |
sendString(ClientHandler clientHandler,
java.lang.String msg)
Prints the given message to the client. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public QuickAuthenticator()
Method Detail |
public abstract boolean askAuthorisation(ClientHandler clientHandler) throws java.io.IOException, AppException
Authenticator
QuickServer
if ServerAuthenticator was set, to authenticate any client
connection.
askAuthorisation
in interface Authenticator
java.io.IOException
- if there is socket error
AppException
- if ServerAuthenticator wants QuickServer to close the
client connection. public void sendString(ClientHandler clientHandler, java.lang.String msg) throws java.io.IOException
msg
- Message to send.
If null
is passed it will not send any thing.
java.io.IOException
public java.lang.String askStringInput(ClientHandler clientHandler, java.lang.String msg) throws java.io.IOException
msg
- Message to send before reading input. If received String is
null
it will throw ConnectionLostException
.
If null
is passed it will not send any thing.
java.io.IOException
- if an I/O error occurspublic void sendObject(ClientHandler clientHandler, java.lang.Object msg) throws java.io.IOException
msg
- Message to send.
If null
is passed it will not send any thing.
java.io.IOException
public java.lang.Object askObjectInput(ClientHandler clientHandler, java.lang.Object msg) throws java.io.IOException, java.lang.ClassNotFoundException
msg
- Message to send before reading input.
If null
is passed it will not send any thing.
null
it will throw ConnectionLostException
.
java.io.IOException
- if an I/O error occurs
java.lang.ClassNotFoundException
public void sendByte(ClientHandler clientHandler, java.lang.String msg) throws java.io.IOException
msg
- Message to send.
If null
is passed it will not send any thing.
java.io.IOException
public java.lang.String askByteInput(ClientHandler clientHandler, java.lang.String msg) throws java.io.IOException
msg
- Message to send before reading input.
If null
is passed it will not send any thing.
null
it will throw ConnectionLostException
.
java.io.IOException
- if an I/O error occurspublic void sendBinary(ClientHandler clientHandler, byte[] msg) throws java.io.IOException
msg
- binary data to send.
If null
is passed it will not send any thing.
java.io.IOException
public byte[] askBinaryInput(ClientHandler clientHandler, byte[] msg) throws java.io.IOException
msg
- binary data to send before reading input.
If null
is passed it will not send any thing.
null
it will throw ConnectionLostException
.
java.io.IOException
- if an I/O error occurs
|
QuickServer v1.4.5 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |