Class ZeroEchoSession
Each session owns one policy, audit listener, and audit mode. Configuration
methods return a new session and never mutate the receiver, so independently
created sessions cannot affect one another. The default configuration is a
permissive policy, a no-op listener, and AuditMode.OFF.
Sessions share the immutable provider registry owned by
CryptoAlgorithms; provider discovery is therefore performed once for
the registry lifecycle. Session instances are safe for concurrent use.
Configured policy and listener implementations must themselves support any
concurrency with which the session is used.
Audit callbacks may receive key and specification objects. Listeners are trusted application components and must not log or retain keys, plaintext, seeds, shared secrets, or sensitive specifications.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a session with a permissive policy, no-op audit listener, andAuditMode.OFF. -
Method Summary
Modifier and TypeMethodDescriptionReturns the audit listener owned by this session.Returns the audit mode owned by this session.Returns the available algorithm identifiers in deterministic registry order.<C extends CryptoContext, K extends Key>
CcreateContext(String id, KeyUsage role, K key) Creates a context using the selected algorithm's default specification.<C extends CryptoContext, K extends Key, S extends ContextSpec>
CcreateContext(String id, KeyUsage role, K key, S spec) Creates a context after applying this session's policy and audit configuration.booleandestroyKey(String algorithmId, String provider, Key key) Destroys a key and verifies that it entered the destroyed state.Returns exact session-bound key operations.Returns configured PBKDF2 limits.policy()Returns the policy owned by this session.Resolves an algorithm from the authoritative registry.withAuditListener(AuditListener newAuditListener) Returns a session with the supplied audit listener and this session's policy and audit mode.withAuditMode(AuditMode newAuditMode) Returns a session with the supplied audit mode and this session's policy and listener.withPbkdf2Limits(Pbkdf2Limits limits) Returns a session with explicit PBKDF2 work-factor limits.withPolicy(CryptoPolicy<ContextSpec, Key> newPolicy) Returns a session with the supplied policy and this session's audit configuration.
-
Constructor Details
-
ZeroEchoSession
public ZeroEchoSession()Creates a session with a permissive policy, no-op audit listener, andAuditMode.OFF.
-
-
Method Details
-
withPolicy
Returns a session with the supplied policy and this session's audit configuration.- Parameters:
newPolicy- policy applied before context creation; must not benull- Returns:
- a new independently configured session
- Throws:
NullPointerException- ifnewPolicyisnull
-
withAuditListener
Returns a session with the supplied audit listener and this session's policy and audit mode.- Parameters:
newAuditListener- listener receiving audit callbacks; must not benull- Returns:
- a new independently configured session
- Throws:
NullPointerException- ifnewAuditListenerisnull
-
withAuditMode
Returns a session with the supplied audit mode and this session's policy and listener.- Parameters:
newAuditMode- audit strategy; must not benull- Returns:
- a new independently configured session
- Throws:
NullPointerException- ifnewAuditModeisnull
-
withPbkdf2Limits
Returns a session with explicit PBKDF2 work-factor limits.- Parameters:
limits- deployment-selected limits- Returns:
- independently configured session
- Throws:
NullPointerException- iflimitsisnull
-
pbkdf2Limits
Returns configured PBKDF2 limits.- Returns:
- explicit deployment limits
- Throws:
IllegalStateException- if limits were not configured
-
policy
Returns the policy owned by this session.- Returns:
- the non-null policy strategy
-
auditListener
Returns the audit listener owned by this session.The returned listener is the configured strategy, not mutable session state. It is exposed to support manual audit mode.
- Returns:
- the non-null audit listener
-
auditMode
Returns the audit mode owned by this session.- Returns:
- the non-null audit mode
-
available
-
require
Resolves an algorithm from the authoritative registry.- Parameters:
id- canonical algorithm identifier- Returns:
- the registered algorithm
- Throws:
IllegalArgumentException- if no algorithm is registered underid
-
keyBuilders
Returns exact session-bound key operations.- Returns:
- immutable grouped key-operation entry point
-
createContext
public <C extends CryptoContext, K extends Key, S extends ContextSpec> C createContext(String id, KeyUsage role, K key, S spec) Creates a context after applying this session's policy and audit configuration.- Type Parameters:
C- context typeK- key typeS- context specification type- Parameters:
id- canonical algorithm identifierrole- intended key usagekey- key compatible with the selected algorithm and rolespec- optional context specification, ornullfor the algorithm default- Returns:
- a ready context, possibly audit-wrapped in
AuditMode.WRAP - Throws:
IllegalArgumentException- if the algorithm identifier is unknown or policy validation rejects the operationUnsupportedRoleException- if the algorithm does not supportroleUnsupportedSpecException- if the key or specification is incompatible
-
createContext
Creates a context using the selected algorithm's default specification.- Type Parameters:
C- context typeK- key type- Parameters:
id- canonical algorithm identifierrole- intended key usagekey- key compatible with the selected algorithm and role- Returns:
- a ready context, possibly audit-wrapped in
AuditMode.WRAP - Throws:
IllegalArgumentException- if the algorithm identifier is unknown or policy validation rejects the operationUnsupportedRoleException- if the algorithm does not supportrole
-
destroyKey
public boolean destroyKey(String algorithmId, String provider, Key key) throws DestroyFailedException Destroys a key and verifies that it entered the destroyed state.- Parameters:
algorithmId- algorithm identifier used as audit metadataprovider- provider name used as audit metadatakey- key to destroy; must not benull- Returns:
trueonly when this call transitions the key to destroyed;falsefor a non-destroyable or already destroyed key- Throws:
NullPointerException- ifkeyisnullDestroyFailedException- if destruction fails or the key does not report itself destroyed afterwardRuntimeException- if the key's lifecycle implementation throws one
-