Threesuns

Email the Instructor

Contact

All Semesters

Semesters

All Courses

Courses

2011Fall

08.16.10 - 12.12.10

Advanced Java

CSYS2413

Thursday
05:30 PM - 08:20 PM

Chat

Lab05

Objective: To use the JSSE extension to perform secure network communications

pastdue

Submit Your Solution

Lab05

Request a Copy of your Solution

Lab05

Requirements

Comments placed in the source code file5 pts
Application placed in an executable JAR file5 pts
Client GUI created5 pts
Client can send secured data to server15 pts
Client can receive secured data from server15 pts
Server can send secured data to (multiple) clients15 pts
Server can receive secured data from (multiple) clients15 pts
JavaBeans used with bound properties and listener20 pts
Usernames are collected and used5 pts
Total100 pts

Instructions

For this lab you will create a secure multithreaded chat application. The application will be composed of two parts: a client and a server. The server will be primarily responsible for accepting incoming connections from clients and producing objects to handle the clients once they are connected. The client will be a GUI application that will allow a user to participate in an online chat, posting messages to the server, and seeing messages posted by other clients.

The server itself should be composed of three classes. The first will be the SecureChatServer class which will accept incoming connections from clients on port 7070 and will in response create a ClientHandler object (the second needed class) to receive incoming data from the client. The ClientHandler class should operate on its own thread so that it will not interfere with other clients connecting to the server. The third class needed on the server will be a JavaBean called ChatBean which will store data sent from any client. The property that stores the data from clients should be bound and every ClientHandler should be registered as a listener for this class so that every time a piece of data is received from a client all ClientHandlers will be notified and will send the new data to each client (every client receives every message).

The client will be made up of two classes. The first will be the SecureChatClient class which will create the GUI for the client to use, will handle events from the GUI, and will initiate communications with the server. The second client class will be a ServerListener which will operate on its own thread as it will need to continuously listen for data being sent from the server without interfering with the operation of the clients GUI. The ServerListener should be written as a JavaBean with a bound property in which will be stored any data coming from the server. The SecureChatClient will be a property listener for this property so that every time a new piece of data is received from the server by the ServerListener it will fire and event which the SecureChatClient will then be notified of so that it can then post that new information in a textarea.

The flow of the system should go like this:

  1. The server starts up and begins listening for connections on port 7070
  2. A client starts up and contacts the server
  3. The client spawns a ServerListener which then listens continuously for data being sent from the server
  4. The client registers itself with the ServerListener as a property listener
  5. In response to the new connection the server spawns a new ClientHandler for that client which then listens for further data coming from that client
  6. The server registers the ClientHandler with the ChatBean as a property listener
  7. The user types a message into a textfield in the SecureChatClients GUI and presses a send button or the enter key
  8. The SecureChatClient sends the message that the user typed to the server
  9. The ClientHandler for that client received the message the user sent and sets it in the chat bean
  10. The chat bean fires an event to all the ClientHandlers telling them that there is new data in the bean
  11. Each ClientHandler, when notified of the new data in the ChatBean, gets that data and sends it to the client it is responsible for
  12. The ServerListener for the client receives the new data that is sent from the server and sets it in its own bound property, causing an event to fire
  13. The listening client, when notified of the new data in the ServerListener bean, will get that new data and display it in a textarea in the GUI for the user to see

All communications traveling between the client and the server should be over SSL connections, providing secure communications.

Every user chatting on the system should be able to supply a username which should then be displayed to all clients with every message they send. The client should also include a Close button which will terminate that clients communications with the server in a way that does not crash the server (or client I hope) so that users may close their own clients leaving the server available for others to continue using.

The server does not require an interface of any type but output to the command line will certainly help with debugging.