Skip to content
AokiAppPublic

Latest commit

 

History

263 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CINPO

Spring Boot for JavaCard — annotation-driven applet installation and provisioning.

Release License

Getting Started · Templates · Writing Tasks


Overview

CINPO (Card INstallation and Provision Orchestrator) is a framework that lets you install and provision JavaCard applets with zero boilerplate. You write host-side tasks, annotate them with @CardTaskDef, and CINPO handles the rest — GlobalPlatform secure channel authentication, CAP file loading, APDU transport, simulator lifecycle.

@CardTaskDef("provision")
public final class MyProvision extends CardTask {

    @Override
    public void run() {
        channel.transmit(
            Iso7816Commands.selectDf(manifest.applets().get(0).instanceAid()));
        // your provisioning logic
    }
}

No manual wiring. No scripts. Just annotate, extend CardTask, and run.

Philosophy

CINPO defines a streamlined developer experience for Java Card applet development. It provides complete workflows and frameworks for building, provisioning, testing, and deploying in the wild, from creating the template project to packaging for production. It is designed just like "Spring Boot for Java Card."

The goal is to put the developer experience first and make applet development easier and more modern, so developers can make secure and robust applets fast and iteratively. It is opinionated like Spring Boot or Quarkus, and out-of-the-box, with batteries included.

So applet development is a few simple steps: create a project from the template, write your applet, add annotations to your provisioning code, and run everything with one command. No entrypoint Main class, no build shell scripts, no ad-hoc Gradle tasks.

And for production, everything ships as a single self-contained appliance JAR. It carries only the runtime modules you declare, so a trimmed project has fewer dependencies and a smaller attack surface, and it runs the same on an air-gapped network. Portability is a core design value.

Getting Started

Prerequisites

  • JDK 21
  • git
  • The Oracle Java Card Development Kit (JCDK); see Step 2.

1. Create a project from a template

curl -fsSL https://AokiApp.github.io/cinpo/bootstrap.sh | bash -s -- my-project

On Windows:

irm https://AokiApp.github.io/cinpo/bootstrap.ps1 -OutFile bootstrap.ps1
powershell -ExecutionPolicy Bypass -File .\bootstrap.ps1 my-project

Pass --name/-Name and --template/-Template to choose the destination and starter (see Templates).

my-project/
├── manifest.yaml          # What to install (package AID, applets, SDK version)
├── applet/                # JavaCard applet source files
├── host/
│   ├── provision/         # Default task kind for plain `write`
│   └── test/              # Conventional verification tasks for `--test`
├── profile/
│   └── jcdksim.yaml       # Oracle JCDK simulator profile (development-only keys)
└── vendor/                # Oracle JCDK archives (you provide these)

2. Prepare the vendor directory

CINPO does not redistribute the Oracle JCDK; you must download it and place the Tools and Simulator archives in my-project/vendor/ (see docs/vendor.md). The Tools archive is required for every project. The Simulator archive is needed only while cinpo-runtime-jcdksim is declared in build.gradle; the starter templates declare it, so a fresh project still needs the Simulator archive — remove the dependency if you don't use the jcdksim runtime. Without the required archives, cinpoRun and cinpoJar fail.

After placement, my-project/vendor/ should look like this:

vendor/
├── java_card_devkit_tools-bin-v26.0-b_705-04-MAY-2026.zip
└── java_card_devkit_simulator-linux-bin-v26.0-b_788-05-MAY-2026.tar.gz   # Linux
    (or java_card_devkit_simulator-win-bin-v26.0-b_788-05-MAY-2026.zip)   # Windows

3. Define your manifest

Edit manifest.yaml to describe your applet package (see docs/manifest.md for the full schema):

schema: cinpo.applet.v1            # manifest schema version

basePackage: com.example.myapplet  # Java package your applet sources use
toolSdkVersion: "26.0"             # JCDK version
targetApiVersion: "3.0.4"          # Java Card API version the applet targets

package:
  name: com.example.myapplet       # package identifier; should match basePackage
  aid: D276000085010100            # package AID (hex)
  version: "1.0"                   # package version

companionBundles: []               # see docs/manifest.md

applets:
  - id: main                       # logical identifier, referenced by host tasks
    className: com.example.myapplet.MainApplet   # fully qualified applet class name
    classAid: D27600008501010001   # class AID; must start with the package AID
    instanceAid: D2760000850101000001  # instance AID; what the host SELECTs
    privilege: "00"                # installation privilege byte; see the GlobalPlatform Card Specification

4. Write your applet

Place JavaCard applet source files in applet/. Standard JavaCard API — nothing CINPO-specific here.

If your applet imports vendor-supplied on-card APIs such as GlobalPlatform, declare them in companionBundles — see docs/manifest.md.

5. Write a default provision task

Create a class in host/provision/:

@CardTaskDef("provision")
public final class SetupPins extends CardTask {

    @Override
    public void run() {
        channel.transmit(Iso7816Commands.selectDf(AID));
        channel.transmit(Iso7816Commands.changeReferenceData(0x01, "1234".getBytes()));
    }
}

Any task kind can be declared with @CardTaskDef("<kind>"). provision is simply the default when you don't select one.

6. Simulate

From the project directory:

cd my-project
./gradlew cinpoRun                                      # install applet + run provision tasks
./gradlew cinpoRun --args='--test'                      # also run the test tasks
./gradlew cinpoRun --args='--task=foobar'               # select explicit task kinds
./gradlew cinpoRun --args='--task=provision --task=test'
./gradlew cinpoRun --args='--skip-install --task=foobar'  # skip installation

CAP compilation, simulator setup, GP authentication, installation, and provisioning are all handled.

To run on Windows, use .\gradlew.bat instead of ./gradlew.

To pass template-specific runtime arguments to host-side tasks, put them after --:

./gradlew cinpoRun --args='write -- --record sample01'

Only the arguments after -- are forwarded verbatim to your tasks.

7. Run on a real card

The simulator is a starting point; the same commands work against a physical card.

Profiles

The default is jcdksim (simulator, well-known test keys). For a physical card, create profile/<name>.yaml with runtime: pcsc and your own keys — see docs/profiles.md. Add cinpo-runtime-pcsc to your dependencies if you removed it; the starter templates already include it.

./gradlew cinpoRun --args='--profile mycard --test'

Production machines typically run the appliance instead of Gradle. Build it with:

./gradlew cinpoJar

Run it anywhere, no Gradle required:

java -jar build/libs/cinpo-appliance.jar write --profile jcdksim
java -jar build/libs/cinpo-appliance.jar write --profile mycard --test
java -jar build/libs/cinpo-appliance.jar write --profile mycard -- --record customer-42

When you declare the jcdksim runtime, the appliance also embeds the simulator binaries from vendor/. If you removed it, they aren't included — pass --profile with a profile that names your own runtime.

Templates

scripts/bootstrap.sh and scripts/bootstrap.ps1 copy one of three starter templates into the destination directory. Select one with --template (-Template on PowerShell); the default is basic.

Template What it provides
basic The default starter: a Hello applet, one provision task that issues and writes a leaf certificate, and one test task that reads it back.
authenticated An SCP03 secure-messaging example: the applet handles GlobalPlatform security commands through a companion bundle, and the test proves that an unauthenticated command is refused and the authenticated one succeeds.
probe A read-only card probe: the probe task kind selects an application or the default one and reads GET DATA without writing to the card.

Writing Tasks

A task is a small Java program that runs on the host side of the APDU link, against the simulator or a physical card. Tasks turn "the applet is installed" into actual card state.

Some of the jobs tasks can do:

  • Provision credentials — set a PIN, store keys, write a certificate.
  • Run test cases — write tests as tasks and run them with --test.
  • Factory-provision production cards — unattended, even on an air-gapped line.
@CardTaskDef("provision")
public final class LoadSelectedRecord extends CardTask {

    @Override
    public void run() {
        String recordId = taskArguments.firstValue("record").orElse("sample01");
        String dbPath = taskArguments.firstValue("db").orElse("host/data/cards.db");
        // the template decides what these mean
    }
}

For the full guide — discovery internals, dependency fields, resources, complete examples — see docs/tasks.md.

License

CINPO is licensed under the Apache License 2.0. Review the license before using, modifying, or distributing the software. Third-party components remain subject to their own terms; see Third-Party Notices.

Releases

Packages

Used by

Contributors

Languages