Skip to content

gsilva00/CPD-Project2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Secure Chat Application

This is a secure multi-threaded chat application with AI integration using Ollama. The application supports multiple chat rooms, user authentication, SSL/TLS encryption, and AI assistants in select rooms. It features connection resilience to handle network disruptions gracefully.

How to Run the Application

  1. Setup and Compilation

    make all
  2. Run Individual Components

    To run the SSL setup script only:

    make run_ssl_setup

    To run the server (SSL setup will run first):

    make run_server

    To run a client (SSL setup will run first):

    make run_client
  3. Run the Complete Stack (SSL setup, Server, and Client) - EXTRA (EXCLUSIVE TO MACOS)

    make run_all

    This will:

    • Run the SSL setup to generate security credentials
    • Start the server in a new terminal window
    • Start a client in another terminal window

User Commands

Once connected to the server, users can use the following commands:

  • /join <room> - Join or create a chat room
  • /ai <room> <prompt> - Create an AI room with custom prompt
  • /rooms - List available rooms
  • /logout - Logout from the server
  • /help - Show help message with available commands
  • Just type to send a message to the current room

System Overview

The application follows a client-server architecture with the following key components:

1. Server

The server (Server.java) manages:

  • User authentication and registration
  • Chat room management
  • Client connections and message handling
  • Secure communication via SSL/TLS
  • Integration with Ollama for AI-powered chat rooms
  • Session management for connection resilience and state preservation

2. Client

The client (Client.java) provides:

  • User authentication (login/registration)
  • Room selection
  • Message sending and receiving
  • Secure communication with the server via SSL/TLS
  • Automatic reconnection when connections break
  • State persistence across reconnections

3. Chat Rooms

Chat rooms (ChatRoom.java) feature:

  • Regular rooms for human-to-human communication
  • AI-powered rooms with Ollama integration
  • Message history tracking
  • Concurrent access handling with read/write locks
  • State persistence for rejoining after disconnection

4. Session Management

The session management system (SessionManager.java) provides:

  • Token-based authentication for reconnection without credentials
  • User state preservation across connection breaks
  • Automatic token expiration for security
  • Room state tracking and restoration after reconnection

5. SSL Security

Security is provided through SSL/TLS using:

  • SSLSetupScript.java: Generates the necessary keystores and truststores
  • Server certificate export and client trust configuration

6. AI Integration

The Ollama integration (OllamaConnection.java) provides:

  • Contextual conversation support
  • Custom system prompts for specialized AI assistants

Requirements

  • Java SE 21 or higher (for virtual threads)
  • Ollama running locally (for AI features)
  • macOS for the full run_all script (uses osascript for terminal management)

SSL Configuration

The SSL setup script generates:

  • A server keystore (serverkeystore.jks)
  • A server certificate (server.cer)
  • A client truststore (clienttruststore.jks)

All with the default password: "password"

About

FEUP L.EIC 2024/25 - 3rd Year, 2nd Semester - 2nd Project developed in the Parallel and Distributed Computing curricular unit

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •