Class ExampleScenario20

java.lang.Object
co.ankatech.ankasecure.sdk.examples.ExampleScenario20

public final class ExampleScenario20 extends Object
Scenario 20 — PKCS#7 → JOSE Conversion / Migration (data-plane).

Converts a legacy PKCS#7/CMS EnvelopedData artifact to a modern JOSE JWE. Unlike the keyless analysis in ExampleScenario19, conversion of EnvelopedData requires the platform to actually decrypt the CMS envelope and re-wrap it — so it needs the recipient's private key, referenced by its platform key id.

Where the recipient key comes from (control-plane prerequisite)

  • The recipient key is matched by issuer DN + serial number, NOT by algorithm — so it cannot be discovered from the algorithm catalogue.
  • Importing that key from a legacy keystore is a control-plane operation handled outside the data-plane SDK (the admin migration surface, an admin-scoped actor).
  • This data-plane example therefore reads the resulting key id from the explicit pkcs7.decryptionKid property and skips cleanly (before any server call) if it is absent.

Steps:

  1. Resolve the recipient key id from the pkcs7.decryptionKid property (skips cleanly when blank)
  2. Compact convert: convertPkcs7ToJose (AUTO format → EnvelopedData becomes JWE)
  3. Streaming convert: convertPkcs7ToJoseStream to a JWE output file
  4. End-to-end: performMigrationWorkflow (analyze + convert in one call)

Target-format contract

TargetFormatEnum.AUTO detects the structure: EnvelopedData → JWE, SignedData → JWS, both → nested. Forcing JWS on EnvelopedData is a 400 contract error (there is no signature to convert); this example uses AUTO / JWE.

API Endpoints:

  • POST /api/v3/migration/convert-pkcs7-to-jose (compact conversion)
  • POST /api/v3/migration/stream/convert-pkcs7-to-jose (streaming conversion)

Prerequisite: a cli.properties for a data-plane actor, plus a pkcs7.decryptionKid entry naming a recipient key already provisioned on the platform. Until that key is provisioned the conversion calls will fail at the server; the analysis counterpart ExampleScenario19 needs no key and runs unconditionally.

Author:
ANKATech Solutions Inc.
See Also:
  • Method Details

    • main

      public static void main(String[] args)
      Runs the PKCS#7 → JOSE conversion / migration scenario.
      Parameters:
      args - command-line arguments (ignored)