|
| 1 | +# Wicket Security |
| 2 | + |
| 3 | +A comprehensive security framework for Apache Wicket applications, providing authentication and authorization capabilities through a modular, extensible architecture. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Wicket Security is a multi-module security framework designed for Apache Wicket web applications. It provides role-based access control (RBAC), permission-based security, and fine-grained authorization at the component, page, and model levels. |
| 8 | + |
| 9 | +**Version:** 10.8.0-SNAPSHOT |
| 10 | +**License:** Apache License 2.0 |
| 11 | +**Inception Year:** 2006 |
| 12 | + |
| 13 | +## Architecture |
| 14 | + |
| 15 | +The framework consists of four main modules organized into two parent projects: |
| 16 | + |
| 17 | +### Module Hierarchy |
| 18 | + |
| 19 | +```mermaid |
| 20 | +graph TD |
| 21 | + A[wicket-security-parent] --> B[wasp-parent] |
| 22 | + A --> C[swarm-parent] |
| 23 | + B --> D[wicomsec] |
| 24 | + B --> E[wasp] |
| 25 | + C --> F[hive] |
| 26 | + C --> G[swarm] |
| 27 | + E -.depends on.-> D |
| 28 | + G -.depends on.-> E |
| 29 | + G -.depends on.-> F |
| 30 | + F -.depends on.-> D |
| 31 | + |
| 32 | + style A fill:#e1f5ff |
| 33 | + style B fill:#fff4e1 |
| 34 | + style C fill:#fff4e1 |
| 35 | + style D fill:#e8f5e9 |
| 36 | + style E fill:#e8f5e9 |
| 37 | + style F fill:#e8f5e9 |
| 38 | + style G fill:#e8f5e9 |
| 39 | +``` |
| 40 | + |
| 41 | +## Modules |
| 42 | + |
| 43 | +### 1. **Wicomsec** (Wicket Common Security) |
| 44 | +**Artifact:** `wicketstuff-security-wicomsec` |
| 45 | + |
| 46 | +The foundation module containing common security-related classes and interfaces. |
| 47 | + |
| 48 | +**Key Components:** |
| 49 | +- `Actions` - Central registry for action factories |
| 50 | +- `ActionFactory` - Factory pattern for creating security actions |
| 51 | +- `WaspAction` - Represents security actions (read, write, enable, render, etc.) |
| 52 | +- Common security abstractions and utilities |
| 53 | + |
| 54 | +**Purpose:** Provides shared security primitives used by other modules. |
| 55 | + |
| 56 | +### 2. **WASP** (Wicket Abstract Security Platform) |
| 57 | +**Artifact:** `wicketstuff-security-wasp` |
| 58 | + |
| 59 | +The core security framework providing abstract security mechanisms for Wicket applications. |
| 60 | + |
| 61 | +**Key Components:** |
| 62 | +- `ISecurityCheck` - Interface for security checks |
| 63 | +- `WaspAuthorizationStrategy` - Integration with Wicket's authorization system |
| 64 | +- `ISecureComponent` - Interface for components with security features |
| 65 | +- `ISecureModel` - Interface for models with security features |
| 66 | +- Component-level and class-level security checks |
| 67 | + |
| 68 | +**Purpose:** Provides the abstract foundation for implementing security in Wicket applications, independent of specific authentication/authorization implementations. |
| 69 | + |
| 70 | +**Dependencies:** |
| 71 | +- wicomsec |
| 72 | +- Apache Wicket Extensions |
| 73 | +- Jakarta Servlet API |
| 74 | + |
| 75 | +### 3. **Hive** |
| 76 | +**Artifact:** `wicketstuff-security-hive` |
| 77 | + |
| 78 | +A basic ACL (Access Control List) security implementation. |
| 79 | + |
| 80 | +**Key Components:** |
| 81 | +- `Hive` - Security policy container (similar to JAAS Policy) |
| 82 | +- `HiveMind` - Registry for multiple hive instances |
| 83 | +- `PolicyFileHiveFactory` - Factory for creating hives from policy files |
| 84 | +- `Principal` - Represents security principals (users, roles) |
| 85 | +- `Permission` - Represents permissions |
| 86 | +- `Subject` - Represents authenticated subjects |
| 87 | + |
| 88 | +**Purpose:** Provides a concrete ACL-based security policy implementation, allowing multiple security policies per JVM. |
| 89 | + |
| 90 | +**Dependencies:** |
| 91 | +- wicomsec |
| 92 | + |
| 93 | +### 4. **SWARM** (Standard Wicket Authentication and Rights Management) |
| 94 | +**Artifact:** `wicketstuff-security-swarm` |
| 95 | + |
| 96 | +A complete, ready-to-use security implementation combining WASP and Hive. |
| 97 | + |
| 98 | +**Key Components:** |
| 99 | +- `SwarmWebApplication` - Base class for Swarm-enabled applications |
| 100 | +- `SwarmStrategy` - Authorization strategy implementation |
| 101 | +- `SwarmActionFactory` - Factory for Swarm-specific actions |
| 102 | +- `DataSecurityCheck` - Security checks for data access |
| 103 | +- Integration layer combining WASP and Hive |
| 104 | + |
| 105 | +**Purpose:** Provides a production-ready security solution with minimal configuration required. |
| 106 | + |
| 107 | +**Dependencies:** |
| 108 | +- wasp |
| 109 | +- hive |
| 110 | + |
| 111 | +## Component Interaction Flow |
| 112 | + |
| 113 | +```mermaid |
| 114 | +sequenceDiagram |
| 115 | + participant User |
| 116 | + participant WicketApp as Wicket Application |
| 117 | + participant SWARM as SWARM Layer |
| 118 | + participant WASP as WASP Layer |
| 119 | + participant Hive as Hive Policy |
| 120 | + |
| 121 | + User->>WicketApp: Access Component/Page |
| 122 | + WicketApp->>SWARM: Check Authorization |
| 123 | + SWARM->>WASP: Evaluate Security Check |
| 124 | + WASP->>Hive: Query Permissions |
| 125 | + Hive-->>WASP: Return Permission Set |
| 126 | + WASP-->>SWARM: Authorization Result |
| 127 | + SWARM-->>WicketApp: Grant/Deny Access |
| 128 | + WicketApp-->>User: Render/Redirect |
| 129 | +``` |
| 130 | + |
| 131 | +## Security Check Flow |
| 132 | + |
| 133 | +```mermaid |
| 134 | +flowchart LR |
| 135 | + A[Component Access] --> B{Security Check} |
| 136 | + B -->|Component Level| C[ISecureComponent] |
| 137 | + B -->|Class Level| D[Class Authorization] |
| 138 | + B -->|Model Level| E[ISecureModel] |
| 139 | + |
| 140 | + C --> F[WaspAuthorizationStrategy] |
| 141 | + D --> F |
| 142 | + E --> F |
| 143 | + |
| 144 | + F --> G[Hive Policy] |
| 145 | + G --> H{Has Permission?} |
| 146 | + H -->|Yes| I[Grant Access] |
| 147 | + H -->|No| J[Deny Access] |
| 148 | + |
| 149 | + style A fill:#e3f2fd |
| 150 | + style I fill:#c8e6c9 |
| 151 | + style J fill:#ffcdd2 |
| 152 | +``` |
| 153 | + |
| 154 | +## Permission Model |
| 155 | + |
| 156 | +```mermaid |
| 157 | +graph LR |
| 158 | + A[Subject/User] -->|has| B[Principal] |
| 159 | + B -->|granted| C[Permission] |
| 160 | + C -->|for| D[Action] |
| 161 | + D -->|on| E[Component/Page/Model] |
| 162 | + |
| 163 | + F[Hive] -->|stores| B |
| 164 | + F -->|manages| C |
| 165 | + |
| 166 | + style A fill:#fff9c4 |
| 167 | + style F fill:#e1bee7 |
| 168 | +``` |
| 169 | + |
| 170 | +## Usage Overview |
| 171 | + |
| 172 | +### Basic Integration |
| 173 | + |
| 174 | +1. **Extend SwarmWebApplication:** |
| 175 | +```java |
| 176 | +public class MyApplication extends SwarmWebApplication { |
| 177 | + @Override |
| 178 | + protected void setupActionFactory() { |
| 179 | + super.setupActionFactory(); |
| 180 | + } |
| 181 | + |
| 182 | + @Override |
| 183 | + protected Object getHiveKey() { |
| 184 | + return "myapp"; |
| 185 | + } |
| 186 | +} |
| 187 | +``` |
| 188 | + |
| 189 | +2. **Define Security Policies:** |
| 190 | + - Create policy files defining principals and permissions |
| 191 | + - Configure Hive to load these policies |
| 192 | + |
| 193 | +3. **Secure Components:** |
| 194 | + - Implement `ISecureComponent` on custom components |
| 195 | + - Use security checks to control rendering and enabling |
| 196 | + - Apply security at page, component, or model level |
| 197 | + |
| 198 | +## Key Features |
| 199 | + |
| 200 | +- ✅ **Component-Level Security** - Secure individual Wicket components |
| 201 | +- ✅ **Page-Level Security** - Control access to entire pages |
| 202 | +- ✅ **Model-Level Security** - Secure data access through models |
| 203 | +- ✅ **Action-Based Permissions** - Fine-grained control (render, enable, etc.) |
| 204 | +- ✅ **Multiple Security Policies** - Support for multiple Hives per JVM |
| 205 | +- ✅ **Extensible Architecture** - Abstract base allows custom implementations |
| 206 | +- ✅ **ACL Support** - Built-in access control list implementation |
| 207 | +- ✅ **Integration Ready** - Works seamlessly with Wicket's authorization system |
| 208 | + |
| 209 | +## Build Information |
| 210 | + |
| 211 | +**Build Tool:** Maven |
| 212 | +**Java Version:** Compatible with Jakarta EE 10 |
| 213 | +**Wicket Version:** 10.x |
| 214 | + |
| 215 | +### Building the Project |
| 216 | + |
| 217 | +```bash |
| 218 | +mvn clean install |
| 219 | +``` |
| 220 | + |
| 221 | +### Running Tests |
| 222 | + |
| 223 | +```bash |
| 224 | +mvn test |
| 225 | +``` |
| 226 | + |
| 227 | +Note: Performance tests (SpeedTest.java) are excluded in release builds. |
| 228 | + |
| 229 | +## Developers |
| 230 | + |
| 231 | +- **Maurice Marrink** (Deceased) - Original Developer - Topicus |
| 232 | +- **Emond Papegaaij** - Developer - Topicus |
| 233 | +- **Olger Warnier** - Developer - Joining Tracks / Zorginiatieven |
| 234 | + |
| 235 | +## Module Dependencies Graph |
| 236 | + |
| 237 | +```mermaid |
| 238 | +graph TD |
| 239 | + subgraph "WASP Family" |
| 240 | + WICOMSEC[wicomsec<br/>Common Security] |
| 241 | + WASP[wasp<br/>Abstract Platform] |
| 242 | + end |
| 243 | + |
| 244 | + subgraph "SWARM Family" |
| 245 | + HIVE[hive<br/>ACL Implementation] |
| 246 | + SWARM[swarm<br/>Complete Solution] |
| 247 | + end |
| 248 | + |
| 249 | + subgraph "External Dependencies" |
| 250 | + WICKET[Apache Wicket] |
| 251 | + SERVLET[Jakarta Servlet API] |
| 252 | + SLF4J[SLF4J Logging] |
| 253 | + end |
| 254 | + |
| 255 | + WASP --> WICOMSEC |
| 256 | + WASP --> WICKET |
| 257 | + WASP --> SERVLET |
| 258 | + HIVE --> WICOMSEC |
| 259 | + SWARM --> WASP |
| 260 | + SWARM --> HIVE |
| 261 | + SWARM --> WICKET |
| 262 | + |
| 263 | + WICOMSEC --> SLF4J |
| 264 | + |
| 265 | + style WICOMSEC fill:#4caf50 |
| 266 | + style WASP fill:#2196f3 |
| 267 | + style HIVE fill:#ff9800 |
| 268 | + style SWARM fill:#9c27b0 |
| 269 | +``` |
| 270 | + |
| 271 | +## License |
| 272 | + |
| 273 | +Licensed under the Apache License, Version 2.0. See LICENSE file for details. |
| 274 | + |
| 275 | +## Contributing |
| 276 | + |
| 277 | +This project is part of the WicketStuff project (http://wicketstuff.org/). |
| 278 | + |
| 279 | +## Support |
| 280 | + |
| 281 | +For issues and questions, please refer to the WicketStuff community resources. |
0 commit comments