All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class RouterLayer.Router.RouterSecurity

Abstract.Security
   |
   +----RouterLayer.Router.RouterSecurity

public class RouterSecurity
extends Security
Secure the connection. Check whether the connection,disconnection protocol is satisfied. Password check will be performed by setting passwordCheckBit using setPasswordCheck(true) method. Since there's no connection protocol upon which all the agent communities agree, we are just suggesting the protocol, which is neither sufficient nor theoretically correct. We hope this problem to be resolved in the near future. This is our current connection protocol
At first, upon request, Router will accept connection and send SMTP for the connection. Then, the agent will send 'reconnect-agent' protocol message and if the agent is acceptable, the Router will send 'connection-accepted' message to the agent.
From beta version, Registry file will be retained to keep agent registry records. The registry will not be updated until the agent send 'unregister' message to router. For example,


Variable Index

 o CLIENTNAMEMISSING
'whoiam' message does not include the client name
 o CLIENTOK
secureAgent() method will return if 'whoiam' information is correct
 o CLIENTSAMENAME
Client name is the same as the Router name.
 o NOCLIENTLIST
The agent is not registered to the Router
 o NOTVALIDMESSAGEMETHOD
The message-method is not understandable to the Router
 o PASSWORDFILECORRUPTED
Password file is corrupted
 o PASSWORDMISMATCH
The agent password is not matched with its pssword
 o PASSWORDMISSING
Connection needs password check, but 'whoiam' message does not include password
 o WRONGROUTERNAME

Constructor Index

 o RouterSecurity()
Default constructor
 o RouterSecurity(AddressTable, String)
Constructor with AddressTable and password file path.
 o RouterSecurity(AddressTable, String, String)
Constructor with AddressTable, password file path and registry file path.
 o RouterSecurity(AddressTable, String, String, boolean)
Constructor with AddressTable, password file path and registry file path.

Method Index

 o denyConnection(ReceiverThread, String)
Error occurs from the connection process.
 o isRegisteredUser(String)
Check whether the user is registered.
 o isValidAgent(Object)
Implementation of agent validity checking.
 o processClientLogin(ReceiverThread, Address)
Opposite to the processServerLogin.
 o processClientLogout(ReceiverThread)
Send disconnect message to the connection.
 o processErrorLogin(int, ReceiverThread, String, String)
According to the error condition, the processErrorLogin will be performed.
 o processServerLogin(ReceiverThread)
Security check process from the RouterServerThread.
 o secureAgent(String, String, String, String)
Check the client send its name and the name is different from mine Password check will be performed if passwordCheckBit is set
 o setPasswordFilePath(String)
Set password file path.
 o setUserList(String)
Set user list using password file path
 o startConnection(ReceiverThread, String, String)
Start conneciton.
 o SystemOut(String)
System message output to the System.out.
 o unregisterAgent(Object)
Unregister Agent.
 o updateUserList(Address, String)
Update user list.

Variables

 o CLIENTOK
 public final int CLIENTOK
secureAgent() method will return if 'whoiam' information is correct

 o CLIENTNAMEMISSING
 public final int CLIENTNAMEMISSING
'whoiam' message does not include the client name

 o CLIENTSAMENAME
 public final int CLIENTSAMENAME
Client name is the same as the Router name. Connection will be denied

 o PASSWORDMISSING
 public final int PASSWORDMISSING
Connection needs password check, but 'whoiam' message does not include password

 o PASSWORDMISMATCH
 public final int PASSWORDMISMATCH
The agent password is not matched with its pssword

 o PASSWORDFILECORRUPTED
 public final int PASSWORDFILECORRUPTED
Password file is corrupted

 o NOCLIENTLIST
 public final int NOCLIENTLIST
The agent is not registered to the Router

 o NOTVALIDMESSAGEMETHOD
 public final int NOTVALIDMESSAGEMETHOD
The message-method is not understandable to the Router

 o WRONGROUTERNAME
 public final int WRONGROUTERNAME

Constructors

 o RouterSecurity
 public RouterSecurity()
Default constructor

 o RouterSecurity
 public RouterSecurity(AddressTable addresses,
                       String passfile,
                       String registryFile)
Constructor with AddressTable, password file path and registry file path. For beta version, password file should be passed even if you do not want to check password. In this case, passwor file will be used as quick reference of registered agents. This constructor will set passwordCheckBit to be true. If you do not want to check password, use next constructor. Registry file can be null if you do not want to retain registry information.

Parameters:
addresses - AddressTable
passfile - Password file path
registryFile - Registry file path
 o RouterSecurity
 public RouterSecurity(AddressTable addresses,
                       String passfile,
                       String registryFile,
                       boolean passwordCheckBit)
Constructor with AddressTable, password file path and registry file path. For beta version, password file should be passed even if you do not want to check password. In this case, passwor file will be used as quick reference of registered agents.

Parameters:
addresses - AddressTable
passfile - Password file path
registryFile - Registry file path
passwordCheckBit - Password check bit set. If you do not want to password check, pass this parameter as false.
 o RouterSecurity
 public RouterSecurity(AddressTable addresses,
                       String passfile)
Constructor with AddressTable and password file path. For beta version, password file should be passed even if you do not want to check password. In this case, passwor file will be used as quick reference of registered agents.

Parameters:
addresses - AddressTable
passfile - Password file path

Methods

 o setPasswordFilePath
 public void setPasswordFilePath(String passfile)
Set password file path. User list will be read and updated.

Parameters:
passfile - Password file path
 o setUserList
 protected void setUserList(String passfile)
Set user list using password file path

Parameters:
passfile - Password file path
 o processServerLogin
 public void processServerLogin(ReceiverThread con)
Security check process from the RouterServerThread. The connection is accepted and the security check is performed using this method. For error condition, the connection may be denied or the RouterServer may give one more chance to correct the wrong information such as agent name missing, password mismatch, etc. If the client agent satifies the connection protocol the conneciton will be added to the ConnectionTable and start to receive/send messages For both registration and connection, the lowest level connection protocol is:
Router : 201 AMR "Router name"
for the successful connection.

or Router : 500 Internal Error
for any error conditions.

Then, the Agent will request connection by sending "reconnect-agent" protocol.
For example,
Agent :(reconnect-agent :sender agent :receiver Router :password xxxx)
If the host/port is changed, Agent : (reconnect-agent :sender agent :receiver Rotuer :password xxxx :host new.host.com :port 4321)
The the Router will send
Router : (connection-accepted :sender Router :receiver agent)

Parameters:
con - RouterRecvThread, will be started
Overrides:
processServerLogin in class Security
 o processErrorLogin
 protected boolean processErrorLogin(int errorCode,
                                     ReceiverThread con,
                                     String myid,
                                     String agentid)
According to the error condition, the processErrorLogin will be performed. If the agent name is missing or if the agent name is the same as the Router name or if the password is missing(when passwordCheckBit is true) or if the password is mismatch(when passwordCheckBit is true), the Router will send 'ask-one' message to the agent. If the agent can correct the problem, the connection will be started. If not, the conneciton will be denied and closed.

Parameters:
errorCode - Error code which happens during connection process
con - RouterRecvThread, which wants to be connected
myid - The Router name
 o startConnection
 protected void startConnection(ReceiverThread con,
                                String agentid,
                                String myid)
Start conneciton. All the conneciton protocol is satisfied. Send 'accepted' message and add the conneciton to the ConnectionTable. This method set the ReceiverThread name as the same as the agent name.

Parameters:
con - ReceiverThread to be started
agentid - The agent name
myid - The Router name
 o denyConnection
 protected void denyConnection(ReceiverThread con,
                               String id)
Error occurs from the connection process. Send 'error' message to the agent and disconnect the conneciton

Parameters:
con - ReceiverThread to be disconnected
id - The Router name
 o secureAgent
 protected int secureAgent(String routerID,
                           String me,
                           String client,
                           String password)
Check the client send its name and the name is different from mine Password check will be performed if passwordCheckBit is set

Parameters:
me - My name, sent back from the client
client - The agent name
password - The agent Password
 o processClientLogin
 public void processClientLogin(ReceiverThread c,
                                Address serveraddress) throws ConnectionException
Opposite to the processServerLogin. The agent(me) wants to connect to the Router and it will send 'whoiam' message to the Router

Parameters:
c - ReceiverThread, which will connect to the Router
serveraddress - The Rotuer server address
Overrides:
processClientLogin in class Security
 o processClientLogout
 public void processClientLogout(ReceiverThread c)
Send disconnect message to the connection.

Parameters:
c - RouterRecvThread to be disconnected
Overrides:
processClientLogout in class Security
 o isValidAgent
 public boolean isValidAgent(Object o)
Implementation of agent validity checking. If the agent is registered agent and its password is correct,reutrn true

Parameters:
o - Object to be checked. For RouterSecurity, it is a string array, agent name and the password
Overrides:
isValidAgent in class Security
 o updateUserList
 public synchronized void updateUserList(Address addr,
                                         String password)
Update user list. Invoked by RegistrarSecurity object. Password file and Registry file will be updated

Parameters:
id - The agent name
password - The agent password
 o unregisterAgent
 public synchronized boolean unregisterAgent(Object o)
Unregister Agent. The password should be passed if password check is enforced. The user will be removed from Password and Registry file

Parameters:
o - String array,length two with agent name and its password
 o isRegisteredUser
 public boolean isRegisteredUser(String id)
Check whether the user is registered.

Parameters:
id - Agent name
Returns:
True if the agent is registered.
 o SystemOut
 public void SystemOut(String str)
System message output to the System.out. This method will be override if you want to use GUI

Parameters:
str - String will be displayed to the System.out or GUI

All Packages  Class Hierarchy  This Package  Previous  Next  Index