Skip to content

Latest commit

 

History

History
454 lines (343 loc) · 14.7 KB

File metadata and controls

454 lines (343 loc) · 14.7 KB

🔐 Java Authentication System - Enhanced Security Edition

Java MVC Security License

A comprehensive console-based authentication system with role-based access control, built following MVC architecture principles.

FeaturesInstallationUsageArchitectureSecurity


📋 Table of Contents


🛠️ Recent Updates

Complete System Overhaul (Latest Release - v2.0)

  • 🔧 Full professional deep corrections - Every file professionally corrected and enhanced
  • 🎯 Advanced Notification System - Complete notification management with priorities and categories
  • 🗄️ Professional Backup Management - Enterprise-grade backup and recovery operations
  • 🏗️ Enhanced Architecture - Full MVC implementation with professional error handling
  • Complete Service Layer - NotificationService and BackupRecoveryService fully implemented
  • 🔐 Robust Permission System - Role-based access control throughout all features
  • 🧹 Zero Compilation Errors - Entire codebase compiles and runs flawlessly

🔄 Professional Enhancements Completed

🔔 NotificationController & NotificationService

  • Complete notification management system with 6 main features
  • Advanced filtering: View all, unread only, urgent notifications
  • Administrative capabilities: Create and broadcast notifications
  • Professional UI: Unread counters, priority indicators, notification aging
  • Full integration: User permissions, notification archiving, cleanup utilities
  • Notification types: Security alerts, login events, system maintenance, user changes

💾 BackupController & BackupRecoveryService

  • Enterprise backup operations: Full, Incremental, Emergency backup types
  • Advanced restore capabilities: Point-in-time recovery with safety confirmations
  • Backup verification: Integrity checking and metadata validation
  • Maintenance tools: Expired backup cleanup, specific deletion capabilities
  • Professional interface: Progress tracking, detailed status reporting
  • Async operations: CompletableFuture-based operations with timeout handling

🗃️ BackupMetadata Model

  • Advanced metadata tracking: Encryption, compression, retention policies
  • Status management: Complete backup lifecycle tracking
  • Professional display: Formatted file sizes, duration calculations
  • Quality improvements: Switch expressions, final fields, proper annotations

👤 AuthController Enhancements

  • Complete user management: Profile viewing, password changes, statistics
  • Administrative features: User creation, deletion, role management
  • Professional error handling: Comprehensive validation and feedback
  • Security integration: Permission checks throughout all operations

🚀 Features

🔐 Authentication & Authorization

  • ✅ Secure user registration with data validation
  • ✅ User login/logout with session management
  • ✅ Role-Based Access Control (RBAC)
  • ✅ Account lockout protection after failed attempts
  • ✅ Password strength validation

👤 User Management

  • ✅ Comprehensive user profile management
  • ✅ User search and filtering capabilities
  • ✅ Account activation/deactivation
  • ✅ Role assignment and modification
  • ✅ User deletion with confirmation

Advanced Notification System (NEW)

  • ✅ Multi-priority notification management (Low, Medium, High, Critical)
  • ✅ Comprehensive notification types (Security, Login, System, Maintenance)
  • ✅ Unread notification tracking with counters and aging
  • ✅ Administrative notification creation and broadcasting
  • ✅ Notification archiving and cleanup utilities
  • ✅ Urgent notification alerts and real-time status display

💾 Enterprise Backup & Recovery (NEW)

  • ✅ Multiple backup types (Full, Incremental, Emergency)
  • ✅ Advanced backup metadata with encryption and compression
  • ✅ Point-in-time system restore with safety confirmations
  • ✅ Backup integrity verification and status monitoring
  • ✅ Automated backup cleanup and retention management
  • ✅ Async backup operations with progress tracking

�📊 System Administration

  • ✅ Real-time system statistics and health monitoring
  • ✅ Audit logging and security reports
  • ✅ Login history tracking and user analytics
  • ✅ Backup system status and management
  • ✅ Notification system statistics and cleanup

🛡️ Security Features

  • ✅ Input validation and sanitization
  • ✅ Failed login attempt tracking
  • ✅ Account lockout mechanisms
  • ✅ Permission-based access control
  • ✅ Secure password handling

🏗️ Architecture

This project follows the MVC (Model-View-Controller) design pattern with clear separation of concerns:

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│      VIEW       │◄──►│   CONTROLLER    │◄──►│      MODEL      │
│                 │    │                 │    │                 │
│ • ConsoleView   │    │ • AuthController│    │ • User          │
│ • User Interface│    │ • Business Logic│    │ • UserDatabase  │
│ • Input/Output  │    │ • Flow Control  │    │ • Data Storage  │
└─────────────────┘    └─────────────────┘    └─────────────────┘
                                │
                                ▼
                       ┌─────────────────┐
                       │    SERVICES     │
                       │                 │
                       │ • PermissionSvc │
                       │ • Security Logic│
                       └─────────────────┘

📁 Project Structure

java-login-system/
├── 📁 src/main/java/com/loginapp/
│   ├── 📄 Main.java                    # Application entry point
│   ├── 📁 controller/
│   │   └── 📄 AuthController.java      # Main application controller
│   ├── 📁 model/
│   │   ├── 📄 User.java               # User entity model
│   │   ├── 📄 UserDatabase.java       # Data access layer
│   │   ├── 📄 Role.java               # Role enumeration
│   │   └── 📄 RegistrationResult.java # Registration response model
│   ├── 📁 services/
│   │   └── 📄 PermissionService.java  # Authorization service
│   └── 📁 view/
│       └── 📄 ConsoleView.java        # User interface layer
├── 📄 README.md                       # Project documentation
└── 📄 .gitignore                      # Git ignore file

🛡️ Security Features

🔒 Account Protection

  • Failed Login Protection: Automatic account lockout after 5 failed attempts
  • Password Validation: Enforced minimum 6 characters, maximum 50 characters
  • Input Sanitization: All user inputs are validated and sanitized
  • Session Management: Secure session handling with proper logout

📝 Audit & Logging

  • Login History: Complete tracking of login attempts and sessions
  • Audit Trail: Comprehensive logging of all system operations
  • Security Reports: Real-time security status and threat detection

🎯 User Roles & Permissions

Role Permissions Description
🔴 Admin Full System Access • Manage all users and roles
• Access system administration
• View audit logs and reports
• System configuration
🟡 Moderator User Management • Manage regular users
• Content moderation
• View user statistics
• Limited admin functions
🟢 User Basic Access • Manage own profile
• Change password
• View public statistics
• Basic system usage

🔐 Default Test Accounts

Username Password Role Purpose
admin admin123 Administrator Full system testing
moderator mod123 Moderator User management testing
testuser password123 User Basic functionality testing

⚠️ Security Note: Change default passwords in production environments!


⚙️ Installation

📋 Prerequisites

  • ☕ Java 17 or higher
  • 🔧 Git (for cloning)
  • 💻 Terminal/Command Prompt

🚀 Quick Start

  1. Clone the repository
git clone https://github.com/teusdrz/java-login-system.git
cd java-login-system
  1. Compile the project
javac -d out -cp src src/main/java/com/loginapp/**/*.java
  1. Run the application
java -cp out com.loginapp.Main

🐳 Alternative: Using Docker (Coming Soon)

docker build -t java-login-system .
docker run -it java-login-system

🖥️ Usage

🎮 Main Menu Options

================================
           MAIN MENU
================================
1. Login
2. Register
3. View Public Statistics
4. Exit
================================

👤 User Dashboard

After successful login, users see role-specific options:

================================
        USER DASHBOARD
================================
Welcome, [User Name]!
Role: [User Role]
Email: [User Email]
Account Status: [Active/Locked]

PROFILE OPTIONS:
1. View Profile Details
2. Edit Profile
3. Change Password

[Role-specific options appear here]

0. Logout
================================

🔧 Admin Functions

Administrators have access to advanced features:

  • 👥 User Management: Create, modify, delete users
  • 📊 System Statistics: View comprehensive system metrics
  • 🔍 Audit Logs: Review security and system events
  • ⚙️ System Health: Monitor application performance

🧪 Testing

🎯 Test Scenarios

  1. Authentication Testing

    • Valid/invalid login attempts
    • Account lockout scenarios
    • Password validation
  2. Authorization Testing

    • Role-based access verification
    • Permission boundary testing
    • Privilege escalation prevention
  3. Data Validation Testing

    • Input sanitization
    • Email format validation
    • Username requirements

🏃‍♂️ Running Tests

# Compile and run basic functionality test
java -cp out com.loginapp.Main

# Test with default accounts
# Username: admin, Password: admin123
# Username: moderator, Password: mod123
# Username: testuser, Password: password123

📝 API Documentation

🔑 Core Classes

AuthController

Main application controller handling user interactions and business logic.

public class AuthController {
    public void startApplication()           // Main application loop
    private void handleLogin()               // User authentication
    private void handleRegistration()        // User registration
    private void handleUserManagement()     // Admin user management
    // ... additional methods
}

User

User entity with comprehensive validation and role management.

public class User {
    // Core properties
    private String username, password, email;
    private String firstName, lastName;
    private Role role;
    private boolean isActive, isLocked;
    
    // Validation methods
    public boolean isValidUsername()
    public boolean isValidPassword()
    public boolean isValidEmail()
    // ... additional methods
}

PermissionService

Centralized authorization and permission management.

public class PermissionService {
    public boolean hasPermission(User user, String permission)
    public boolean canManageUser(User manager, User target)
    public boolean canChangeUserRole(User changer, User target, Role newRole)
    // ... additional methods
}

🚧 Roadmap

🎯 Upcoming Features

  • 🗄️ Database Integration (MySQL/PostgreSQL)
  • 🌐 Web Interface (Spring Boot)
  • 🔐 JWT Authentication
  • 📧 Email Verification
  • 🔑 Two-Factor Authentication (2FA)
  • 📱 Mobile App Support
  • 🐳 Docker Containerization
  • ☁️ Cloud Deployment (AWS/Azure)

🔄 Recent Updates

  • v1.2.0 - Enhanced role-based access control
  • v1.1.0 - Added audit logging and security reports
  • v1.0.0 - Initial release with basic authentication

🤝 Contributing

We welcome contributions! Please follow these steps:

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch (git checkout -b feature/amazing-feature)
  3. 💾 Commit your changes (git commit -m 'Add amazing feature')
  4. 📤 Push to the branch (git push origin feature/amazing-feature)
  5. 🔄 Open a Pull Request

📝 Contribution Guidelines

  • Follow Java coding conventions
  • Add unit tests for new features
  • Update documentation as needed
  • Ensure backward compatibility

🐛 Issue Reporting

Found a bug? Please create an issue with:

  • 🔍 Clear description of the problem
  • 📝 Steps to reproduce the issue
  • 💻 Environment details (Java version, OS)
  • 📸 Screenshots if applicable

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


👨‍💻 Author

Matheus Vinicius dos Reis Souza


🙏 Acknowledgments

  • ☕ Built with Java
  • 🏗️ MVC Architecture Pattern
  • 🛡️ Security Best Practices
  • 📚 Educational Purpose

⭐ Star this repository if you found it helpful!

Made with ❤️ by Matheus Vinicius