Package ChatRoom and its sub-packages implement a simple chat room with client/server, multicast, and secure variations. All the executable classes (main() functions) for chat room clients and servers are in this package. The sub-packages contain various library classes. The secure versions rely on the Celbercor and FlamingSword packages, which contain executable classes for the various authentication servers and password managers that they need.

Table of contents

Design of the core chatroom classes

Large class diagram in abbreviated UML. [>]
Meaning of arrows, etc. in abbreviated UML [>]

The design of these packages is as follows:

Client/Server Model

Large picture of the flow of messages in the client/server model [>]

The client/server chatroom system centers on classes ChatRoom.Server.ThreadedServer and ChatRoom.Client.Client. The server process waits for connections, and for each one, creates (1) a Writer, which can be used to send a message to the client, and (2) a new thread which uses a Reader to get any messages the client sends. When a message arrives at a reader, that thread passes it to each of the writers to be delivered. To start a server process, use the main() function in ChatRoom.ThreadedServer.

The client process contacts the server. At the heart of it is the Client class. A client process creates a Client and installs in it a Reader, a Writer, and a MessageHandler. The main thread normally calls the run() method on the Client object, which causes it to enter an infinite loop where it waits for messages to come from the reader and sends them to the message handler. The handler normally shows messages on the screen somehow. Another thread in the client must wait for the user to type a message, which goes to the client object and to the writer, and from there to the network.

The MonitorClient installs a message handler that prints out all messages it receives and never actually sends any messages. It's used mostly to monitor a server and be sure it's working properly. To start one, use the main() function in ChatRoom.MonitorClient.

The GUI client in class ChatRoom.GUI.SimpleUI can send and receive messages. Its main thread receives messages and shows them in a TextArea. The AWT event handling mechanism runs in its own thread and is therefore able to send messages at any time. To start a GUI client, use the main() function in ChatRoom.SClient. (The "s" means "Server Client" as opposed to "Multicast Client".)

All network communication in this system is done over reliable TCP/IP connections (over plain java.net.Socket connections) so it can use the powerful java.io stream library.

Multicast Model

Large picture of the flow of messages in the multicast model [>]

The multicast chat room system works without a server. An IP router can be instructed to send packets directed at multicast addresses to any number of hosts. It can do all the work the server did before.

The clients work exactly the same in this model, except that they use different reader and writer classes. Since multicasting has to be done by datagrams instead of TCP, we can no longer just use the java.io streams directly on top of a Socket. Instead, messages are read to and written from datagrams, and for simplicity, messages can be no longer than can fit into a single datagram. Each client announces to the router that it would like to receive messages from a particular multicast address and port. When it needs to send a message, it sends it to that address and port, and the router forwards it to everyone else who has joined that group. To start one of these clients, use the main() function in ChatRoom.MClient.

Security Extensions

Package Celbercor.Security includes several classes that allow you to create a secure chat room. Among them are reader and writer classes that can deal with "sealed objects," or messages that have been serialized and encrypted. There are also reader and writer classes that can deal with "signed" objects, which are messages that come with a nonce, or secret signature; such readers reject any message they see with the wrong signature. There is a SecureServer class, which takes a ServerAuthentication object and uses it to verify that all clients have the proper authentication. The SecureClient class isn't really a class. It has a static method that covers up some of the dirty work of authentication. It uses a ClientAuthentication object to do most of the real work. The interfaces ServerAuthentication and ClientAuthentication are façades over the underlying authentication protocol.

The chat room package makes use of two additional packages to provide authentication and security. Using them, the server and clients can confirm that messages are from the user they claim to be from, and intact (not altered during transmission). Furthermore, the clients and server can encrypt messages before sending them, ensuring that no one else who might possibly intercept the transmission can read them.

The Celbercor package provides authentication and encryption using a protocol very similar to Kerberos.

The Flaming Sword package provides authentication and encryption using public key/private key encryption.

Each of these packages has a parallel sub-package within ChatRoom that contains concrete implementations of ServerAuthentication and ClientAuthentication. The main() functions in CelbercorClient, CelbercorServer, FlamingSwordClient, and FlamingSwordServer glue everything together.

List of executable classes (main() functions)

See the main() function in each of these classes for documentation on how to run them. The secure versions assume that appropriate authentication servers are already running.
Simple client/server model
Server
ThreadedServer
Monitor client
MonitorClient
Graphical client
SClient
Multicast model
Graphical client
MClient
Secure chat room
Celbercor server
CelbercorServer
Graphical Celbercor client
CelbercorClient
Flaming Sword server
FlamingSwordServer
Graphical Flaming Sword client
FlamingSwordClient

Last modified: Tue Jun 29 15:15:52 EDT 1999