Class VapidTransport

java.lang.Object
com.iizix.server.push.engine.transport.VapidTransport
All Implemented Interfaces:
IPushTransport

public final class VapidTransport extends Object implements IPushTransport
The Web Push transport: RFC 8030 request, RFC 8291 encryption, RFC 8292 VAPID authorization, over the Jetty client.

The subscription is the JSON the browser's PushSubscription.toJSON() produced, stored verbatim by /iizi-push/subscribe: endpoint, keys.p256dh, keys.auth. The application's public key and subject come from its .iiziPush and its private key from this machine's secrets store (ruling PP-1), resolved through AppPushConfigs at every send so a hot-deployed configuration takes effect; * is the server's own pair. A token is never minted without a sub claim: an application without a subject sends the server's own * subject, else DEFAULT_SUBJECT (subject(PushProps, String), CC-FIX-PUSH-V5 G-2). A stored private key that is not the public key's pair leaves VAPID off for the application with one SEVERE (ruling PP-2, isPair(String, String, String)). The private key is loaded with P256Keys, java.base only, so the transport signs identically on the standalone iiziServer and under Equinox in the Designer's debug server.

The pair is chosen by the row (PUSH-CLUSTER-DESIGN 3.3, B-10b, AppPushConfigs.signer(SubscriptionRecord)): a row made under the server's own * key - a Browser inside iiziRun Developer subscribed for an application (RR-21 C) - is signed with *'s pair, since the push service accepts only the key the subscription was made with; a row made under a key this server holds for neither is DeliveryOutcome.KEY_MISMATCH, nothing is posted, and the row is kept.

Status mapping, from RFC 8030 section 8 and the push services' practice: 201 (and 200, 202) delivered; 404 and 410 endpoint stale, prune it; 429 and 5xx transient, spool and honour Retry-After; 400, 401, 403, 413 permanent, the request or the credentials are wrong; a connection failure or timeout is transient.

Author:
Christopher Mindus
  • Constructor Details

    • VapidTransport

      public VapidTransport(HttpClient client, AppPushConfigs configs)
      Constructor.
      Parameters:
      client - The started Jetty client.
      configs - The application configurations.
  • Method Details

    • getKind

      public PushTransport getKind()
      Description copied from interface: IPushTransport
      Gets the transport kind.
      Specified by:
      getKind in interface IPushTransport
      Returns:
      The kind.
    • getState

      public TransportState getState(String appId)
      Description copied from interface: IPushTransport
      Gets whether this transport can send for an application.
      Specified by:
      getState in interface IPushTransport
      Parameters:
      appId - The application ID, * for iiziRun.
      Returns:
      The state, never null.
    • send

      public TransportResult send(SubscriptionRecord subscription, PushMessage message, long ttlMillis, DeliveryUrgency urgency)
      Description copied from interface: IPushTransport
      Sends a notification to one subscription. Blocks the calling (virtual) thread until the push service has answered or the request timed out.
      Specified by:
      send in interface IPushTransport
      Parameters:
      subscription - The subscription.
      message - The notification.
      ttlMillis - The effective time-to-live in milliseconds, already defaulted and clamped by the engine; converted to seconds at the header only.
      urgency - The effective urgency.
      Returns:
      The result, never null; a failure is an outcome, never an exception.
    • dispose

      public void dispose()
      Description copied from interface: IPushTransport
      Releases the transport's resources.
      Specified by:
      dispose in interface IPushTransport