To use the JSSE extension to perform secure network communications
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:
- The server starts up and begins listening for connections on port 7070
- A client starts up and contacts the server
- The client spawns a ServerListener which then listens continuously for data being sent from the server
- The client registers itself with the ServerListener as a property listener
- 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
- The server registers the ClientHandler with the ChatBean as a property listener
- The user types a message into a textfield in the SecureChatClients GUI and presses a send button or the enter key
- The SecureChatClient sends the message that the user typed to the server
- The ClientHandler for that client received the message the user sent and sets it in the chat bean
- The chat bean fires an event to all the ClientHandlers telling them that there is new data in the bean
- Each ClientHandler, when notified of the new data in the ChatBean, gets that data and sends it to the client it is responsible for
- 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
- 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.