|
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.ServerAuthenticator
This class is used to authenticate a client when it connects to QuickServer.
Every client connected will have separate instance of this class which
will be used to handle the authentication. If single instance is needed
use QuickAuthenticator
. You should only use this class if your
authentication need you to have dedicate an object.
Recommendations to be followed when extending ServerAuthenticator.
Ex:
package echoserver;
import org.quickserver.net.server.*;
import java.io.*;
public class MyServerAuthenticator extends ServerAuthenticator {
public boolean askAuthorisation() throws IOException {
pout.println("User Name :");
username=in.readLine();
pout.println("Password :");
password=in.readLine();
if(username==null || password ==null)
return false;
if(username.equals(password))
return true;
else {
pout.println("Auth Failed");
return false;
}
}
}
Field Summary | |
protected ClientData |
data
|
protected java.lang.String |
error
|
protected ClientHandler |
handler
|
protected java.io.BufferedReader |
in
Client input BufferedReader |
protected java.io.OutputStream |
out
Client output OutputStream |
protected java.lang.String |
password
Member to store password |
protected java.io.PrintWriter |
pout
Client output PrintWriter |
protected java.lang.String |
username
Member to store username |
Constructor Summary | |
ServerAuthenticator()
|
Method Summary | |
boolean |
askAuthorisation()
This method is called by QuickServer
if ServerAuthenticator was set, to authenticate any client
connection. |
boolean |
askAuthorisation(ClientHandler clientHandler)
This method is called by QuickServer
if ServerAuthenticator was set, to authenticate any client
connection. |
void |
cleanup()
Called by ClientHandler ones. |
ClientData |
getClientData()
Return ClientData object associated with Client being authenticated or null if no ClientData was set in QuickServer object. |
ClientHandler |
getClientHandler()
Returns ClientHandler object associated with Client being authenticated. |
java.lang.String |
getError()
Gives description for last Authorisation failure if any. |
boolean |
getFreeOnUse()
Returns if ServerAuthenticator should be freed after client is authenticated. |
void |
setClientHandler(ClientHandler handler)
Sets ClientHandler object associated with Client being authenticated. |
void |
setError(java.lang.String error)
Sets description for last Authorisation failure if any. |
void |
setFreeOnUse(boolean flag)
Sets if ServerAuthenticator should be freed after client is authenticated. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String error
protected java.io.BufferedReader in
protected java.io.OutputStream out
protected java.io.PrintWriter pout
protected ClientData data
protected ClientHandler handler
protected java.lang.String username
protected java.lang.String password
Constructor Detail |
public ServerAuthenticator()
Method Detail |
public boolean askAuthorisation() throws java.io.IOException, AppException
QuickServer
if ServerAuthenticator was set, to authenticate any client
connection.
AppException
- if ServerAuthenticator wants QuickServer to close the
client connection. java.io.IOException
- if there is socket errorpublic 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 java.lang.String getError()
public void setError(java.lang.String error)
public void cleanup()
ClientHandler
ones.
Used to close any resources that was opened by the
inheriting class. Do call the base class version
eg: super.cleanup()
if you override.
This will set all io/output streams,
data
, handler
to null
.
public ClientData getClientData()
QuickServer
object.
public final void setClientHandler(ClientHandler handler)
getClientHandler()
public ClientHandler getClientHandler()
public void setFreeOnUse(boolean flag)
true
QuickServer will set ServerAuthenticator to null ones
client is authenticated. Default is true
getFreeOnUse()
public boolean getFreeOnUse()
true
setFreeOnUse(boolean)
|
QuickServer v1.4.5 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |