Skip to content

Commit e1f91c9

Browse files
committed
Added
1 parent 265c8e2 commit e1f91c9

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.claude/
12
.idea/
23
.settings/
34
.vscode

CLAUDE.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Phase2 (formerly "as2-lib") is a Java implementation of the AS2 protocol (RFC 4130) for secure document transport. It includes S/MIME signing/encryption, MDN handling (RFC 3798), and compression (RFC 5402). Forked from OpenAS2. Uses BouncyCastle for cryptography.
8+
9+
## Build Commands
10+
11+
```bash
12+
# Build all modules (skip tests for speed)
13+
mvn clean install -DskipTests
14+
15+
# Build with tests
16+
mvn clean install
17+
18+
# Run a single test
19+
mvn -pl phase2-lib test -Dtest=BCCryptoHelperTest
20+
21+
# Build a single module
22+
mvn -pl phase2-lib clean install
23+
24+
# Run demo webapp in Jetty (from phase2-demo-webapp)
25+
mvn jetty:run -pl phase2-demo-webapp
26+
```
27+
28+
Java 17+ required. Uses Maven multi-module build with parent POM `com.helger:parent-pom`.
29+
30+
## Module Architecture
31+
32+
```
33+
phase2-lib Core library: crypto, message model, processors, partnerships, client
34+
phase2-servlet Servlet integration (AS2ReceiveServlet, MDN servlet)
35+
phase2-server Standalone socket-based AS2 server with command system
36+
phase2-partnership-mongodb MongoDB-backed IPartnershipFactory
37+
phase2-demo-webapp Example WAR using phase2-servlet
38+
phase2-demo-spring-boot Example Spring Boot app using phase2-servlet
39+
```
40+
41+
Dependencies flow: `phase2-lib``phase2-servlet` ← demo apps. `phase2-server` and `phase2-partnership-mongodb` depend only on `phase2-lib`.
42+
43+
## Key Abstractions (phase2-lib)
44+
45+
- **IAS2Session** (`com.helger.phase2.session`) — Central DI container providing access to certificate factory, partnership factory, and message processor. `AS2Session` is the concrete implementation.
46+
- **IMessage / IMessageMDN** (`com.helger.phase2.message`) — Message model hierarchy. `AS2Message` and `AS2MessageMDN` are the concrete types.
47+
- **IMessageProcessor** (`com.helger.phase2.processor`) — Orchestrates message processing through pluggable modules (sender, receiver, resender, storage). Uses chain-of-responsibility via `IProcessorModule` subtypes.
48+
- **ICertificateFactory** (`com.helger.phase2.cert`) — Certificate/keystore management. Implementations: `CertificateFactory` (keystore-based), `PredefinedCertificateFactory`.
49+
- **IPartnershipFactory** (`com.helger.phase2.partner`) — Partnership data store. Implementations: `XMLPartnershipFactory`, `SelfFillingPartnershipFactory`, `MongoDBPartnershipFactory`.
50+
- **ICryptoHelper / BCCryptoHelper** (`com.helger.phase2.crypto`) — Sign, verify, encrypt, decrypt, compress, MIC calculation.
51+
- **AS2Client** (`com.helger.phase2.client`) — High-level client API for sending AS2 messages. Uses `AS2ClientRequest`, `AS2ClientSettings`, `AS2ClientResponse`.
52+
53+
## Processor Module Types
54+
55+
Under `com.helger.phase2.processor`:
56+
- **Receiver**: `AS2ReceiverModule`, `AS2MDNReceiverModule`, `AS2DirectoryPollingModule`
57+
- **Sender**: `AS2SenderModule`, `AsynchMDNSenderModule`
58+
- **Resender**: `DirectoryResenderModule`, `InMemoryResenderModule`, `ImmediateResenderModule`
59+
- **Storage**: `MessageFileModule`, `MDNFileModule`
60+
61+
## Configuration Patterns
62+
63+
- **XML config** (server/servlet): `config.xml` defines certificates, partnerships, commands, and processor modules. See `phase2-server/src/main/resources/config/`.
64+
- **Programmatic** (client): Build `AS2ClientSettings` + `AS2ClientRequest`, call `AS2Client.sendMessage()`.
65+
- **Servlet handlers**: `AS2ReceiveXServletHandlerFileBasedConfig` (XML-based) or `AS2ReceiveXServletHandlerConstantSession` (code-based).
66+
67+
## Test Patterns
68+
69+
- JUnit 4/5 tests in standard `src/test/java` locations
70+
- `SPITest` classes in multiple modules verify service provider interface registrations
71+
- `Main*` classes are manual/integration test runners (not JUnit), e.g. `MainRunTestPhase2Server`, `MainTestClient`
72+
- Test utilities: `MockAS2KeyStore`, `MockCertificateFactoryByteArray` in phase2-lib tests
73+
- MongoDB tests use embedded Flapdoodle MongoDB
74+
75+
## Code Conventions
76+
77+
- Package root: `com.helger.phase2` (except Spring Boot demo uses `com.helger.as2demo.springboot`)
78+
- Follows [Philip Helger's Coding Styleguide](https://github.com/phax/meta/blob/master/CodingStyleguide.md)
79+
- Heavy use of `@Nonnull`, `@Nullable` (JSR 305/JSpecify) annotations
80+
- Relies on `ph-commons` library ecosystem (ph-commons, ph-web, ph-oton)
81+
- SLF4J for logging throughout; Log4j2 in server/demo modules

0 commit comments

Comments
 (0)