Class ServerControlStore

java.lang.Object
zeroecho.pki.server.ServerControlStore
All Implemented Interfaces:
AutoCloseable

public final class ServerControlStore extends Object implements AutoCloseable
Dedicated durable authority for finite server security and disclosure control metadata.

All public operations are synchronized to serialize compare-and-replace within one realm process. Cross-process exclusion and durability remain the responsibility of the composed TransactionalMetadataStore. No PKI certificate, CRL, CSR, key, secret, or unrestricted exception data is stored.

  • Field Details

    • REALM

      public static final String REALM
      Stable namespace for the realm record.
      See Also:
    • PRINCIPAL

      public static final String PRINCIPAL
      Stable namespace for principals.
      See Also:
    • ASSIGNMENT

      public static final String ASSIGNMENT
      Stable namespace for scoped role assignments.
      See Also:
    • GRANT

      public static final String GRANT
      Stable namespace for direct permission grants.
      See Also:
    • APPROVAL

      public static final String APPROVAL
      Stable namespace for approvals.
      See Also:
    • BREAK_GLASS

      public static final String BREAK_GLASS
      Stable namespace for break-glass records.
      See Also:
    • DISCLOSURE

      public static final String DISCLOSURE
      Stable namespace for disclosure records.
      See Also:
    • CAPABILITY

      public static final String CAPABILITY
      Stable namespace for capability commitments.
      See Also:
    • REPOSITORY_ALIAS

      public static final String REPOSITORY_ALIAS
      Stable namespace for non-authoritative public repository aliases.
      See Also:
    • ACME_DIRECTORY

      public static final String ACME_DIRECTORY
      Stable namespace for ACME directory records.
      See Also:
    • ACME_ACCOUNT

      public static final String ACME_ACCOUNT
      Stable namespace for ACME account records.
      See Also:
    • ACME_ORDER

      public static final String ACME_ORDER
      Stable namespace for ACME order records.
      See Also:
    • ACME_AUTHORIZATION

      public static final String ACME_AUTHORIZATION
      Stable namespace for ACME authorization records.
      See Also:
    • ACME_CHALLENGE

      public static final String ACME_CHALLENGE
      Stable namespace for ACME challenge records.
      See Also:
    • ACME_EVIDENCE

      public static final String ACME_EVIDENCE
      Stable namespace for ACME validation-evidence records.
      See Also:
    • OCSP_RESPONDER

      public static final String OCSP_RESPONDER
      Stable namespace for durable OCSP responder bindings.
      See Also:
    • ENROLLMENT_PROFILE

      public static final String ENROLLMENT_PROFILE
      Stable namespace for durable enrollment policy profiles.
      See Also:
    • ENROLLMENT_ENDPOINT

      public static final String ENROLLMENT_ENDPOINT
      Stable namespace for revisioned enrollment endpoint bindings and tombstones.
      See Also:
    • ENROLLMENT_CREDENTIAL

      public static final String ENROLLMENT_CREDENTIAL
      Stable namespace for immutable enrollment credential-set commitments.
      See Also:
    • ENROLLMENT_REQUEST

      public static final String ENROLLMENT_REQUEST
      Stable namespace for durable enrollment transactions and replay tombstones.
      See Also:
    • CMP_TRANSACTION

      public static final String CMP_TRANSACTION
      Stable namespace for quota-reserved CMP transaction manifests.
      See Also:
    • CMP_RESPONSE

      public static final String CMP_RESPONSE
      Stable namespace for fixed CMP response slots owned by a manifest.
      See Also:
    • ENROLLMENT_KEYGEN

      public static final String ENROLLMENT_KEYGEN
      Immutable server-keygen reservations and encrypted delivery lifecycle.
      See Also:
    • REVOCATION_AUDIT_PROJECTION

      public static final String REVOCATION_AUDIT_PROJECTION
      Stable namespace for non-authoritative revocation-audit projection state.
      See Also:
    • AUDIT_ANCHOR

      public static final String AUDIT_ANCHOR
      Stable namespace for the durable cross-store audit-log integrity anchor.
      See Also:
    • AUDIT_EVIDENCE_PROJECTION

      public static final String AUDIT_EVIDENCE_PROJECTION
      Stable namespace for per-family success-evidence audit-projection cursors.
      See Also:
  • Constructor Details

    • ServerControlStore

      public ServerControlStore(TransactionalMetadataStore metadata)
      Creates a server-control adapter over one exclusively owned metadata store.
      Parameters:
      metadata - lifecycle-owned metadata authority
  • Method Details

    • id

      public MetadataStoreId id()
      Returns the durable server-control metadata-store identity.
      Returns:
      durable metadata-store identity
      Throws:
      IllegalStateException - if this adapter is closed
    • ensureRealm

      Creates or validates the sole realm identity record.
      Parameters:
      expected - expected immutable realm record
      Returns:
      existing or newly created exact realm record
    • createPrincipal

      public void createPrincipal(SecurityPrincipal value)
      Creates one principal.
      Parameters:
      value - validated record to create
    • replacePrincipal

      public void replacePrincipal(SecurityPrincipal current, SecurityPrincipal updated)
      Replaces one exact principal.
      Parameters:
      current - caller-observed current record
      updated - replacement record with the same identity
    • requirePrincipal

      public SecurityPrincipal requirePrincipal(String principalId)
      Returns one principal or fails without revealing storage details.
      Parameters:
      principalId - stable principal identifier
      Returns:
      exact principal
    • principals

      public ServerControlStore.Page<SecurityPrincipal> principals(int offset, int limit)
      Returns a bounded stable page of principals in metadata-key order.
      Parameters:
      offset - zero-based page offset
      limit - positive page-size limit
      Returns:
      bounded principal page
    • createAssignment

      public void createAssignment(RoleTemplateCatalog.Assignment value)
      Creates one scoped role assignment.
      Parameters:
      value - validated record to create
    • requireAssignment

      public RoleTemplateCatalog.Assignment requireAssignment(String assignmentId)
      Returns one role assignment.
      Parameters:
      assignmentId - stable role-assignment identifier
      Returns:
      exact role assignment
    • replaceAssignment

      public void replaceAssignment(RoleTemplateCatalog.Assignment current, RoleTemplateCatalog.Assignment updated)
      Replaces one exact role assignment.
      Parameters:
      current - caller-observed current record
      updated - replacement record with the same identity
    • assignments

      public ServerControlStore.Page<RoleTemplateCatalog.Assignment> assignments(int offset, int limit)
      Returns a bounded stable page of role assignments.
      Parameters:
      offset - zero-based page offset
      limit - positive page-size limit
      Returns:
      bounded role-assignment page
    • assignmentsFor

      public List<RoleTemplateCatalog.Assignment> assignmentsFor(String principalId)
      Lists assignments for one principal from one stable metadata snapshot.
      Parameters:
      principalId - stable principal identifier
      Returns:
      immutable assignments for the principal
    • createGrant

      public void createGrant(Permission.Grant value)
      Creates one direct grant.
      Parameters:
      value - validated record to create
    • requireGrant

      public Permission.Grant requireGrant(String grantId)
      Returns one direct grant.
      Parameters:
      grantId - stable grant identifier
      Returns:
      exact permission grant
    • grants

      public ServerControlStore.Page<Permission.Grant> grants(int offset, int limit)
      Returns a bounded stable page of direct grants.
      Parameters:
      offset - zero-based page offset
      limit - positive page-size limit
      Returns:
      bounded grant page
    • replaceGrant

      public void replaceGrant(Permission.Grant current, Permission.Grant updated)
      Replaces one direct grant.
      Parameters:
      current - caller-observed current record
      updated - replacement record with the same identity
    • grantsFor

      public List<Permission.Grant> grantsFor(String principalId)
      Lists direct grants for one principal from one stable snapshot.
      Parameters:
      principalId - stable principal identifier
      Returns:
      immutable direct grants for the principal
    • createApproval

      public void createApproval(ApprovalService.Request value)
      Creates one approval request.
      Parameters:
      value - validated record to create
    • replaceApproval

      public void replaceApproval(ApprovalService.Request current, ApprovalService.Request updated)
      Replaces one approval request through compare-and-replace.
      Parameters:
      current - caller-observed current record
      updated - replacement record with the same identity
    • requireApproval

      public ApprovalService.Request requireApproval(String approvalId)
      Returns one approval request.
      Parameters:
      approvalId - stable approval identifier
      Returns:
      exact approval request
    • approvals

      public ServerControlStore.Page<ApprovalService.Request> approvals(int offset, int limit)
      Returns a bounded stable page of approval records.
      Parameters:
      offset - zero-based page offset
      limit - positive page-size limit
      Returns:
      bounded approval page
    • pendingApprovalCount

      public long pendingApprovalCount(Instant now)
      Counts pending, unexpired approvals in one stable metadata scan using constant auxiliary memory.
      Parameters:
      now - evaluation instant
      Returns:
      exact count in this snapshot
    • createBreakGlass

      public void createBreakGlass(BreakGlassService.Record value)
      Creates one break-glass record.
      Parameters:
      value - validated record to create
    • replaceBreakGlass

      public void replaceBreakGlass(BreakGlassService.Record current, BreakGlassService.Record updated)
      Replaces one break-glass record.
      Parameters:
      current - caller-observed current record
      updated - replacement record with the same identity
    • requireBreakGlass

      public BreakGlassService.Record requireBreakGlass(String breakGlassId)
      Returns one break-glass record.
      Parameters:
      breakGlassId - stable break-glass identifier
      Returns:
      exact break-glass record
    • breakGlassFor

      public List<BreakGlassService.Record> breakGlassFor(String principalId)
      Lists break-glass records for one principal.
      Parameters:
      principalId - stable principal identifier
      Returns:
      immutable break-glass records for the principal
    • breakGlass

      public ServerControlStore.Page<BreakGlassService.Record> breakGlass(int offset, int limit)
      Returns a bounded stable page of break-glass records.
      Parameters:
      offset - zero-based page offset
      limit - positive page-size limit
      Returns:
      bounded break-glass page
    • createDisclosure

      public void createDisclosure(DisclosureService.Record value)
      Creates one disclosure record.
      Parameters:
      value - validated record to create
    • replaceDisclosure

      public void replaceDisclosure(DisclosureService.Record current, DisclosureService.Record updated)
      Replaces one disclosure record.
      Parameters:
      current - caller-observed current record
      updated - replacement record with the same identity
    • requireDisclosure

      public DisclosureService.Record requireDisclosure(PkiId objectId)
      Returns one disclosure record.
      Parameters:
      objectId - exact protected object identifier
      Returns:
      exact disclosure record
    • findDisclosure

      public Optional<DisclosureService.Record> findDisclosure(PkiId objectId)
      Finds one disclosure record without converting absence into an error.
      Parameters:
      objectId - exact protected object identifier
      Returns:
      matching record or empty
    • disclosures

      public ServerControlStore.Page<DisclosureService.Record> disclosures(int offset, int limit)
      Returns a bounded stable page of disclosure records.
      Parameters:
      offset - zero-based page offset
      limit - positive page-size limit
      Returns:
      bounded disclosure page
    • createCapability

      public void createCapability(DisclosureService.Capability value)
      Creates one commitment-only capability record.
      Parameters:
      value - validated record to create
    • replaceCapability

      public void replaceCapability(DisclosureService.Capability current, DisclosureService.Capability updated)
      Replaces one capability record.
      Parameters:
      current - caller-observed current record
      updated - replacement record with the same identity
    • requireCapability

      public DisclosureService.Capability requireCapability(String capabilityId)
      Returns one capability record.
      Parameters:
      capabilityId - stable capability identifier
      Returns:
      exact capability metadata
    • protocolRecord

      public Optional<ServerControlStore.ProtocolRecord> protocolRecord(String namespace, String recordId)
      Reads one exact protocol record from its closed namespace.
      Parameters:
      namespace - closed protocol namespace
      recordId - canonical protocol record identifier
      Returns:
      matching protocol record or empty
    • protocolRecords

      public ServerControlStore.Page<ServerControlStore.ProtocolRecord> protocolRecords(String namespace, int offset, int limit)
      Returns one bounded deterministic page of protocol records.
      Parameters:
      namespace - closed protocol namespace
      offset - zero-based page offset
      limit - positive page-size limit
      Returns:
      bounded protocol-record page
    • protocolSnapshot

      public ServerControlStore.ProtocolCursor protocolSnapshot(String namespace)
      Opens a single consistent protocol snapshot for linear-time startup accounting. The caller must close the thread-confined cursor before closing this store. Traversal and caller processing occur outside the control monitor. Each step retains one bounded record; the metadata provider owns snapshot resources.
      Parameters:
      namespace - closed protocol namespace
      Returns:
      caller-owned snapshot cursor
    • mutateProtocol

      public void mutateProtocol(List<ServerControlStore.ProtocolMutation> requested)
      Atomically creates or compare-and-replaces a finite set of protocol records. Empty expected commitments mean create-only; present commitments mean exact compare-and-replace. Provider I/O and PKI operations must occur outside this method.
      Parameters:
      requested - finite nonempty atomic mutation set
    • selectCapabilities

      public List<DisclosureService.Capability> selectCapabilities(PkiId objectId, Optional<String> after, int limit, CancellationSignal cancellation)
      Selects capabilities for one already-authorized object in ascending capability-ID order. The namespace is scanned once; O(N log L) comparisons and O(L) retained rows, plus decoded record I/O.
      Parameters:
      objectId - exact object whose disclosure-read scope the gateway authorized
      after - exclusive capability identifier
      limit - maximum rows, 1 through 1001 including lookahead
      cancellation - cooperative cancellation checked for each record
      Returns:
      immutable bounded page; no global count or namespace cursor
    • capabilitiesFor

      public List<DisclosureService.Capability> capabilitiesFor(PkiId objectId)
      Lists capability commitments bound to one object.
      Parameters:
      objectId - exact protected object identifier
      Returns:
      immutable capability metadata for the object
    • createRepositoryAlias

      public void createRepositoryAlias(RepositoryAliasService.Record value)
      Creates one exact repository alias record.
      Parameters:
      value - validated record to create
    • findRepositoryAlias

      public Optional<RepositoryAliasService.Record> findRepositoryAlias(String aliasId)
      Finds one exact repository alias record.
      Parameters:
      aliasId - stable repository-alias identifier
      Returns:
      matching alias or empty
    • requireRepositoryAlias

      public RepositoryAliasService.Record requireRepositoryAlias(String aliasId)
      Returns one exact repository alias record.
      Parameters:
      aliasId - stable repository-alias identifier
      Returns:
      exact alias record
    • replaceRepositoryAlias

      public void replaceRepositoryAlias(RepositoryAliasService.Record current, RepositoryAliasService.Record updated, Optional<String> expectedCurrentCommitment)
      Atomically replaces an alias after exact expected-current validation.
      Parameters:
      current - caller-observed current record
      updated - replacement record with the same identity
      expectedCurrentCommitment - optional expected current record commitment
    • repositoryAliases

      public ServerControlStore.Page<RepositoryAliasService.Record> repositoryAliases(int offset, int limit)
      Returns a bounded repository alias page.
      Parameters:
      offset - zero-based page offset
      limit - positive page-size limit
      Returns:
      bounded repository-alias page
    • validateAll

      public void validateAll()
      Strictly decodes and cross-checks every authoritative control record from stable metadata snapshots before the realm is exposed.
    • validateReferences

      public void validateReferences(RoleTemplateCatalog roles)
      Validates durable relationships against the active strict role catalog.
      Parameters:
      roles - active strict role-template catalog
    • close

      public void close() throws IOException
      Opens no sidecar authority and closes the sole metadata authority idempotently.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException