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,
- Agent send message to the Router
(reconnect-agent :sender agent :receiver Router :password xxxx)
- Router will respond
(connection-accepted :sender Router :receiver agent)
or
(error :sender Router :receiver agent :content (error-content))
if error occurs.
-
CLIENTNAMEMISSING
- 'whoiam' message does not include the client name
-
CLIENTOK
- secureAgent() method will return if 'whoiam' information is correct
-
CLIENTSAMENAME
- Client name is the same as the Router name.
-
NOCLIENTLIST
- The agent is not registered to the Router
-
NOTVALIDMESSAGEMETHOD
- The message-method is not understandable to the Router
-
PASSWORDFILECORRUPTED
- Password file is corrupted
-
PASSWORDMISMATCH
- The agent password is not matched with its pssword
-
PASSWORDMISSING
- Connection needs password check, but 'whoiam' message does not include password
-
WRONGROUTERNAME
-
-
RouterSecurity()
- Default constructor
-
RouterSecurity(AddressTable, String)
- Constructor with AddressTable and password file path.
-
RouterSecurity(AddressTable, String, String)
- Constructor with AddressTable, password file path and registry file path.
-
RouterSecurity(AddressTable, String, String, boolean)
- Constructor with AddressTable, password file path and registry file path.
-
denyConnection(ReceiverThread, String)
- Error occurs from the connection process.
-
isRegisteredUser(String)
- Check whether the user is registered.
-
isValidAgent(Object)
- Implementation of agent validity checking.
-
processClientLogin(ReceiverThread, Address)
- Opposite to the processServerLogin.
-
processClientLogout(ReceiverThread)
- Send disconnect message to the connection.
-
processErrorLogin(int, ReceiverThread, String, String)
- According to the error condition, the processErrorLogin will be performed.
-
processServerLogin(ReceiverThread)
- Security check process from the RouterServerThread.
-
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
-
setPasswordFilePath(String)
- Set password file path.
-
setUserList(String)
- Set user list using password file path
-
startConnection(ReceiverThread, String, String)
- Start conneciton.
-
SystemOut(String)
- System message output to the System.out.
-
unregisterAgent(Object)
- Unregister Agent.
-
updateUserList(Address, String)
- Update user list.
CLIENTOK
public final int CLIENTOK
- secureAgent() method will return if 'whoiam' information is correct
CLIENTNAMEMISSING
public final int CLIENTNAMEMISSING
- 'whoiam' message does not include the client name
CLIENTSAMENAME
public final int CLIENTSAMENAME
- Client name is the same as the Router name. Connection will be denied
PASSWORDMISSING
public final int PASSWORDMISSING
- Connection needs password check, but 'whoiam' message does not include password
PASSWORDMISMATCH
public final int PASSWORDMISMATCH
- The agent password is not matched with its pssword
PASSWORDFILECORRUPTED
public final int PASSWORDFILECORRUPTED
- Password file is corrupted
NOCLIENTLIST
public final int NOCLIENTLIST
- The agent is not registered to the Router
NOTVALIDMESSAGEMETHOD
public final int NOTVALIDMESSAGEMETHOD
- The message-method is not understandable to the Router
WRONGROUTERNAME
public final int WRONGROUTERNAME
RouterSecurity
public RouterSecurity()
- Default constructor
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
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.
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
setPasswordFilePath
public void setPasswordFilePath(String passfile)
- Set password file path. User list will be read and updated.
- Parameters:
- passfile - Password file path
setUserList
protected void setUserList(String passfile)
- Set user list using password file path
- Parameters:
- passfile - Password file path
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
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
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
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
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
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
processClientLogout
public void processClientLogout(ReceiverThread c)
- Send disconnect message to the connection.
- Parameters:
- c - RouterRecvThread to be disconnected
- Overrides:
- processClientLogout in class Security
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
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
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
isRegisteredUser
public boolean isRegisteredUser(String id)
- Check whether the user is registered.
- Parameters:
- id - Agent name
- Returns:
- True if the agent is registered.
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