This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
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.
# Build all modules (skip tests for speed)
mvn clean install -DskipTests
# Build with tests
mvn clean install
# Run a single test
mvn -pl phase2-lib test -Dtest=BCCryptoHelperTest
# Build a single module
mvn -pl phase2-lib clean install
# Run demo webapp in Jetty (from phase2-demo-webapp)
mvn jetty:run -pl phase2-demo-webappJava 17+ required. Uses Maven multi-module build with parent POM com.helger:parent-pom.
phase2-lib Core library: crypto, message model, processors, partnerships, client
phase2-servlet Servlet integration (AS2ReceiveServlet, MDN servlet)
phase2-server Standalone socket-based AS2 server with command system
phase2-partnership-mongodb MongoDB-backed IPartnershipFactory
phase2-demo-webapp Example WAR using phase2-servlet
phase2-demo-spring-boot Example Spring Boot app using phase2-servlet
Dependencies flow: phase2-lib ← phase2-servlet ← demo apps. phase2-server and phase2-partnership-mongodb depend only on phase2-lib.
- IAS2Session (
com.helger.phase2.session) — Central DI container providing access to certificate factory, partnership factory, and message processor.AS2Sessionis the concrete implementation. - IMessage / IMessageMDN (
com.helger.phase2.message) — Message model hierarchy.AS2MessageandAS2MessageMDNare the concrete types. - IMessageProcessor (
com.helger.phase2.processor) — Orchestrates message processing through pluggable modules (sender, receiver, resender, storage). Uses chain-of-responsibility viaIProcessorModulesubtypes. - ICertificateFactory (
com.helger.phase2.cert) — Certificate/keystore management. Implementations:CertificateFactory(keystore-based),PredefinedCertificateFactory. - IPartnershipFactory (
com.helger.phase2.partner) — Partnership data store. Implementations:XMLPartnershipFactory,SelfFillingPartnershipFactory,MongoDBPartnershipFactory. - ICryptoHelper / BCCryptoHelper (
com.helger.phase2.crypto) — Sign, verify, encrypt, decrypt, compress, MIC calculation. - AS2Client (
com.helger.phase2.client) — High-level client API for sending AS2 messages. UsesAS2ClientRequest,AS2ClientSettings,AS2ClientResponse.
Under com.helger.phase2.processor:
- Receiver:
AS2ReceiverModule,AS2MDNReceiverModule,AS2DirectoryPollingModule - Sender:
AS2SenderModule,AsynchMDNSenderModule - Resender:
DirectoryResenderModule,InMemoryResenderModule,ImmediateResenderModule - Storage:
MessageFileModule,MDNFileModule
- XML config (server/servlet):
config.xmldefines certificates, partnerships, commands, and processor modules. Seephase2-server/src/main/resources/config/. - Programmatic (client): Build
AS2ClientSettings+AS2ClientRequest, callAS2Client.sendMessage(). - Servlet handlers:
AS2ReceiveXServletHandlerFileBasedConfig(XML-based) orAS2ReceiveXServletHandlerConstantSession(code-based).
- JUnit 4/5 tests in standard
src/test/javalocations SPITestclasses in multiple modules verify service provider interface registrationsMain*classes are manual/integration test runners (not JUnit), e.g.MainRunTestPhase2Server,MainTestClient- Test utilities:
MockAS2KeyStore,MockCertificateFactoryByteArrayin phase2-lib tests - MongoDB tests use embedded Flapdoodle MongoDB
- Package root:
com.helger.phase2(except Spring Boot demo usescom.helger.as2demo.springboot) - Follows Philip Helger's Coding Styleguide
- Heavy use of
@Nonnull,@Nullable(JSR 305/JSpecify) annotations - Relies on
ph-commonslibrary ecosystem (ph-commons, ph-web, ph-oton) - SLF4J for logging throughout; Log4j2 in server/demo modules