Skip to content

Repository files navigation

Secure Authentication System

A comprehensive JavaFX-based secure authentication system written in Java with Maven, featuring password strength checking, secure password hashing, and optional encryption utilities.

Features

πŸ” Core Security Features

  • Password Hashing: PBKDF2-based password hashing with random salt generation and 65536 iterations
  • Password Strength Checking: Real-time password strength analysis with detailed requirements
  • Secure Login: User authentication with secure credential verification
  • Encryption Utility: AES-256 symmetric encryption for optional data protection
  • Constant-Time Comparison: Protection against timing attacks

🎨 User Interface

  • Modern, professional GUI with gradient purple theme
  • Real-time password strength meter with color coding
  • Password visibility toggle button (πŸ‘ eye icon)
  • Registration form with requirements validation
  • User-friendly login interface
  • Live password requirement feedback
  • Emoji indicators for clear feedback (βœ“, βœ—, ⚠)

🎨 GUI Improvements (v1.0.1)

The interface has been enhanced with modern design elements:

  • Gradient Background: Beautiful purple gradient for professional appearance
  • Password Visibility: Toggle button to show/hide password while typing
  • Color-Coded Strength: Real-time visual feedback with vibrant colors
  • Styled Components: Rounded corners, shadows, and modern styling
  • Clear Feedback: Success (green βœ“), Error (red βœ—), and Warning (orange ⚠) indicators
  • Better Typography: Segoe UI font with proper hierarchy
  • Improved Layout: Better spacing and alignment throughout
  • Responsive Design: Proper sizing for all screen sizes

See GUI_IMPROVEMENTS.md for detailed visual improvements and design details.

Project Structure

Secure Authentication System/
β”œβ”€β”€ pom.xml
β”œβ”€β”€ README.md
└── src/
    β”œβ”€β”€ main/java/com/authentication/
    β”‚   β”œβ”€β”€ app/
    β”‚   β”‚   └── SecureAuthApp.java
    β”‚   β”œβ”€β”€ security/
    β”‚   β”‚   β”œβ”€β”€ PasswordHasher.java
    β”‚   β”‚   β”œβ”€β”€ PasswordStrengthChecker.java
    β”‚   β”‚   β”œβ”€β”€ EncryptionUtility.java
    β”‚   β”‚   └── AuthenticationService.java
    β”‚   └── ui/
    β”‚       └── LoginController.java
    └── test/java/com/authentication/security/
        β”œβ”€β”€ PasswordHasherTest.java
        β”œβ”€β”€ PasswordStrengthCheckerTest.java
        β”œβ”€β”€ EncryptionUtilityTest.java
        └── AuthenticationServiceTest.java

Technologies Used

  • JavaFX 21.0.1: Modern UI framework for desktop applications
  • Java 11+: Core language and runtime
  • Maven: Build automation and dependency management
  • Bouncy Castle: Cryptographic operations
  • SLF4J: Logging framework
  • Apache Commons Codec: Base64 encoding/decoding

Requirements

  • Java Development Kit (JDK) 11 or higher
  • Maven 3.6.0 or higher
  • JavaFX SDK 21.0.1

Installation & Setup

1. Clone or Download the Project

cd "Secure Authentication System"

2. Build the Project

mvn clean install

3. Run the Application

Using Maven:

mvn javafx:run

Using Java directly:

mvn package
java -jar target/secure-auth-system-1.0.0-shaded.jar

Usage

Running the Application

  1. Launch the application using one of the methods above
  2. A login/registration window will appear

Registration

  1. Switch to the "Register" tab
  2. Choose a username
  3. Enter a password:
    • Minimum 8 characters
    • Include uppercase letters (A-Z)
    • Include lowercase letters (a-z)
    • Include numbers (0-9)
    • Include special characters (!@#$%^&*)
  4. The password strength meter provides real-time feedback
  5. Confirm your password and click "Register"

Login

  1. Stay on the "Login" tab
  2. Enter your registered username
  3. Enter your password
  4. Click "Login"
  5. Success message displays upon successful authentication

API Usage

Password Hashing

import com.authentication.security.PasswordHasher;

// Hash a password
String hashedPassword = PasswordHasher.hashPassword("MyPassword123!");

// Verify a password
boolean isValid = PasswordHasher.verifyPassword("MyPassword123!", hashedPassword);

Password Strength Checking

import com.authentication.security.PasswordStrengthChecker;
import com.authentication.security.PasswordStrengthChecker.StrengthLevel;

// Check password strength
StrengthLevel strength = PasswordStrengthChecker.checkStrength("Password123!");

// Get requirements message
String requirements = PasswordStrengthChecker.getRequirementsMessage("weak");

Encryption Utility

import com.authentication.security.EncryptionUtility;

// Generate a key
String key = EncryptionUtility.generateKey();

// Encrypt data
String encrypted = EncryptionUtility.encrypt("Sensitive Data", key);

// Decrypt data
String decrypted = EncryptionUtility.decrypt(encrypted, key);

Authentication Service

import com.authentication.security.AuthenticationService;

AuthenticationService service = new AuthenticationService();

// Register a user
service.registerUser("john_doe", "SecurePassword123!");

// Authenticate a user
boolean authenticated = service.authenticateUser("john_doe", "SecurePassword123!");

// Check current user
String currentUser = service.getCurrentUser();

// Change password
service.changePassword("john_doe", "SecurePassword123!", "NewPassword456!");

// Logout
service.logout();

Security Considerations

  1. Password Hashing: Uses PBKDF2 with SHA-256, 65536 iterations, and 32-byte salt
  2. Timing Attack Prevention: Constant-time comparison for password verification
  3. Encryption: AES-256 symmetric encryption for data protection
  4. Random Salt: Each password gets a unique salt
  5. Logging: Security events are logged for audit purposes

Running Tests

# Run all tests
mvn test

# Run specific test class
mvn test -Dtest=PasswordHasherTest

# Generate test coverage report
mvn test jacoco:report

Password Strength Levels

  • Very Weak (Score 0): Insufficient length and character diversity
  • Weak (Score 1-3): Limited character variety
  • Fair (Score 2-5): Decent length and reasonable character mix
  • Good (Score 3-7): Strong password with good practices
  • Strong (Score 4-9): Very secure password
  • Very Strong (Score 5+): Excellent security with all requirements met

Logging

The application uses SLF4J for logging. Logs are configured to output to the console by default. Log level can be controlled by:

  1. Creating a logback.xml file in src/main/resources/
  2. Or setting the system property: -Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG

Maven Commands

# Clean build
mvn clean

# Compile source code
mvn compile

# Run tests
mvn test

# Package application
mvn package

# Install locally
mvn install

# View dependency tree
mvn dependency:tree

# Run JavaFX application
mvn javafx:run

Troubleshooting

Issue: Module not found errors

Solution: Ensure all dependencies are downloaded with:

mvn dependency:resolve

Issue: JavaFX modules not recognized

Solution: Add JavaFX VM options if running from IDE:

--module-path /path/to/javafx-sdk/lib --add-modules javafx.controls,javafx.fxml

Issue: Port already in use

Solution: The application uses local in-memory storage and doesn't bind to network ports.

Future Enhancements

  • Database integration for persistent user storage
  • Two-factor authentication (2FA)
  • Session management and token-based authentication
  • OAuth2/OIDC integration
  • Password reset functionality
  • User profile management
  • Audit logging and activity tracking
  • Admin dashboard
  • Multi-language support
  • HTTPS/TLS support for network operations

License

This project is provided as-is for educational and development purposes.

Support

For issues, questions, or contributions, please refer to the project documentation or create a ticket in your issue tracker.

Author

Created as a comprehensive secure authentication system demonstration.


Last Updated: January 2026 Version: 1.0.0

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages