Class InMemoryPepperService
java.lang.Object
com.svenruppert.jsentinel.credential.password.pepper.InMemoryPepperService
- All Implemented Interfaces:
PepperService
In-process pepper key store for tests, demos and small single-node
deployments.
Keys are kept on the heap; the service holds defensive copies so the caller can zero the original bytes. This is not an HSM (see CWE-321 / CWE-798) — the operator must still keep the pepper material out of source control, off the password database and out of audit logs.
For a production deployment, plug in a PepperService
implementation backed by a secret manager (HSM, AWS KMS, HashiCorp
Vault, Kubernetes Secrets) instead.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionCurrently active pepper key id used by the policy when producing new hashes.builder()Builder for multi-key configurations (one active + zero or more retired, used by Phase-3 pepper rotation).intConvenience for tests: returns the number of known key ids.Optional<byte[]> Resolves the pepper material for a previously stored hash.voidwipe()Zeroes every held key and forgets all key ids.static InMemoryPepperServicewithActiveKey(String keyId, byte[] key) Convenience: build a service from a single active key.
-
Method Details
-
withActiveKey
Convenience: build a service from a single active key. -
builder
Builder for multi-key configurations (one active + zero or more retired, used by Phase-3 pepper rotation). -
activeKeyId
Description copied from interface:PepperServiceCurrently active pepper key id used by the policy when producing new hashes.Optional.empty()signals that no pepper is applied to new hashes.- Specified by:
activeKeyIdin interfacePepperService
-
resolve
Description copied from interface:PepperServiceResolves the pepper material for a previously stored hash.- Specified by:
resolvein interfacePepperService- Returns:
- the pepper bytes, or
Optional.empty()when no pepper service knows about this key id
-
wipe
public void wipe()Zeroes every held key and forgets all key ids. After this call the service has no active key andresolve(String)returnsOptional.empty()for every input. -
knownKeyCount
public int knownKeyCount()Convenience for tests: returns the number of known key ids.
-