CV | My profile | Photo gallery
Doctor's Appointment
 Matlab interface
Visual Basic
How to use


DevelopmentJavaChat room


The chat room was implemented using the package with 4 classes namely: ChatClient, ChatServer, ChatHandler, and CryptoSystem.


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 keys respectively.

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 service

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.

Group privacy

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.


Module testing

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 our CrytoSystem.

Product testing

Case Testing Bug Correction/Coment
Registered users chating Alice and Bob were logged in in the same room, sent messages 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() method
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 in. NO bugs: Right error message displayed  
Wrong user Smith was logged with incorrect private keys several times. Sometimes the correct message was logged but at times Smith was logged Because the keys we made short these security holes wer expected.
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 logged in!!"  
Single user but multiple logins in different room With Alice already in room 1, John was the logged into room 2. 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.  
Message disclosure Bob and Alice logged in room 1 and Smith and John in room NO: bugs: Alice only saw messages from herself and Bob while Smith only saw messages from John and himself.  


Registered users and their keys

User name Public keys private key 1 private key 2 private key 3
Alice 15, 5 3 5 5
Bob 21, 5 3 7 5
Smith 35, 5 5 7 5
Jack 77, 7 7 11 43
Jill 55, 7 5 11 23
John 143, 7 11 13 103


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.