Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
ce7b333
Updated Pom versions for release changes
Prafulrakhade Aug 6, 2024
a077d3b
Merge pull request #239 from mosip/releas-branch
ckm007 Aug 6, 2024
d315033
[MOSIP-35160] Updated URL from https://github.com/mosip/mosip-infra/b…
Prafulrakhade Sep 9, 2024
1b01fc0
Merge pull request #244 from Prafulrakhade/release-1.3.x
ckm007 Sep 10, 2024
a1618bb
MOSIP-32453: Fixed pdf generation issue (#245)
dhanendra06 Sep 13, 2024
c2c7eeb
Updated the released versions for commons dependency
GOKULRAJ136 Oct 7, 2024
4ace410
updated the versions from the props
GOKULRAJ136 Oct 8, 2024
d4f0c3a
Merge pull request #246 from GOKULRAJ136/pom-1.3.x
ckm007 Oct 17, 2024
9aedc4b
updated readme for developer guide java21
GOKULRAJ136 Nov 8, 2024
409fb54
updated config props and jdk versions
GOKULRAJ136 Nov 11, 2024
f59af6f
updated the configuration
GOKULRAJ136 Nov 11, 2024
0704db5
Update configuration.md
GOKULRAJ136 Nov 11, 2024
d979cf1
Merge pull request #249 from GOKULRAJ136/doc-1.3.x
ckm007 Nov 12, 2024
c4ff3fb
MOSIP-32453
dhanendra06 Nov 12, 2024
3e05771
MOSIP-32453
dhanendra06 Nov 12, 2024
5376dc0
Merge pull request #250 from dhanendra06/mosip-186
ckm007 Nov 12, 2024
1a0ac8d
Updated chart versions, image and tag for release changes
Prafulrakhade Dec 4, 2024
d75bb0f
Merge pull request #252 from mosip/releas-branch
ckm007 Dec 5, 2024
4557954
[DSD-6825] platform 1.2.1.0-beta-1 release (#253)
ckm007 Dec 10, 2024
bdd00b4
Updated chart versions, image and tag for release changes (#254)
ckm007 Dec 10, 2024
c07c6ec
Updated Pom version and Chart version for post-release changes (#255)
ckm007 Dec 13, 2024
f86b2af
MOSIP-25202 - fix sonar reliability issues
ymahtat-dev Dec 2, 2024
a9a8411
MOSIP-25202 - github actions fix - update actions/upload-artifact and…
ymahtat-dev Jan 28, 2025
116b3b6
Merge pull request #259 from ymahtat-dev/draft-release-1.3.x
ckm007 Jan 30, 2025
89ef4ee
[MOSIP-40012] Corrected ZGC (#263)
GOKULRAJ136 Mar 7, 2025
caac4cb
MOSIP-40719 change version to snapshot (#264)
kameshsr Mar 17, 2025
0546ea0
MOSIP-37901: print-release (#260)
nagendra0721 Mar 19, 2025
a9464d7
MOSIP-37901: change to RC (#265)
nagendra0721 Mar 20, 2025
a351bf0
[MOSIP-41674] Updated the changes for mosip namespace migration from …
Prafulrakhade Jun 2, 2025
9f7bd02
Merge pull request #271 from Prafulrakhade/release-1.3.x
ckm007 Jun 2, 2025
de5a004
[MOSIP-42464] [MOSIP-41674] central sonatype migration changes
Prafulrakhade Aug 5, 2025
0941336
Merge pull request #278 from Prafulrakhade/release-1.3.x-MOSIP-42464
dhanendra06 Aug 5, 2025
d52bb40
pom and util updates
nandhu-kumar Nov 13, 2025
716d135
dateutil changes
nandhu-kumar Nov 13, 2025
40ba6dc
Merge pull request #283 from nandhu-kumar/release13x
dhanendra06 Nov 13, 2025
3668689
[MOSIP-43631] updated helm charts
GOKULRAJ136 Nov 15, 2025
85ef9ef
Merge pull request #285 from GOKULRAJ136/MOSIP-43631
dhanendra06 Nov 15, 2025
4d52088
Update values.yaml
GOKULRAJ136 Nov 15, 2025
52c93da
Merge pull request #288 from GOKULRAJ136/patch-1
dhanendra06 Nov 15, 2025
ca2473c
update tag version
dhanendra06 Nov 16, 2025
a8d88dc
Updated tag version
dhanendra06 Nov 16, 2025
ff0c443
Merge pull request #289 from dhanendra06/MOSIP-018
ckm007 Nov 16, 2025
d93da27
Add THIRD-PARTY-NOTICES.txt with package details
Rakshithasai123 Nov 25, 2025
23c23af
MOSIP-43803 - removed commented out dependency in pom
nandhu-kumar Nov 26, 2025
81f08c8
Merge pull request #293 from nandhu-kumar/release-13x-01
dhanendra06 Nov 26, 2025
251ac0a
Create Apache-2.0.txt
Rakshithasai123 Nov 27, 2025
9a13d8b
fix cpu & memory
kaledOu Nov 28, 2025
3fb2502
Merge pull request #296 from kaledOu/release-1.3.x-helm
ckm007 Nov 29, 2025
547d28a
Create NOTICES.txt
rajapandi1234 Dec 2, 2025
b95445b
Update THIRD-PARTY-NOTICES.txt
Rakshithasai123 Dec 3, 2025
b12cf10
Update THIRD-PARTY-NOTICES.txt
Rakshithasai123 Dec 3, 2025
f2518ba
Update THIRD-PARTY-NOTICES.txt
Rakshithasai123 Dec 4, 2025
75bbd9f
Update THIRD-PARTY-NOTICES.txt
Rakshithasai123 Dec 4, 2025
ca72c8d
Create NOTICES.txt
Rakshithasai123 Dec 5, 2025
a1682b9
Create MPL-2.0.txt‎
Rakshithasai123 Dec 8, 2025
b815db5
Create EPL-1.0.txt
Rakshithasai123 Dec 8, 2025
eb4fba7
Create EPL-2.0.txt
Rakshithasai123 Dec 8, 2025
196d341
Create BSD-2.0.txt
Rakshithasai123 Dec 8, 2025
a78f943
Create BSD-3-Clause.txt‎
Rakshithasai123 Dec 8, 2025
f2ab7dd
Create AGPL-3.0-only.txt‎
Rakshithasai123 Dec 8, 2025
ad8f0d9
Create LGPL-3.0-only.txt
Rakshithasai123 Dec 8, 2025
a449971
Create JSON.txt‎
Rakshithasai123 Dec 8, 2025
4fa488d
Create MIT.txt‎
Rakshithasai123 Dec 8, 2025
f76c4b1
Rename NOTICES.txt to NOTICE
Rakshithasai123 Dec 9, 2025
69fad02
[MOSIP-42190] : Sonar coverage, Taken test cases from develop (#299)
chetankh239 Dec 9, 2025
a78fccb
Rename NOTICES.txt to NOTICE
rajapandi1234 Dec 9, 2025
bae3edb
Update Apache-2.0.txt
Rakshithasai123 Dec 11, 2025
012b81a
Update Apache-2.0.txt
Rakshithasai123 Dec 11, 2025
d5940fc
Update THIRD-PARTY-NOTICES.txt
Rakshithasai123 Dec 12, 2025
7f8e82d
[MOSIP-44072] : Updated README.md (#310)
chetankh239 Dec 17, 2025
1a63a31
Merge pull request #303 from rajapandi1234/patch-5
Mahesh-Binayak Dec 20, 2025
b739140
Merge pull request #295 from Rakshithasai123/patch-3
Mahesh-Binayak Dec 21, 2025
035588a
Merge pull request #292 from Rakshithasai123/patch-1
Mahesh-Binayak Dec 21, 2025
e9ac0e3
Merge pull request #309 from Rakshithasai123/patch-14
Mahesh-Binayak Dec 21, 2025
24f0271
Updated chart versions, image and tag for release changes (#312)
ckm007 Dec 22, 2025
dd8f5be
Updated Pom versions for release changes (#313)
ckm007 Dec 22, 2025
f2b1709
[MOSIP-44867]fixing duplicate license issues (#317)
Mahesh-Binayak Apr 15, 2026
095fd4d
[MOSIP-44894] Renamed licences (#320)
amanbh321 Apr 16, 2026
b7baebb
SNAPSHOT changes for licensing folder space issue fix (#326)
kameshsr May 21, 2026
a55f369
Updated chart versions, image and tag for release changes (#334)
ckm007 May 27, 2026
2f574d7
Updated Pom versions for release changes (#335)
ckm007 May 27, 2026
82ff1f5
Merge branch 'rel-1.3.1-test' into develop-test
nagendra0721 Jun 5, 2026
7aced28
#1830: taking latest release changes to develop
nagendra0721 Jun 5, 2026
257d705
#1830: image revert to qa
nagendra0721 Jun 5, 2026
38680ab
#1830: agents.md file added
nagendra0721 Jun 5, 2026
3d028cb
#1830: agents.md file modified
nagendra0721 Jun 5, 2026
ea20c2e
#1830: modified as per suggestion
nagendra0721 Jun 5, 2026
e22baa2
#1830: update bootstrap fie
nagendra0721 Jun 8, 2026
25f1501
#1830: update agents file
nagendra0721 Jun 8, 2026
1244290
#1830: update pom file
nagendra0721 Jun 8, 2026
390fa65
#1830: update readme file
nagendra0721 Jun 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,13 @@ jobs:
- SERVICE_LOCATION: '../print'
SERVICE_NAME: 'print'
BUILD_ARTIFACT: 'print'
SQUASH_LAYERS: '11'
fail-fast: false
name: ${{ matrix.SERVICE_NAME }}
uses: mosip/kattu/.github/workflows/docker-build.yml@master-java21
with:
SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }}
SERVICE_NAME: ${{ matrix.SERVICE_NAME }}
BUILD_ARTIFACT: ${{ matrix.BUILD_ARTIFACT }}
SQUASH_LAYERS: ${{ matrix.SQUASH_LAYERS }}
secrets:
DEV_NAMESPACE_DOCKER_HUB: ${{ secrets.DEV_NAMESPACE_DOCKER_HUB }}
ACTOR_DOCKER_HUB: ${{ secrets.ACTOR_DOCKER_HUB }}
Expand Down
265 changes: 265 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
# AGENTS.md — MOSIP Print Service

This file provides guidance to AI agents when working with code in this repository.

---

## Project Overview

The **MOSIP Print Service** is a Spring Boot microservice that generates PDF identity credentials (eUIN cards, reprint cards, QR code cards) for residents enrolled in MOSIP — the Modular Open Source Identity Platform.

It sits at the tail end of the **ID Lifecycle Management** pipeline:
1. A resident registers or updates their ID at a registration centre.
2. Demographic and biometric data are captured and processed by Registration Processor.
3. Credentials are issued and an event is published to WebSub.
4. **This service** consumes the credential event, decrypts resident data, renders a template, generates a PDF, uploads it to DataShare, and publishes a completion event.

The service is a **reference implementation** for credential partner onboarding. Deployers are expected to customise templates and partner certificates.

---

## Technology Stack

| Layer | Technology |
|---|--------------------------------------------|
| Language | Java 21 |
| Framework | Spring Boot 3.2.3 + Spring Cloud Config |
| Build | Maven 3.9.6 |
| PDF generation | pdfbox
Comment thread
nagendra0721 marked this conversation as resolved.
| Template engine | Apache Velocity 1.7 |
| QR codes | ZXing (Google) 3.4.1 |
| Cryptography | BouncyCastle 1.66, JWT 3.8.1 |
| Messaging | MOSIP WebSub (kernel-websub-client-api) |
| Biometrics | CBEFF format via kernel-cbeffutil |
| Tests | JUnit 5, Mockito 4.11.0, JaCoCo |
| Containerisation | Docker (Alpine-based), Helm for Kubernetes |

---

## Repository Layout

```
print/
├── src/main/java/io/mosip/print/
│ ├── PrintPDFApplication.java # Spring Boot entry point
│ ├── controller/Print.java # Single REST endpoint (WebSub callback)
│ ├── service/
│ │ ├── PrintService.java # Interface
│ │ └── impl/
│ │ ├── PrintServiceImpl.java # Core orchestration logic (~500 lines)
│ │ ├── PDFGeneratorImpl.java # iText PDF generation
│ │ ├── QrcodeGeneratorImpl.java # ZXing QR code generation
│ │ ├── TemplateManagerImpl.java # Velocity template processing
│ │ ├── CbeffImpl.java # Biometric (CBEFF) handling
│ │ └── UinCardGeneratorImpl.java
│ ├── util/ # 50+ utility classes
│ │ ├── CryptoUtil.java # Encryption / decryption
│ │ ├── DataShareUtil.java # DataShare upload
│ │ ├── TemplateGenerator.java # Template instantiation
│ │ ├── DigitalSignatureUtility.java # PDF digital signing
│ │ ├── WebSubSubscriptionHelper.java # WebSub subscription management
│ │ └── RestApiClient.java # HTTP client wrapper
│ ├── dto/ # 65+ Data Transfer Objects
│ ├── constant/ # 35+ constant classes
│ ├── exception/ # 35+ custom exception classes
│ ├── model/ # Domain models (Event, StatusEvent)
│ └── entity/ # CBEFF entity models
├── src/main/resources/
│ ├── application-local1.properties # Local dev config (port 8088)
│ ├── bootstrap.properties # Spring Cloud Config bootstrap
│ └── partner.p12 # Sample partner certificate
├── src/test/java/io/mosip/print/ # 45+ unit test files
├── docs/
│ ├── build-and-run.md
│ ├── configuration.md
│ └── print-service.png # Architecture diagram
├── deploy/ # Shell scripts for bare-metal deploy
├── helm/ # Kubernetes Helm charts
├── Dockerfile
└── pom.xml
```

---

## Build and Run

### Build (skip tests)
```bash
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgpg.skip=true
```

### Build with tests
```bash
mvn clean install -Dmaven.javadoc.skip=true -Dgpg.skip=true
```

### Run tests only
```bash
mvn test
```

### Run the JAR
```bash
java -Dloader.path=<path-to-kernel-auth-adapter.jar> \
-Dspring.profiles.active=local1 \
-jar target/print-*.jar
```

### Docker
```bash
# Build image
docker build -t print-service:local .

# Run container
docker run -d -p 8099:8099 --name print-service print-service:local
```

Service listens on **port 8099** (default) or **port 8088** (local1 profile).

---

## Key Configuration Properties

All runtime configuration is sourced from a **Spring Cloud Config Server** (mosip-config repository). Local overrides live in `application-local1.properties`.

| Property | Purpose |
|---|---|
| `mosip.event.hubURL` | WebSub hub URL |
| `mosip.partner.id` | This service's partner ID (`mpartner-default-print`) |
| `mosip.event.topic` | WebSub topic to subscribe to |
| `mosip.event.callBackUrl` | Public URL of the `/print/callback/notifyPrint` endpoint |
| `mosip.event.secret` | WebSub HMAC secret |
| `mosip.datashare.partner.id` | DataShare partner (`mpartner-default-resident`) |
| `mosip.datashare.policy.id` | DataShare policy (`mpolicy-default-resident`) |
| `mosip.print.crypto.p12.filename` | Partner P12 certificate filename |
| `mosip.print.crypto.p12.password` | P12 password |
| `mosip.print.crypto.p12.alias` | P12 key alias |
| `mosip.template-language` | Language code for template lookup (e.g. `eng`) |
| `mosip.kernel.pdf_owner_password` | PDF encryption owner password |
| `mosip.supported-languages` | Comma-separated ISO language codes |
| `mosip.iam.adapter.clientid` | Keycloak client ID for this service |
| `mosip.iam.adapter.issuerURL` | Keycloak realm issuer URL |
| `TEMPLATES` | Masterdata templates endpoint |
| `CREATEDATASHARE` | DataShare create endpoint |
| `PDFSIGN` | Keymanager PDF sign endpoint |

---

## REST API

### `POST /v1/print/print/callback/notifyPrint`

The single public endpoint. Called by the WebSub hub when a credential event is published.

**Headers required:**
- `x-hub-signature` — HMAC-SHA256 signature from WebSub hub (validated by the service)

**Body:** WebSub notification JSON containing the credential event payload.

**Flow:**
1. Validates WebSub signature and intent.
2. Extracts and decrypts credential data using the partner P12 key.
3. Fetches the HTML template for the card type from Masterdata.
4. Renders the template with resident data using Velocity.
5. Converts HTML to PDF via iText html2pdf.
6. Optionally embeds a QR code and applies a digital signature.
7. Uploads the PDF to DataShare.
8. Publishes a `CREDENTIAL_STATUS_UPDATE` event back to WebSub.

---

## Data Flow and Integration Points

```
WebSub Hub
│ POST /print/callback/notifyPrint
Print.java (controller)
│ generateCard(event)
PrintServiceImpl.java
├── KeyManager / CryptoUtil — decrypt credential data
├── Masterdata (TEMPLATES) — fetch HTML template
├── TemplateManagerImpl — merge template + data (Velocity)
├── PDFGeneratorImpl — HTML → PDF (PDF Box)
├── QrcodeGeneratorImpl — embed QR code (ZXing)
├── DigitalSignatureUtility — sign PDF (Keymanager PDFSIGN)
├── DataShareUtil — upload PDF (DataShare)
└── WebSubSubscriptionHelper — publish status event
```

External services consumed:
- **Keymanager** — decryption and PDF signing
- **Masterdata** — HTML templates
- **DataShare** — secure PDF upload
- **WebSub** — event subscription and publication
- **IAM (Keycloak)** — token-based authentication for all REST calls

---

## ID Lifecycle Context

MOSIP's ID Lifecycle Management covers the full journey of an identity:

- **Registration** — Resident attends a registration centre; demographic and biometric data are captured.
- **Processing** — Registration Processor de-duplicates and validates the data.
- **Activation** — A UIN (Unique Identification Number) is issued; the ID is active.
- **Credential Issuance** — Credentials (VCs, PDF cards) are generated for configured partners.
- **Updates** — Resident can update demographics or biometrics; a new credential is re-issued.
- **Deactivation / Reactivation** — IDs can be deactivated and reactivated via resident services.
- **Print / Reprint** — This service handles the print partner use case: it receives credential events and produces PDF identity cards.

This service handles the **Credential Issuance → Print** leg. The `UinCardType` constant class enumerates supported card types: `EUIN`, `REPRINT`, `QRCODE`.

---

## Working with This Codebase

### Before making changes
1. Read `PrintServiceImpl.java` — it is the central orchestrator; most changes flow through it.
2. Check `PrintRestClientServiceImpl.java` for how external REST calls are made before adding new ones.
3. Verify properties exist in `application-local1.properties` or `docs/configuration.md` before introducing new config keys.

### Adding a new card type
1. Add a constant to `UinCardType.java`.
2. Add a template to Masterdata and reference it in `PrintServiceImpl.generateCard()`.
3. Add a corresponding branch in `TemplateGenerator.java` if template rendering differs.

### Modifying template rendering
Templates are HTML files processed by Velocity. Variables are injected via `VelocityContext`. See `TemplateManagerImpl.java` and `TemplateGenerator.java`.

### Cryptography
Do not modify `CryptoUtil.java` without understanding the P12 key usage. The partner certificate must match the credential encryption key registered in Keymanager.

### Tests
- Unit tests are in `src/test/java/io/mosip/print/`.
- Tests use Mockito; external service calls are mocked.
- Run `mvn test` before committing any change.
- JaCoCo generates a coverage report under `target/site/jacoco/`.

### Docker image
The `Dockerfile` copies the built JAR and runs it. The image is published to Docker Hub as `mosipid/print-service`.

---

## Conventions

- Package root: `io.mosip.print`
- All Spring beans follow constructor injection where possible.
- REST responses are wrapped in a standard `ResponseWrapper<T>` DTO.
- Exceptions extend `BaseCheckedException` or `BaseUncheckedException` from the MOSIP kernel.
- Logging uses `io.mosip.print.logger.PrintLogger` (SLF4J wrapper); do not use `System.out`.
- Constants live in dedicated files under the `constant/` package; do not hard-code strings inline.
- All external HTTP calls go through `PrintRestClientService` — do not use `RestTemplate` directly in service classes.

---

## Useful References

- MOSIP documentation: https://docs.mosip.io/1.2.0/
- ID Lifecycle Management: https://docs.mosip.io/1.2.0/id-lifecycle-management
- mosip-config repository: contains `print-default.properties` with all runtime properties
- MOSIP functional tests: https://github.com/mosip/mosip-functional-tests
- Docker Hub image: `mosipid/print-service`
- Build and run guide: `docs/build-and-run.md`
- Configuration guide: `docs/configuration.md`
8 changes: 4 additions & 4 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ This project includes components licensed under BSD licenses:

• PostgreSQL JDBC Driver (BSD-2-Clause)
• Jakarta Activation API (BSD-3-Clause)
• Jakarta Persistence API (BSD-3-Clause)
• Jakarta Persistence API (BSD-3-Clause or EPL-2.0)
• Additional transitive BSD-licensed components

-------------------------------------------------------------------------------
Eclipse Public License Attribution (EPL-2.0)
Eclipse Public License Attribution (EPL-1.0 / EPL-2.0)
-------------------------------------------------------------------------------
The following components are licensed under EPL:

• JUnit (EPL-2.0)
• JUnit (EPL-1.0 / EPL-2.0)
• JUnit Vintage Engine (EPL-2.0)
• JaCoCo Maven Plugin (EPL-2.0)
• Jakarta XML Bind API (EPL-2.0)

• H2 Database (dual-licensed EPL-1.0 / MPL-2.0)

-------------------------------------------------------------------------------
MIT License Attribution
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ To deploy print service in production follow the given steps:

1. Onboard your organisation as [Credential Partner](https://docs.mosip.io/1.2.0/partners).
2. Place your `.p12` file in `../src/main/resources` folder.
3. Set configuration as in given [here](https://github.com/mosip/mosip-config/blob/develop/print-default.properties).
3. Set configuration as in given [here](https://github.com/mosip/mosip-config/blob/master/print-default.properties).
4. Build and run as given [here](docs/build-and-run.md).

## Test
Expand Down Expand Up @@ -73,7 +73,7 @@ Ensure the following artifacts are available in the classpath or loader path:

### Configuration
Print uses properties from **mosip-config**.
You can check the configuration here: [print-default.properties](https://github.com/mosip/mosip-config/blob/develop/print-default.properties)
You can check the configuration here: [print-default.properties](https://github.com/mosip/mosip-config/blob/master/print-default.properties)
### Local Setup (for Development or Contribution)

1. Ensure the **Config Server** is running and accessible.To run config server [check here.](https://github.com/mosip/mosip-config/blob/master/README.md)
Expand Down
4 changes: 1 addition & 3 deletions helm/print/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@ spec:
{{- end }}
{{- end }}
{{- if .Values.extraEnvVarsSecret }}
{{- range .Values.extraEnvVarsSecret }}
- secretRef:
name: {{ . }}
{{- end }}
name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsSecret "context" $) }}
{{- end }}
ports:
- name: spring-service
Expand Down
Loading
Loading