Class MapIssuerKeyRegistry

java.lang.Object
xyz.tcheeric.cashu.voucher.app.adapter.MapIssuerKeyRegistry
All Implemented Interfaces:
IssuerKeyRegistry

public final class MapIssuerKeyRegistry extends Object implements IssuerKeyRegistry
An IssuerKeyRegistry backed by a fixed map of issuer id to public key.

Enough for the common case: a merchant application that knows its own issuer id and signing key from configuration. Deployments serving many issuers should implement the port against whatever already holds that mapping rather than growing this class.

Issuer ids are matched case-insensitively, and keys are compared that way too, because hex is written both ways in practice and a case difference is not a different key.

  • Constructor Details

    • MapIssuerKeyRegistry

      public MapIssuerKeyRegistry(@NonNull @NonNull Map<String,String> keysByIssuerId)
  • Method Details

    • of

      public static MapIssuerKeyRegistry of(@NonNull @NonNull String issuerId, @NonNull @NonNull String publicKeyHex)
      A registry holding a single issuer, the usual shape for one merchant.
    • publicKeyFor

      public Optional<String> publicKeyFor(String issuerId)
      Description copied from interface: IssuerKeyRegistry
      The public key registered for an issuer.
      Specified by:
      publicKeyFor in interface IssuerKeyRegistry
      Parameters:
      issuerId - the issuer identifier claimed by a voucher
      Returns:
      the hex-encoded public key, or empty when the issuer is unknown