A multi-threaded chat application with JWT authentication, AES encryption, and MongoDB storage.
- JWT Authentication - Stateless tokens with HMAC256 signing, 24-hour expiration
- Password Encryption - AES-encrypted passwords, never stored in plain text
- AES Message Encryption - All messages encrypted with AES-256 before transmission
- HMAC Message Integrity - Verifies messages haven't been tampered with
- Secure MongoDB Connection - Encrypted connections, credentials in
.envfile - Thread-Safe Architecture - CopyOnWriteArrayList, separate thread per client
- User registration and login with JWT tokens
- Real-time encrypted messaging between multiple clients
- Message history sent to new clients when they join
- Automatic message broadcasting to all connected users
- Session persistence via JWT token file storage
Create .env in the ca1_group_k directory:
JWT_SECRET_KEY=your_secret_key_here
MONGODB_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongodb.net/?appName=YourApp
MONGODB_DATABASE_NAME=YourDatabaseName
AES_SECRET_KEY=MTIzNDU2Nzg5MDEyMzQ1Ng==
HMAC_SECRET_KEY=your_super_secret_key_at_least_32_characterscd ca1_group_k
mvn compile exec:java -Dexec.mainClass="nci.security_fundamentals.server.ChatServer"cd ca1_group_k
mvn compile exec:java -Dexec.mainClass="nci.security_fundamentals.client.Main"- Choose Register (1) or Login (2)
- Enter credentials
- Start sending encrypted messages
Prerequisites: Java 21+, Maven 3.6+, MongoDB Atlas account