Class EnrollmentProfileService
java.lang.Object
zeroecho.pki.server.enrollment.EnrollmentProfileService
Durable, thread-safe enrollment profile registry owned by one realm.
Writes use the server-control transaction boundary and compare-and-set commitments. Concurrent replacement conflicts fail rather than losing an update. Every stored replacement advances a revision, including a replacement with identical policy, so an intervening change cannot evade the comparison. The caller owns and closes the supplied store. Construction validates all persisted profiles before the realm accepts requests.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionOpens and validates the realm's durable registry. -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringcommitment(EnrollmentProfile profile) Commits every policy field using the same canonical encoding as persistence.Looks up the current profile by identifier.list()Collects all current profiles in deterministic store-key order.list(int offset, int limit) Reads a bounded page without retaining the complete registry.voidregister(EnrollmentProfile profile) Durably creates a profile; existing identities cannot be overwritten.requireBinding(String id, String certificateProfileId, String authorityId, boolean active) Resolves a compatible enrollment binding under the shared control monitor.static EnrollmentProfilerequireBinding(ServerControlStore control, String id, String certificateProfileId, String authorityId, boolean active) Resolves one policy without constructing another registry or scanning it.setState(String id, EnrollmentProfileState state) Transitions the profile to the given state.update(EnrollmentProfile profile) Updates an existing enrollment profile.
-
Constructor Details
-
EnrollmentProfileService
Opens and validates the realm's durable registry.- Parameters:
control- open realm-owned server-control store- Throws:
IllegalStateException- if a stored profile is corrupt or unsupported
-
-
Method Details
-
register
Durably creates a profile; existing identities cannot be overwritten.- Parameters:
profile- non-null immutable profile to persist- Throws:
IllegalStateException- if the identity exists or persistence fails
-
update
Updates an existing enrollment profile. Active endpoint bindings must remain compatible with the certificate profile and allowed authorities. Deregister incompatible endpoints before changing those fields; suspension itself is always permitted. Validation and commit share the control-store monitor with endpoint registration.- Parameters:
profile- non-null replacement profile- Returns:
- the durably committed replacement
- Throws:
IllegalArgumentException- if no profile with the given id existsIllegalStateException- if an active endpoint would become incompatible, a concurrent change conflicts, or persistence fails
-
find
Looks up the current profile by identifier.- Parameters:
id- non-null identifier- Returns:
- the observed profile, or empty if absent
-
list
Collects all current profiles in deterministic store-key order. Concurrent writes between pages need not form one atomic snapshot.- Returns:
- immutable profiles; O(N) retained profile memory
-
requireBinding
public EnrollmentProfile requireBinding(String id, String certificateProfileId, String authorityId, boolean active) Resolves a compatible enrollment binding under the shared control monitor.- Parameters:
id- enrollment policy identitycertificateProfileId- distinct certificate policy identityauthorityId- selected logical authorityactive- whether admission requires an active policy- Returns:
- exact current compatible policy
-
requireBinding
public static EnrollmentProfile requireBinding(ServerControlStore control, String id, String certificateProfileId, String authorityId, boolean active) Resolves one policy without constructing another registry or scanning it. Protocol registries use the same control monitor for validation and mutation.- Parameters:
control- owning realm authorityid- enrollment policy identitycertificateProfileId- selected certificate profileauthorityId- selected authorityactive- whether the profile must be active- Returns:
- exact compatible profile
-
list
Reads a bounded page without retaining the complete registry.- Parameters:
offset- nonnegative store-key offsetlimit- page size accepted by the server-control store- Returns:
- immutable page in deterministic store-key order
-
setState
Transitions the profile to the given state.- Parameters:
id- non-null profile identifierstate- non-null replacement state- Returns:
- the durably committed profile
- Throws:
IllegalArgumentException- if no profile with the given id existsIllegalStateException- if a concurrent change conflicts or persistence fails
-
commitment
Commits every policy field using the same canonical encoding as persistence. Set ordering is normalized; list ordering and optional-value presence are preserved.- Parameters:
profile- exact proposed policy- Returns:
- lowercase SHA-256 commitment, independent of its storage revision
- Throws:
IllegalArgumentException- if the profile exceeds the finite encoding bounds
-