Class PushKeyResolver

java.lang.Object
com.iizix.server.push.engine.PushKeyResolver

public final class PushKeyResolver extends Object
Resolves the Push Notification (PN) key references of the server's own container - application *: the credentials file's [server] section and the server settings' $push (PUSH-KEYFILES-DESIGN.md section 9) - into key material: a container that names its VAPID key file (VPrivKeyFile) or its Firebase service-account key file (fcmServiceAccountFile) is answered as a detached clone with VPrivKey and fcmServiceAccount filled in from the files, the pattern of ServerPushKeys.get(). The transports do not change: they read the same two members. The container itself is never modified, and a container without a reference is answered as it is.

An application's .iiziPush is not resolved here since ruling PP-1: its two secrets come from this machine's secrets store, resolved when the application is loaded (PushProps.setSecretsContext), and a key file reference it carried is dropped then. AppPushConfigs.get(String) therefore calls this resolver for * only.

Precedence, per member (ruling K-5): a reference present wins over an inline value, even when its file cannot be used - the member is then empty and the transport reports "not configured" with its existing reason.

When a file is missing or unusable (7.2): SEVERE once per failure streak, naming the application, the member, the reference as written, the resolved path and the reason - never a byte of the file - and the member stays empty until the next lookup finds the file usable. A VAPID key file whose public key is not the container's VPubKey is refused (a stale or foreign file on a load-balanced member), and so is an FCM key file of another Firebase project than the container's fcmProject. A file is read when a send or a keys request needs it, never at load, and re-read after the engine's watcher reports it changed (PushKeyFiles).

Thread-safe: the reader is; the map is concurrent.

Author:
Christopher Mindus
  • Constructor Details

    • PushKeyResolver

      public PushKeyResolver(PushKeyFiles keyFiles, PushKeyFiles.VapidStorage storage)
      Constructor.
      Parameters:
      keyFiles - The reader, shared with the credentials and the engine's watcher.
      storage - Loads a VAPID key file as its $push container.
  • Method Details

    • getKeyFiles

      public PushKeyFiles getKeyFiles()
      Gets the reader.
      Returns:
      The key files.
    • resolve

      public PushProps resolve(String appId, PushProps props)
      Resolves a container: the container itself when it carries no reference, else a detached clone with the referenced secrets filled in - or empty where a file cannot be used.
      Parameters:
      appId - The application ID, for the log: * for the server's own container.
      props - The container, may be null.
      Returns:
      The container to sign with, or null for null.