Skip to main content

Setup & Build

This page walks through everything needed to build and run the project from scratch.


Prerequisites

ToolMinimum VersionCheck Command
Java JDK17java -version
Apache Maven3.8mvn -version
keytool(bundled with JDK)keytool -help
Bash (Linux/macOS) or cmd.exe (Windows)

Ensure JAVA_HOME is set and both java and mvn are on your PATH.


Step 1 — Generate TLS Certificates

Run once from the secure-dfs/ directory:

# Linux / macOS
chmod +x scripts/generate-certs.sh
./scripts/generate-certs.sh
REM Windows
scripts\generate-certs.bat

Creates:

certs/
├── ca.jks # Certificate Authority keypair
├── truststore.jks # Shared truststore (everyone trusts the CA)
├── auth.jks # AuthService identity
├── node0.jks # ReplicaNode0 identity
├── node1.jks # ReplicaNode1 identity
├── node2.jks # ReplicaNode2 identity
└── client.jks # Client identity

All passwords: changeit


Step 2 — Build

cd secure-dfs
mvn clean package

Expected: BUILD SUCCESS

Produces 6 JARs in target/:

JAREntry PointDescription
secure-dfs-1.0-auth.jarAuthMainSecure authentication service
secure-dfs-1.0-node.jarNodeMainSecure replica node
secure-dfs-1.0-client.jarClientMainSecure interactive client
secure-dfs-1.0-vuln-auth.jarVulnerableAuthMainVulnerable auth (no TLS)
secure-dfs-1.0-vuln-node.jarVulnerableNodeMainVulnerable node (no TLS, no auth)
secure-dfs-1.0-vuln-client.jarVulnerableClientMainVulnerable client (no TLS)

Step 3 — Run the Secure Stack

Open 5 separate terminals, all in secure-dfs/:

Terminal 1 — AuthService

java -jar target/secure-dfs-1.0-auth.jar
AuthService bound to RMI registry on port 1098

Terminals 2–4 — Replica Nodes

# Terminal 2
java -jar target/secure-dfs-1.0-node.jar 0 1099

# Terminal 3
java -jar target/secure-dfs-1.0-node.jar 1 1100

# Terminal 4
java -jar target/secure-dfs-1.0-node.jar 2 1101

Wait ~3 seconds for Raft election. One node will print: Raft role → LEADER.

Terminal 5 — Client

java -jar target/secure-dfs-1.0-client.jar

Step 4 — Test the System

--- Not logged in ---
1. Register
2. Login
3. Exit

Choice: 1
Username: jana
Password: mypassword123
[OK] Registered and logged in.

--- Logged in ---
1. Upload file 4. Rename file
2. Download file 5. Search files
3. Delete file 6. List all files
7. Logout
8. Exit

Choice: 1
Local file path: /home/jana/Documents/report.pdf
Remote filename: report.pdf
[OK] File uploaded successfully.

Choice: 6
[OK] 1 file(s):
- report.pdf

Verify Replication

ls storage/node0/
ls storage/node1/
ls storage/node2/

All three directories should contain report.pdf.

Verify Atomic Consistency (Two Clients)

Open a second client terminal. Login from both. Upload different files simultaneously:

# Terminal A
java -jar target/secure-dfs-1.0-client.jar
# login → upload fileA.txt

# Terminal B (at the same time)
java -jar target/secure-dfs-1.0-client.jar
# login → upload fileB.txt

Check all three storage directories — files appear in the same order on every node.


Step 5 — Stopping

Press Ctrl+C in each terminal.

Clean up:

rm -rf storage/
mvn clean

Troubleshooting

SymptomCauseFix
java.rmi.ConnectExceptionServices not started yetStart AuthService before nodes, nodes before client
javax.net.ssl.SSLHandshakeExceptionCertificates missingRun ./scripts/generate-certs.sh first
java.security.KeyStoreExceptionWrong passwordAll passwords must be changeit
BUILD FAILUREWrong Java versionInstall JDK 17+
Port already in usePrevious run still holding portfuser -k 1099/tcp (Linux)

Next: → Attack Demonstrations