> ## Documentation Index
> Fetch the complete documentation index at: https://docs.futurex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Validate and test

> How to test and validate that jPOS is integrated with the Futurex HSM.

This section explains how to test and validate that jPOS is integrated with the Futurex HSM. Before starting this section, install and configure `jPOS Template` per your specific requirements.

> [!NOTE]
>
> Check out [Supported commands](https://docs.futurex.com/Integrations/HSM/Payment/jPOS/Appendices/Supported_commands.md) if you would like to see a table of commands supported by the `ExcryptAdapter`.
>
> If you would like to see some working Java code examples of common operations, check out [Common operations](https://docs.futurex.com/Integrations/HSM/Payment/jPOS/Appendices/Common_operations.md).

## Q2 Overview

Q2 is the jPOS runtime environment that runs and manages jPOS' services called **QBeans**.
When you start Q2, it reads configuration files in the `deploy/` directory, loads the corresponding Java classes, and keeps them running.
For HSM integration, Q2 starts the ExcryptAdapter QBean defined in `20_excrypt.xml`, connects it to the HSM, and manages its lifecycle.
Q2 also supports hot‑deployment — if you add or modify a QBean XML in `deploy/`, it loads or updates the service without restarting the runtime.

## jPOS connection validation

To test the installation, in the directory where you built the jPOS template, run the following command:

```shell expandable lines wrap title="Shell" theme={null}
./gradlew q2
```

While the service is running, look for a log entry similar to this:

```none expandable lines wrap title="None" theme={null}
<log realm="" at="2021-02-19T14:16:38.837" lifespan="1296ms">
   <send>
      ------------ Request ------------
      <message command='ECHO'>
      <token id='AG' value=''/>
      </message>
      [AOECHO;AG;]
      Data received: [AOECHO;BC6.5.3.22ck;AG;]
      ------------ Response ------------
      <message command='ECHO'>
            <token id='BC' value='6.5.3.22ck'/>
            <token id='AG' value=''/>
      </message>
      Socket disconnected.
   </send>
 </log>
```

If that log entry is found, jPOS successfully communicated with the Futurex Excrypt HSM. If not, troubleshoot by verifying the connection settings in `20_excrypt.xml` to ensure they match your HSM’s configuration.

## CLI commands

The library provides a set of CLI commands that help with troubleshooting and configuration tasks. Please see **section 7.1.1** in the [**jPOS Programmer's Guide**](https://jpos.org/doc/proguide-draft.pdf) for further information on the jPOS command line interface.

### ENCRYPT

Encrypts the text provided. Useful when used in combination with the `hsm::` prefix to secure sensitive configuration values such as encryption keys or passwords.

#### Format:

```none expandable lines wrap title="None" theme={null}
excrypt> encrypt <some_text>
```

#### Example:

```shell expandable lines wrap title="Shell" theme={null}
q2> excrypt
excrypt> encrypt "This is a test."
hsm::B7FAA125C4AB3EEE00FD809FC1AE65CE1C43A75699925A57

excrypt>
```

### GENKCV

Calculates the check digits for the given key.

#### Format:

```none expandable lines wrap title="None" theme={null}
excrypt> genkcv 64|128|192 <key >
```

#### Example:

```shell expandable lines wrap title="Shell" theme={null}
q2> excrypt
excrypt> genkcv 128 A468C24C386B3B9D5B0102976B865B89

KCV: EBA8

excrypt>
```

### GENKEY

Generates a new random key encrypted under the LMK.

#### Format:

```none expandable lines wrap title="None" theme={null}
excrypt> genkey
```

#### Example:

```shell expandable lines wrap title="Shell" theme={null}
q2> excrypt
excrypt> genkey

Key cryptogram: 61CDEFFE674F29F22A0231675D3D4319
KCV: 3D35

excrypt>
```

### GENWKEY

Generates a new working key.

#### Format:

```none expandable lines wrap title="None" theme={null}
excrypt> genwkey <kek> <key_type>
```

#### Example:

```shell expandable lines wrap title="Shell" theme={null}
q2> excrypt
excrypt> genwkey 042FAEDF91FE6ED67F97982CE545401C kek

Key under MFK: D13CADC8112880702B239AB0992611B0
Key under KEK: 66227A59F6EB9320CEE3CE2239B595A3
KCV: 9FE3

excrypt>
```

### VERSION

Shows the HSM version.

#### Format:

```none expandable lines wrap title="None" theme={null}
excrypt> version
```

#### Example:

```shell expandable lines wrap title="Shell" theme={null}
q2> excrypt
excrypt> version

Version: 6.5.3.22ck

excrypt>
```
