All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class KQMLLayer.KQMLSecurity

Abstract.Security
   |
   +----KQMLLayer.KQMLSecurity

public class KQMLSecurity
extends Security
Secure the connection. Check whether the register,unregister protocol is satisfied. No password check will be performed. You can extend Security class to perform more complex security check include password check. Typical process for the KQML agents' protocol is :
At first, upon request, ServerSocket(BServerThread) will accept() and introduce itself. Then, the client will receive the introduction and send the client's introduction. If the message is legal, the Security will send accepted message.
The address table for this class should be defined. When you construct your agent, the address table should be created before construct the KQMLSecurity object.To pass address table for the KQMLSecurity constructor is preferable not to forget set address table to the KQMLSecurity object.


Constructor Index

 o KQMLSecurity()
Default constructor
 o KQMLSecurity(AddressTable)
Constructor with AddressTable

Method Index

 o denyConnection(ReceiverThread, String)
Deny connection since error.
 o isValidAgent(Object)
No checking on the validity, user name check
 o processClientLogin(ReceiverThread, Address)
Opposite to the processServerLogin.
 o processClientLogout(ReceiverThread)
Send disconnect message to the BRecvThread for some reasons such as timeout, or reboot the Server,etc.
 o processErrorLogin(int, ReceiverThread, String)
Process error state.
 o processServerLogin(ReceiverThread)
Override processServerLogin since KMQL use different register process By request, server will kindly introduce itself.
 o secureAgent(String, String)
Check the client send its name and the name is different from mine No password check.
 o startConnection(ReceiverThread, String, String)
Start connection.

Constructors

 o KQMLSecurity
 public KQMLSecurity()
Default constructor

 o KQMLSecurity
 public KQMLSecurity(AddressTable addresses)
Constructor with AddressTable

Parameters:
addresses - AddressTable , which will be maintained by this.

Methods

 o processServerLogin
 public void processServerLogin(ReceiverThread con)
Override processServerLogin since KMQL use different register process By request, server will kindly introduce itself. Then wait for the client introduction. If it matches the protocol, receiver thread will be started. If the first message from client has not 'register' performative, accession will be denied. If the first message's content does not satisfy the security check, this method will give a chance to the client to correct. If the corrected response is still wrong, access will be denied. No password cross-check will be performed.

Parameters:
con - BRecvThread, will be started
Overrides:
processServerLogin in class Security
 o processErrorLogin
 protected boolean processErrorLogin(int errorCode,
                                     ReceiverThread con,
                                     String myid)
Process error state. If the error is CLIENTNAMEMISSING or CLIENTSAMENAME, it will give one more chance to get the response from the end connection. If still fails it will close the connection and kill the ReceiverThread

Parameters:
errorCode - error code
con - ReceiverThread, which is checked
myid - My name in agent society
 o startConnection
 protected void startConnection(ReceiverThread con,
                                String agentid,
                                String myid) throws ConnectionException
Start connection. All protocol is satisfied. Add the ReceiverThread to the ConnectionTable

Parameters:
con - ReceiverThread, to be checked
agentid - Other agent name
myid - My name
Throws: ConnectionException
If write a message to the connection fails
 o denyConnection
 protected void denyConnection(ReceiverThread con,
                               String id) throws ConnectionException
Deny connection since error. Send error message and disconnect

Parameters:
con - ReceiverThread, to be killed
id - Other agent name
Throws: ConnectionException
If write a message to the connection fails
 o secureAgent
 protected int secureAgent(String me,
                           String client)
Check the client send its name and the name is different from mine No password check.

Parameters:
me - My name, sent back from the client
client - Client agent name
 o processClientLogin
 public void processClientLogin(ReceiverThread c,
                                Address serveraddress) throws ConnectionException
Opposite to the processServerLogin. Connection should be added to the connection table, by caller. The KQMLTCPRecvThread generator should specify the Server name and Password. The description

Parameters:
c - BRecvThread, which will connect to the other server
serveraddress - Server address to whom I want to connect
Overrides:
processClientLogin in class Security
 o processClientLogout
 public void processClientLogout(ReceiverThread c)
Send disconnect message to the BRecvThread for some reasons such as timeout, or reboot the Server,etc. This method will be invoked by BRecvThread or AgentAction. The processClientLogin does not kill the ReceiverThread

Parameters:
c - BRecvThread to be disconnected
Overrides:
processClientLogout in class Security
 o isValidAgent
 public boolean isValidAgent(Object o)
No checking on the validity, user name check

Overrides:
isValidAgent in class Security

All Packages  Class Hierarchy  This Package  Previous  Next  Index