# Java sample


This sample protects real CSV output using the installed SDK. It uses the same customer approval for browser and file transfer.

[Download this language sample](/downloads/samples/signox-java-sample.zip)

## Install and configure

Download and extract the source archive, then run inside that directory. Install the development SDK using the language guide. All four SDKs are installed as package dependencies.

[SDK](/en/sdk/java/)

```bash
mvn -U compile
```

Copy env.example to your private environment. Set SIGNOX_API_URL, SIGNOX_PRODUCT_ID, SIGNOX_PUBLIC_KEY_FILE and SIGNOX_STATE_DIR. Get the public key and product UUID from your vendor product settings. The customer registers the license key only in the portal. Never commit private state or account credentials.

## Run the sample

Set the four variables from env.example in your shell. Place the pinned public key at SIGNOX_PUBLIC_KEY_FILE. Run start, approve in the returned customer portal, then poll and export.

```bash
mvn exec:java -Dexec.mainClass=kr.signox.samples.Main -Dexec.args="activation-start"
mvn exec:java -Dexec.mainClass=kr.signox.samples.Main -Dexec.args="activation-poll"
mvn exec:java -Dexec.mainClass=kr.signox.samples.Main -Dexec.args="activation-export output.csv"
```

For a disconnected device, carry the two files between computers:

```bash
mvn exec:java -Dexec.mainClass=kr.signox.samples.Main -Dexec.args="activation-request request.signox"
# Import request.signox in the customer portal and save activation.signox.
mvn exec:java -Dexec.mainClass=kr.signox.samples.Main -Dexec.args="activation-apply activation.signox"
```

| Command | Expected behavior |
|---|---|
| `activation-start` | Print the app-branded customer portal URL; open it in a browser. |
| `activation-poll` | Before approval: pending. After approval: apply the response and validate. |
| `activation-request` | Export public request JSON for another computer. |
| `activation-renew-request` | Replace an expired request while preserving the local installation identity. |
| `activation-apply activation.signox` | Verify and apply a response from the customer portal. |
| `activation-status` | Check the current license; only valid plus demo_export grants CSV permission. |
| `activation-export output.csv` | Write two sample sensor rows when allowed; exit 3 if feature permission is missing. |
| `activation-deactivate` | Release an online registration; protected grants require transfer review. |

Exit 0 means the command completed, including pending approval; it does not always mean the device is activated. Exit 2 means validation/activation failed. Do not call pending or skipped checks a pass.

Create a request, sign in as the customer, register the purchased key, select the license, approve, then poll/apply. To test replacement, create a request in a separate state directory; the portal must request vendor review. Record each command, exit code, expected/observed result and evidence path.

Legacy online-/offline-specific commands remain only for compatibility checks. Start a new integration with the activation commands above.
