How hcl-tech-software/altoroj works
Project Type & Purpose
• AltoroJ is a full-stack J2EE web application with a focus on banking functionality and security vulnerability demonstration.
• It uses standard Java, JSP, Servlets, and Filters as its core technology – making it ideal for illustrating both web application structure and security issues.
File Structure
• Notice that the top-level directories include configuration/IDE files (.settings, .project), a WebContent folder (housing JSP pages, static assets, and WEB-INF configurations), and a src folder (containing Java source code).
• WebContent contains directories for JSP pages (e.g., bank, admin), static content like images and CSS, and the WEB-INF folder that holds configuration files (web.xml, app.properties) and libraries.
• The src directory further divides into packages (com.ibm.security.appscan.altoromutual) with sub-packages for:
– API endpoints (AccountAPI, AdminAPI, etc.)
– Filters (e.g., AuthFilter, AdminFilter, ApiAuthFilter)
– Servlets to handle user actions (LoginServlet, TransferServlet, etc.)
– Model classes (Account, Feedback, Transaction, User)
– Utility classes (DBUtil, OperationsUtil, ServletUtil)
• A separate directory (“swagger”) within WebContent documents and exposes the REST API via Swagger UI.
Key Components
a. Web Client / Browser:
– Represents users accessing the application through their browsers.
– Includes both standard web navigation (JSP pages & forms) and queries via the REST API (accessed through Swagger).
b. Application Server (Tomcat 7):
– Deployed as a WAR package containing the WebContent directory and the Java code compiled from src.
– Divided into multiple layers:
• Web Layer: JSP pages, static assets (CSS, images, JSPF includes) for the look and feel.
• Controller Layer: Servlets that process requests, route actions and handle both standard interactions and REST API calls.
• Filter & Listener Layer: Security filters (AuthFilter, ApiAuthFilter, AdminFilter) that check and control access, plus listeners (StartupListener) for initialization events.
c. Business Logic / Model Layer:
– Represented by the classes in the model package (Account, Feedback, Transaction, User) that encapsulate core business data.
– The API classes in the “api” sub-package serve as endpoints exposing business functionality, typically consumed by REST API calls.
d. Database (Apache Derby):
– The application uses Apache Derby as the SQL database.
– DBUtil (and possibly other utility classes) are used to handle connectivity and basic CRUD operations on the database.
– Note that the database is auto-initialized on the first successful login and is persisted in the “altoro” folder under the user’s home directory.
e. REST API Component:
– The “swagger” directory in WebContent provides clients a way to interact with the REST services defined in the API package.
Relationships and Interactions
• Inside the Application Server, illustrate the flow:
1. Incoming HTTP requests are intercepted by Filters (authentication/authorization).
2. Requests are then delegated to the appropriate Servlets or API controllers.
3. Servlets interact with utility classes and the Model layer to execute business logic.
4. For data persistence, a connection is made to the Apache Derby database via DBUtil.
• Role of the Listener (StartupListener) which initializes configuration or resources during server start-up.
Architectural Patterns and Design Principles
• MVC Pattern:
– View: JSP pages and static content.
– Controller: Servlets and API classes managing request/response cycles.
– Model: Java classes representing data and business logic.
• Security Considerations:
– The presence of Filters indicates pre-processing for security checks (both for normal web sessions and API calls).
• Separation of Concerns:
– Clear directory separation between presentation (WebContent) and business logic (src).