Class ExchangeOperations

java.lang.Object
co.ankatech.ankasecure.keymanagement.ExchangeOperations

public final class ExchangeOperations extends Object
The tenant's cryptographic exchanges: drafts, validation, activation and the lifecycle of an active exchange. Obtained from AuthenticatedKeyManagementSdk.exchanges(). The exchange routes carry no tenant in their path: the Admin API takes it from the token, like every other operation here.

 ExchangeDetailResponse draft = sdk.exchanges().create(new ExchangeCreateRequest().name("payroll-to-bank"));
 ValidationResultResponse verdict = sdk.exchanges().validate(draft.getId());
 
  • Method Details

    • list

      Lists exchanges (GET /exchanges).
      Parameters:
      query - the filters and page; must not be null
      Returns:
      one page of exchanges
      Throws:
      KeyManagementSdkException - when the call is refused
    • create

      Creates a draft exchange (POST /exchanges).
      Parameters:
      request - the exchange; must not be null
      Returns:
      the created draft
      Throws:
      KeyManagementSdkException - when the call is refused
    • get

      public ExchangeDetailResponse get(UUID id)
      Reads one exchange (GET /exchanges/{id}).
      Parameters:
      id - the exchange; must not be null
      Returns:
      the exchange
      Throws:
      KeyManagementSdkException - when the call is refused
    • update

      public ExchangeDetailResponse update(UUID id, ExchangeUpdateRequest request)
      Updates an exchange (PATCH /exchanges/{id}).
      Parameters:
      id - the exchange; must not be null
      request - the members to change, with the version read; must not be null
      Returns:
      the updated exchange
      Throws:
      KeyManagementSdkException - when the call is refused (a stale version is 409)
    • discardDraft

      public void discardDraft(UUID id, int version)
      Discards a draft exchange (DELETE /exchanges/{id}).
      Parameters:
      id - the exchange; must not be null
      version - the version read, so a concurrent change is refused (409)
      Throws:
      KeyManagementSdkException - when the call is refused
    • cloneExchange

      public ExchangeDetailResponse cloneExchange(UUID id, CloneRequest request)
      Clones an exchange into a new draft (POST /exchanges/{id}/clone).
      Parameters:
      id - the exchange to clone; must not be null
      request - the clone's settings, or null for the defaults
      Returns:
      the new draft
      Throws:
      KeyManagementSdkException - when the call is refused
    • validate

      public ValidationResultResponse validate(UUID id)
      Validates a draft exchange (POST /exchanges/{id}/validate).
      Parameters:
      id - the exchange; must not be null
      Returns:
      the validation verdict and its findings
      Throws:
      KeyManagementSdkException - when the call is refused
    • previewActivation

      public ExchangeActivationPreviewResponse previewActivation(UUID id)
      Previews what an activation would grant (GET /exchanges/{id}/activation-preview).
      Parameters:
      id - the exchange; must not be null
      Returns:
      the preview
      Throws:
      KeyManagementSdkException - when the call is refused
    • activate

      public ExchangeDetailResponse activate(UUID id, ActivateRequest request)
      Activates a validated exchange (POST /exchanges/{id}/activate).
      Parameters:
      id - the exchange; must not be null
      request - the activation; must not be null
      Returns:
      the active exchange
      Throws:
      KeyManagementSdkException - when the call is refused
    • suspend

      public ExchangeDetailResponse suspend(UUID id, SuspendExchangeRequest request)
      Suspends an active exchange (POST /exchanges/{id}/suspend).
      Parameters:
      id - the exchange; must not be null
      request - the suspension; must not be null
      Returns:
      the suspended exchange
      Throws:
      KeyManagementSdkException - when the call is refused
    • resume

      public ExchangeDetailResponse resume(UUID id, ResumeExchangeRequest request)
      Resumes a suspended exchange (POST /exchanges/{id}/resume).
      Parameters:
      id - the exchange; must not be null
      request - the resumption; must not be null
      Returns:
      the resumed exchange
      Throws:
      KeyManagementSdkException - when the call is refused
    • revoke

      public ExchangeDetailResponse revoke(UUID id, RevokeExchangeRequest request)
      Revokes an exchange for good (POST /exchanges/{id}/revoke).
      Parameters:
      id - the exchange; must not be null
      request - the revocation; must not be null
      Returns:
      the revoked exchange
      Throws:
      KeyManagementSdkException - when the call is refused
    • createGrant

      public CapabilityGrantResponse createGrant(UUID id, ExchangeGrantRequest request)
      Adds a capability grant owned by the exchange, in the exchange's context (POST /exchanges/{id}/grants). The grant authorizes only while the exchange is active; added to a draft, ready or suspended exchange it is held until activation or resumption. Its actor belongs to the origin or destination application, and it names exactly one key, or 1 to 32 ordered key pairs for REENCRYPT or RESIGN.
      Parameters:
      id - the exchange; must not be null
      request - the grant; must not be null
      Returns:
      the created grant
      Throws:
      KeyManagementSdkException - when the call is refused (409 capability-grant-overlap when it would overlap a live grant of the actor)
    • revokeGrant

      public void revokeGrant(UUID id, UUID grantId, RevokeExchangeGrantRequest request)
      Revokes one grant the exchange owns (POST /exchanges/{id}/grants/{grantId}/revoke); its other grants are unchanged. The last live grant of an active or suspended exchange is not revoked alone (422): revoke the exchange instead.
      Parameters:
      id - the exchange; must not be null
      grantId - the grant; must not be null
      request - the audited reason for the revocation, required; must not be null
      Throws:
      KeyManagementSdkException - when the call is refused