How sprinting/filebox works
Project Type and Purpose
• FileBox is a web application built on the Java Servlet API (v3.1) deployed on a Tomcat 8 server.
• It uses a simple MVC pattern where the presentation is handled via JSP, HTML, CSS, and JavaScript; the business logic is implemented in the servlet and service layers; and security is managed via custom classes for JSON Web Tokens and session management.
• Key features include Login/Logout, session management, file upload/download, and JSON Web Token based verification.
Analyzing the File Structure
• WebContent Folder:
– Contains the static and view components: JSP pages (dashboard.jsp, index.jsp), HTML (upload.html), CSS (dashboard.css) and JavaScript (dashboard.js).
– Also contains deployment descriptors and configuration (WEB-INF/web.xml) along with library dependencies.
• src Directory:
– Contains several packages:
• security: Implements authentication and token management (BCrypt, JsonTokenVerifier, JsonWebToken etc.). Also holds exception classes and managers like DashboardManager, UploadManager, and SQLManager.
• service: Houses servlets handling various functionalities (LoginInit, Logout, Dashboard, FileShare, FileDownload, ReceiveSharedFile) and filters (IndexFilter, LoggedInFilter) that manage request flow.
• examples and tests: Provide a reference example (ExampleFileUploader) and unit tests for security and service functionality.
Key Components and Their Interactions
– Client/Browser: Initiates requests through the user interface by interacting with HTML forms, JSP pages, and JavaScript.
– Web Server (Tomcat): Hosts the application and manages the execution of servlets.
– Presentation Layer (View):
• Located in WebContent (JSP, HTML, CSS, JS files).
• Responsible for rendering the UI to the user.
– Controller/Service Layer:
• Servlets found in the src/service package handle HTTP requests.
• Filters (IndexFilter, LoggedInFilter) pre-process requests to manage sessions and restrict access.
– Security Module:
• The src/security package contains logic for authentication and authorization using BCrypt for password hashing and JSON Web Tokens for stateless operations.
• Security managers (DashboardManager, UploadManager) and token verification classes (JsonTokenVerifier, JsonWebToken) are central to this module.
– Data Access/Management (Optional/Abstraction):
• SQLManager suggests that there is a component interacting with databases, even if the actual data store isn’t detailed here.
– Testing Suite:
• Located in src/tests, includes unit tests ensuring the correctness of security and service components.
Architectural Patterns and Design Principles
• MVC Pattern: Clear separation of concerns between the view (WebContent), controller (servlets and filters), and model (service/business logic in security and service packages).
• Security Best Practices: Use of JSON Web Tokens for stateless verification and BCrypt for secure password handling.
• Layered Architecture: There is a distinct separation between presentation, controller/service, and security/data access layers.
• Client (Browser)
• Web Server (Tomcat container)
• Presentation Layer: WebContent (JSP, HTML, CSS, JavaScript)
• Controller/Service Layer: Servlets (LoginInit, Logout, FileShare, FileDownload, etc.) and Filters (IndexFilter, LoggedInFilter)
• Security Module: All classes under src/security (BCrypt, JsonTokenVerifier, JsonWebToken, etc.)
• Testing Suite: Indicate as a separate component or note that tests run against various modules.
– From Browser to Web Server (HTTP requests).
– Between the Presentation Layer to Controller layer (user actions triggering servlets).
– From Controllers to Security Module (for authentication and authorization tasks).
– From Controllers (or Security) to Data Access if applicable.