feat(fullstack): Add middleware API to frontend, add dummy signature mode for middleware

This commit is contained in:
2025-07-27 09:05:09 +02:00
parent 4d1280749f
commit 115a12bbf5
14 changed files with 373 additions and 2 deletions

View File

@@ -0,0 +1,125 @@
# Dummy Mode Configuration
This document explains how to use the dummy/mock mode in the legalconsenthub-middleware application.
## Overview
Dummy mode allows you to test the middleware API endpoints without requiring a physical smart card connected to your system. Instead of interacting with real smart card hardware via OpenSC, the application returns predefined dummy data.
## How to Enable Dummy Mode
### Option 1: Using Spring Profiles
Start the application with the `dummy` profile:
```bash
# Using Gradle
./gradlew bootRun --args='--spring.profiles.active=dummy'
# Using JAR
java -jar build/libs/legalconsenthub-middleware-*.jar --spring.profiles.active=dummy
# Using environment variable
export SPRING_PROFILES_ACTIVE=dummy
./gradlew bootRun
```
### Option 2: Using IntelliJ IDEA Run Configuration
A pre-configured run configuration named `local-middleware-dummy` is available in the `.run` directory. Simply:
1. Open the project in IntelliJ IDEA
2. Select "local-middleware-dummy" from the run configurations dropdown
3. Click the run button
### Option 3: Manual Configuration
You can also manually set the dummy mode property:
```bash
./gradlew bootRun --args='--dummy.mode.enabled=true'
```
## What Gets Mocked
### Smart Card Information
- **Smart Card Info**: Always returns a successful response with dummy smart card information
- **Certificates**: Always returns a successful response with two dummy certificates
### Signature Operations
- **Sign PDF Hash**: Always returns a successful dummy signature
- **Verify Signature**: Always returns a successful verification result
## Dummy Data
### Smart Card Info
```json
{
"isPresent": true,
"label": "DUMMY Smart Card",
"serialNumber": "12345678",
"manufacturer": "Dummy Corp",
"model": "DummyCard 2024"
}
```
### Available Certificates
1. **Certificate 1**:
- ID: `01`
- Subject: `CN=John Doe, O=Example Company, L=Berlin, C=DE`
- Issuer: `CN=Dummy CA, O=Dummy Corp, C=DE`
2. **Certificate 2**:
- ID: `02`
- Subject: `CN=Jane Smith, O=Test Organization, L=Munich, C=DE`
- Issuer: `CN=Test CA, O=Test Corp, C=DE`
## Testing Signature Verification
The dummy implementation always returns successful responses:
- **All signatures**: Any signature verification request will return `isValid: true`
- **Consistent behavior**: All requests return successful responses for predictable testing
- **No validation**: The dummy mode doesn't perform actual signature validation
## API Endpoints
All original API endpoints remain the same when running in dummy mode:
- `GET /smart-card/info` - Returns dummy smart card information
- `GET /smart-card/certificates` - Returns dummy certificates
- `POST /sign-pdf-hash` - Creates dummy signatures
- `POST /verify-signature` - Verifies dummy signatures
## Development Benefits
Using dummy mode provides several advantages during development:
1. **No Hardware Dependency**: Test frontend functionality without smart card hardware
2. **Consistent Data**: Predictable responses make testing easier
3. **Fast Development**: No waiting for smart card operations or PIN entry
4. **Error Testing**: Easily test error scenarios by using invalid certificate IDs
5. **CI/CD Integration**: Run automated tests without smart card hardware
## Switching Back to Real Mode
To disable dummy mode and use real smart card operations:
1. Remove the `dummy` profile from `SPRING_PROFILES_ACTIVE`
2. Ensure your smart card is connected and OpenSC is properly configured
3. Start the application normally
```bash
# Normal mode (default)
./gradlew bootRun
# Or explicitly disable dummy mode
./gradlew bootRun --args='--dummy.mode.enabled=false'
```
## Notes
- In dummy mode, all responses are successful and verification details are prefixed with "DUMMY:" to clearly indicate mock responses
- The dummy controllers return hardcoded successful responses without any actual processing
- All dummy responses include realistic data structures that match the real API responses
- Perfect for frontend testing where you need predictable successful responses