> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/nfc-wallet/ja/nfcworetto-bakkuendo/kdo/tkunwo.md).

# 認証トークンを作成（旧）

### 概要

グリーンフロー登録をサポートするには、イシュアのバックエンドで認証トークンを作成する必要があります。

このトークンは、イシュアが事前にエンドユーザーを認証し、トークン化リクエストを承認したことを証明します。

イシュアのバックエンドの秘密鍵で認証トークンに署名します。

NFC Wallet バックエンドは、オンボーディング時に提供された対応する公開鍵でトークンを検証します。

{% hint style="warning" %}
イシュアのバックエンドで認証トークンを作成し、次にそれをイシュアアプリケーションに渡します。
{% endhint %}

### 認証トークンの要件

認証トークンは JWT（[RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519)).

{% hint style="info" %}
JWT は、署名付きクレームをシステム間で送信するための標準形式です。
{% endhint %}

#### サポートされるアルゴリズム

NFC Wallet バックエンドは、次の署名アルゴリズムをサポートしています：

* `RS256`
* `PS256`
* `PS512`

#### JWT 形式

JWT は、ドットで区切られた 3 つの Base64URL エンコードされた部分で構成されます（`.`):

* ヘッダー
* ペイロード
* 署名

コンパクト形式は次のとおりです：

`<header>.<payload>.<signature>`

#### ヘッダー

ヘッダーはトークンの種類と署名アルゴリズムを定義します。

`kid` が必要です。NFC Wallet バックエンドは、これを使用して正しい公開鍵を選択します。

ヘッダーの例：

{% code title="JWT ヘッダー" expandable="true" %}

```json
{
  "typ": "JWT",
  "alg": "RS256",
  "kid": "12345abcde"
}
```

{% endcode %}

署名を生成する前に、ヘッダーを 1 行の Base64URL エンコードにします。

#### ペイロード

ペイロードは次のクレームをサポートしています：

| フィールド | 要件   | 説明                                                                                     |
| ----- | ---- | -------------------------------------------------------------------------------------- |
| `iss` | 必須   | イシュア識別子。オンボーディング時に割り当てられた `issuerId` を使用します。                                           |
| `sub` | 条件付き | このクレームを提供するのは、 `nonce` が暗号化されたカードデータに含まれている場合のみです。値は、次の値の SHA-256 ハッシュに設定します。 `nonce`. |
| `iat` | 必須   | トークン発行時刻。で定義されている形式で指定します [RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519).   |
| `exp` | 必須   | トークン有効期限。で定義されている形式で指定します [RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519).   |

ペイロードの例：

{% code title="JWT ペイロード" expandable="true" %}

```json
{
  "iat": 1456815010,
  "exp": 1456851010,
  "iss": "acmeBank",
  "sub": "b776ce1e1b00be3f03c7fff59d872c32cfd65cc4377766f47af84f48ea8925f2"
}
```

{% endcode %}

この例では、 `sub` は、次の値の SHA-256 ハッシュを含みます。 `nonce` 値 `abdda9cfbe2fdce335290773ba6f56a9c5ebe64910`.

#### 署名

イシュアのバックエンドの秘密鍵を使用して、Base64URL エンコードされたヘッダーとペイロードに対して署名を計算します。

NFC Wallet バックエンドは、オンボーディング時に提供された公開鍵で署名を検証します。

最終的な JWT は、エンコードされたヘッダー、ペイロード、署名をドットで区切って連結したものです。

#### JWT を生成する

RSA 署名とカスタムヘッダーをサポートする任意の JWT ライブラリを使用できます。

この例では `jose4j` Java ライブラリを使用します：

{% code title="GenerateJwt.java" %}

```java
private static String generateJwt() throws Exception {
    JwtClaims claims = new JwtClaims();
    claims.setIssuer(issuerId);
    claims.setExpirationTimeMinutesInTheFuture(5);
    claims.setIssuedAtToNow();

    if (subject != null) {
        claims.setSubject(subject);
    }

    JsonWebSignature jws = new JsonWebSignature();
    jws.setPayload(claims.toJson());
    jws.setKey(privateKey);
    jws.setHeader("typ", "JWT");
    jws.setHeader("kid", keyId);
    jws.setAlgorithmHeaderValue(AlgorithmIdentifiers.RSA_USING_SHA256);

    return jws.getCompactSerialization();
}
```

{% endcode %}

{% hint style="info" %}
参照してください [言語別 JWT ライブラリ](https://jwt.io/#libraries-io) 対応する実装について。
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/nfc-wallet/ja/nfcworetto-bakkuendo/kdo/tkunwo.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
