The chat room was implemented using the java.net package
with 4 classes namely: ChatClient, ChatServer, ChatHandler,
This classs acts as the main server for our chat rooms. Our
server has a maximun of 6 clients and two rooms as specified
on the requirements.
This class was adapted from Dr. Kui 's sample code. A few
methods were added for house keeping purposes. ChatRoomFull
(int room), registered (String name), getPublicKeyPQ(String
user), and getPublicKeyE (String user) methods were added
to check if the specified chat room is full, check if the
specified user is registered, and to return a user's public
ChatServer class basically listens to a port (specified on
the command line) for clients. If a client makes a request,
the server accepts the client and assigns a ChatHandler to
the client, passing the socket assigned to the client and
server's socket to the handler. The server then continues
to listens for other clients while the handler deals with
the accepted client. Our server has a display (text area)
where all the message from the handler are displayed.
This is probably the heart of a chatroom. After been accepted,
the client sends a login message using the protocol specified
on the requirements.
The handler first checks if the user is registered, and goes
through the authentication procedure described in the requirements.
In addition to the error described on the requirements, the
handler sends a "Please login" message to client,
and closes the clients' GUI if the client was not properly
authenticated but still tries to use our services.
Tracking number clients
If a client was successfully aunthenticated, the handler
increments the number of users in the room the client is in
and sets itself to active. This feature is used to help determine
acurrately how many clients are in each room. So when a clients
leaves a chat room we can update the number clients remaining,
but when a client that was not logged in leaves we would not
do any updating since their handler was not active.
Single user and multiple logins, and denial of
Our server can only support six clients and each room can
only support 3 users, so if one user logs in (opens several
windows) into the same room several times concurrently, then
other users may not be able to use the chat room bacause it
will be full. To combat this problem, our handler checks if
the user is not alreadly logged in during authentication,
and then displayes error "The user: "user+ "is
already logged in!!" if user was already loggeg in. The
users request is therefore denied. A client can, however,
join both chat rooms concurrently as required.
Even though each room has a unique key to ensure message
disclosure, it was decided in addition to the group key, it
would be more convenient if the message was only broadcasted
to users in the same room.
The ChatClient classs has display and text input area where
the user can read incoming messages and send messages respectively.
The class takes in the name of the server you want to connect,
the server port number, user name, room number, and the user's
private keys at the command line when invoking the class.
The user is then authenticated as described on the requirements.
If an error was encounted, it is displayed, and the GUI is
closed if the user tries to use the program anyhow.
As described in the requirement our chat room uses the Caeser
cipher encryption methods for encrypting (and decrypting)
plain messages between users, and use the RSA encryption for
control messages between a client and our server. The CryptoSystem
class implements these encryption methods. It should noted
that since the keys were made short (to speed up execution)
the encryption is no that secure.
The classes were first tested independently (module testing).
The ServerTester class used for testing the newmly added methods
to our server wheares the CrytoTester was used for testing
| Registered users chating
||Alice and Bob were logged in in the same room, sent
||A character (space or cariage return) appeared at the
end of each message
||Messages to be encrypted or decrypted were trimmed to
remove leading or trailing spaces using the string trim()
|User not registered
||An unregistered user "Chris" was used try
to login into our char room.
||NO bugs: The correct error message "The User: Chris
has not registered!" was returned
|Chat room full
||With 3 users (Alice, Bob, John) already logged into
a single room, a fourth user (Jill) then tried to log
||NO bugs: Right error message displayed
||Smith was logged with incorrect private keys several
||Sometimes the correct message was logged but at times
Smith was logged
||Because the keys we made short these security holes
|Single user but multiple logins in same room
||With John already in room 1, John was the logged into
room 1 again.
||NO bugs: Correct error message "John "is already
|Single user but multiple logins in different room
||With Alice already in room 1, John was the logged into
||NO bugs: Alice successfully into room 2
|Successful login followed by wrong user
||With Alice already in room 1, Alice was agin logged
in but with incorrect private keys
||NO: bugs: Correct error message "You are not Alice"
was returned, not "Alice"is already logged in!!"
|Wrong user followed by successful login
||Bob was tried to login in with incorrect private keys,
and loggeg with the right keys
||NO: bugs: Correct error message "You are not Bob"
was returned and NO "Alice"is already logged
in!!" message was returned on next login.
||Bob and Alice logged in room 1 and Smith and John in
||NO: bugs: Alice only saw messages from herself and Bob
while Smith only saw messages from John and himself.
Registered users and their keys
||private key 1
||private key 2
||private key 3
How to run the chat room:
To start a chat server, you enter the
following line in a Command window:
% java ChatServer portNumber
For example: % java ChatServer 12345
To start a client, you enter:
% java ChatClient server_IP_Address:portNumber
chatRoomNum userName <privateKeys>
For example: % java ChatClient localhost:12345
1 Alice 3:5:5
An Important Note!
After each test, it is very important to remove the
processes of chatServer and chatClient. Start the Task Manager
in Windows, and kill each process explicitly.