Class LicenseVerifier
LICENSE-V2-DESIGN.md section 2.5, in this order and no other, for the licence client, the MLS and the hub principal alike (design 13, 14):- The envelope is well-formed;
certverifies under a pinned root and the clock is inside itsnotBefore-notAfter. sigverifies over the payload bytes under the certified key, andkidequals the certificate's.- The payload parses under the rules of 2.2 and
vis 2. licis this installation's licence UUID andikeyits public key. On the MLS and the hub principal the expectation is the connection's proven key (5); a caller that proves possession ofikeyanother way (5.2, 5.4) passes null and the step is skipped, which the JavaDoc ofverify(byte[], UUID, PublicKey)spells out.expiresis in the future by the clock. The only step that never refuses: the document is returned withLicenseDocument.isExpired()set.
A document failing 1 to 4 is refused with a LicenseRefusal naming the step and the rule, never a byte of the document, and is never stored. The clock is injected: the client's and the MLS's is the system clock, a test's is fixed. The roots are given at construction (PinnedRoots.ROOTS through pinned(Clock, boolean) in production, test roots in a test); with no root the verifier refuses everything at step 1 and says so once at construction: SEVERE where the product applies the verdicts, INFO where it observes only (order CC-LIC-V5-OBSERVE-DESIGNER: iiziGo and iiziServer in this release).
Thread-safe: no state changes after construction.
- Author:
- Christopher Mindus
Constructor Summary
ConstructorsConstructorDescriptionLicenseVerifier(Collection<RootKey> roots, Clock clock) Constructor.LicenseVerifier(Collection<RootKey> roots, Clock clock, boolean enforced) Constructor, for a product that applies or observes the verdicts.Method Summary
Modifier and TypeMethodDescriptiongetClock()Gets the clock.getRoots()Gets the pinned roots.static LicenseVerifierCreates the production verifier of a product that applies the verdicts:PinnedRoots.ROOTSand a clock.static LicenseVerifierCreates the production verifier:PinnedRoots.ROOTSand a clock, for a product that applies or observes the verdicts.Verifies a licence document: the steps of 2.5 in order.Verifies a licence document given as text:verify(byte[], UUID, PublicKey)on its UTF-8 bytes (the envelope is ASCII; anything else is refused at step 1).verifyCertificate(byte[] certificate) Verifies a key certificate on its own: the certificate half of step 1 - the envelope, the signature under a pinned root, the payload, and the validity by the clock.
Constructor Details
LicenseVerifier
Constructor.- Parameters:
roots- The pinned roots; empty refuses everything, with a SEVERE logged here.clock- The clock steps 1 and 5 read.- Throws:
IllegalArgumentException- If two roots share a key ID.
LicenseVerifier
Constructor, for a product that applies or observes the verdicts.- Parameters:
roots- The pinned roots; empty refuses everything, and says so here.clock- The clock steps 1 and 5 read.enforced- true where the product applies what this verifier refuses (the MLS, the hub, a release that enforces the licence): an empty root set is SEVERE; false where it observes only (iiziGo's gate and iiziServer's counter in this release, order CC-LIC-V5-OBSERVE-DESIGNER): INFO. Nothing else depends on it.- Throws:
IllegalArgumentException- If two roots share a key ID.
Method Details
pinned
Creates the production verifier of a product that applies the verdicts:PinnedRoots.ROOTSand a clock.- Parameters:
clock- The clock,Clock.systemUTC()on a client, the MLS and a hub.- Returns:
- The verifier.
pinned
Creates the production verifier:PinnedRoots.ROOTSand a clock, for a product that applies or observes the verdicts.- Parameters:
clock- The clock,Clock.systemUTC()on a client, the MLS and a hub.enforced- true where the product applies what the verifier refuses, false where it observes only: how an empty root set is logged, SEVERE or INFO.- Returns:
- The verifier.
getRoots
getClock
verify
Verifies a licence document given as text:verify(byte[], UUID, PublicKey)on its UTF-8 bytes (the envelope is ASCII; anything else is refused at step 1).- Parameters:
document- The document text.lic- This installation's licence UUID, or null to skip that half of step 4.ikey- This installation's public key, or null to skip that half of step 4.- Returns:
- The verified document, expired or not.
- Throws:
LicenseRefusal- If a step of 1 to 4 fails.
verify
Verifies a licence document: the steps of 2.5 in order.Step 4 and null. An installation passes its own licence UUID and public key. The MLS passes the values of the installation row the connection proved (5.2). The hub principal passes null for both when it verifies a member's
REGISTER: it takesikeyfrom the returned document and checks the member's signature overHello.hubRegister(byte[], String, String)with it (5.4) - possession of the key, proved that way, replaces the comparison. A null skips the half of step 4 it stands for and nothing else.- Parameters:
document- The document bytes, the envelope as received.lic- This installation's licence UUID, or null to skip that half of step 4.ikey- This installation's Ed25519 public key, or null to skip that half of step 4.- Returns:
- The verified document, expired or not: step 5 is
LicenseDocument.isExpired(). - Throws:
LicenseRefusal- If a step of 1 to 4 fails: the step and the rule, never the bytes.IllegalArgumentException- Ifikeyis not an Ed25519 key.
verifyCertificate
Verifies a key certificate on its own: the certificate half of step 1 - the envelope, the signature under a pinned root, the payload, and the validity by the clock. The MLS verifies its own certificate this way at startup before it signs anything with the certified key.- Parameters:
certificate- The certificate bytes, theIIZI-KEYCERT/1envelope.- Returns:
- The certificate.
- Throws:
LicenseRefusal- At step 1, naming the rule and never the bytes.