Package dev.dokimos.server.service
Class LlmCredentialService
java.lang.Object
dev.dokimos.server.service.LlmCredentialService
Resolves and protects the API key for an
LlmConnection. Inline keys are encrypted with
AES-256-GCM under a key derived from the configured encryption secret; external keys are read from
the named environment variable at resolution time. The master encryption secret is required only
when an inline key is encrypted or decrypted, so deployments that use only environment-backed
connections need not configure it.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionencryptInlineKey(LlmConnection connection, String rawKey) Returns a copy of the connection with its inline key encrypted.resolveKey(LlmConnection connection) Resolves the effective plaintext API key for a connection.
-
Constructor Details
-
LlmCredentialService
-
-
Method Details
-
encryptInlineKey
Returns a copy of the connection with its inline key encrypted. Used on the create path before the connection is persisted.- Parameters:
connection- the connection to populaterawKey- the plaintext API key supplied by the caller- Returns:
- the connection with
encryptedApiKeyset - Throws:
IllegalStateException- if the encryption secret is not configured
-
resolveKey
Resolves the effective plaintext API key for a connection.- Parameters:
connection- the connection to resolve- Returns:
- the plaintext API key
- Throws:
IllegalStateException- if a referenced environment variable is absent, or if an inline key cannot be decrypted, or if neither credential source is set
-