Class CredentialLifecycleService
java.lang.Object
com.svenruppert.jsentinel.credential.lifecycle.CredentialLifecycleService
Owns the lifecycle of stored credentials and the rules for moving
between
CredentialStatus values.
Decision side
decide(CredentialStatus) is a pure function: given a
stored status, returns the adapter-neutral
CredentialLifecycleDecision. No I/O, no audit.
Transition side
transition(String, CredentialStatus, CredentialStatus, String)
checks the configured state machine, calls
CredentialStore.updateStatusIfCurrent(String, CredentialStatus, CredentialStatus, Instant) for the CAS, and
publishes CredentialStatusChanged on success. Disallowed
transitions throw InvalidStatusTransitionException
deterministically before touching the store
(CWE-284 / CWE-778).
-
Constructor Summary
ConstructorsConstructorDescriptionCredentialLifecycleService(CredentialStore store, JSentinelAuditService auditService, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptiondecide(CredentialStatus status) Pure decision: maps stored status onto the adapter-neutral lifecycle decision.booleanisAllowed(CredentialStatus from, CredentialStatus to) Returns whether a transition is part of the configured state machine.transition(String username, CredentialStatus expected, CredentialStatus target, String reason) Atomic state transition.
-
Constructor Details
-
CredentialLifecycleService
public CredentialLifecycleService(CredentialStore store, JSentinelAuditService auditService, Clock clock)
-
-
Method Details
-
decide
Pure decision: maps stored status onto the adapter-neutral lifecycle decision. -
isAllowed
Returns whether a transition is part of the configured state machine. Exposed so adapters can preview decisions. -
transition
public CredentialUpdateResult transition(String username, CredentialStatus expected, CredentialStatus target, String reason) Atomic state transition. Validates against the state machine, then performs a CAS through the store.- Parameters:
reason- optional structural reason key (kept short; audit-only)- Throws:
InvalidStatusTransitionException- ifexpected → targetis not part of the state machine
-