Class Secrets
- All Implemented Interfaces:
AutoCloseable
Manage application secrets through one consistent API.
Chilkat.Secrets provides a unified interface for storing,
retrieving, listing, and deleting secrets across local, cloud-based, and
in-memory secret stores. It supports string, binary, and JSON secrets, making
it useful for passwords, API keys, OAuth credentials, tokens, unlock codes,
certificates, and private configuration data.
Local secure storage
- Windows Credential Manager
- Apple Keychain
Cloud secret managers
- AWS Secrets Manager
- Azure Key Vault
- IBM Cloud Secrets Manager
- Oracle Cloud Secrets
- Doppler Secrets
Temporary secrets
Use in-memory secrets when values should exist only for the lifetime of the running process.
Flexible content types
Store and retrieve secrets as strings, binary data, or structured JSON.
Note: Cloud-based secret managers often require local bootstrap credentials. These can be stored securely in the Windows Credential Manager or Apple Keychain and then used to authenticate to the cloud secret manager.
Start with the Conceptual Overview and Components of a Secret Name. For an extended overview, see the Secrets Class Overview.
</section>
Event-capable: long-running methods report progress through a ProgressListener installed
with setProgressListener(ProgressListener), onAbortCheck(BooleanSupplier),
onPercentDone(IntPredicate) or onProgressInfo(BiConsumer).
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteSecret(JsonObject jsonId)Deletes a secret.booleanThe AutoSplit property is specific tolocal_managersecrets on Windows.booleanIf set totrue, then the contents of the secret will be stored compressed.The location of the secrets.Returns the installed listener, ornull.voidgetSecretBd(JsonObject jsonId, BinData bd)Fetches a binary secret and returns the content inbd.voidgetSecretJson(JsonObject jsonId, JsonObject jsonOut)Fetches a JSON secret and returns the content injsonOut.voidgetSecretSb(JsonObject jsonId, StringBuilder sb)Fetches a string secret and returns the content insb.getSecretStr(JsonObject jsonId)Fetches a string secret and returns the content of the secret.This is a catch-all property to be used for uncommon needs.voidlistSecrets(JsonObject json, JsonObject jsonOut)Lists secrets matching the wildcarded or exact values passed injson.voidonAbortCheck(BooleanSupplier callback)Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it.voidonPercentDone(IntPredicate callback)Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it.voidonProgressInfo(BiConsumer<String,String> callback)Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds.voidsecretSpecToJson(String secretSpec, JsonObject json)Converts a secret specification string (secretSpec) to JSON.voidsetAutoSplit(boolean value)Sets theAutoSplitproperty; seegetAutoSplit().voidsetBootstrapSecret(JsonObject jsonId, Secrets secretContent)Accessing a cloud-based secrets manager requires authentication credentials, which cannot be stored in the manager itself.voidsetCompression(boolean value)Sets theCompressionproperty; seegetCompression().voidsetLocation(String value)Sets theLocationproperty; seegetLocation().voidsetProgressListener(ProgressListener listener)Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.voidsetUncommonOptions(String value)Sets theUncommonOptionsproperty; seegetUncommonOptions().voidupdateSecretBd(JsonObject jsonId, BinData secret)Creates a binary secret if it does not yet exist, or updates an existing secret.voidupdateSecretJson(JsonObject jsonId, JsonObject secret)Creates a JSON secret if it does not yet exist, or updates an existing secret.voidupdateSecretSb(JsonObject jsonId, StringBuilder sb)Creates a string secret if it does not yet exist, or updates an existing secret.voidupdateSecretStr(JsonObject jsonId, String secret)Creates a string secret if it does not yet exist, or updates an existing secret.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
Secrets
public Secrets()Creates a newSecretsobject.
-
-
Method Details
-
getAutoSplit
public boolean getAutoSplit()The AutoSplit property is specific tolocal_managersecrets on Windows. The Windows Credentials Manager supports a maximum of 2560 bytes per secret. If a secret exceeds this size, it will be automatically compressed and split when created or updated, and automatically recomposed when retrieved.A secret can be split into a maximum of 10 parts.
The default value is
true.- Returns:
- the value of the
AutoSplitproperty
-
setAutoSplit
public void setAutoSplit(boolean value)Sets theAutoSplitproperty; seegetAutoSplit().- Parameters:
value- the new value
-
getCompression
public boolean getCompression()If set totrue, then the contents of the secret will be stored compressed. The default value of this property isfalse.- Returns:
- the value of the
Compressionproperty
-
setCompression
public void setCompression(boolean value)Sets theCompressionproperty; seegetCompression().- Parameters:
value- the new value
-
getLocation
The location of the secrets. Possible values are:local_manager- On Windows this is the Credentials Manager. On MacOS and iOS it is the Keychain. This is not yet an option on Linux or Android.aws_secrets_manager- AWS Secrets Managerazure_key_vault- Azure Key Vaultibm_cloud- IBM Cloud Secrets Manageroracle_cloud- Oracle Cloud Secretsdoppler- Doppler Secretsmemory- In-Memory Secrets
The default location is the
local_manager. On Linux and Android,local_managerwill behave the same asmemory.- Returns:
- the value of the
Locationproperty
-
setLocation
Sets theLocationproperty; seegetLocation().- Parameters:
value- the new value (notnull)
-
getUncommonOptions
This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.- Returns:
- the value of the
UncommonOptionsproperty
-
setUncommonOptions
Sets theUncommonOptionsproperty; seegetUncommonOptions().- Parameters:
value- the new value (notnull)
-
deleteSecret
Deletes a secret. Cloud secrets managers will typically disable the secret and schedule the secret for deletion after some number of days.- Parameters:
jsonId- thejsonIdargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getSecretBd
Fetches a binary secret and returns the content inbd.- Parameters:
jsonId- thejsonIdargument (notnull)bd- thebdargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getSecretJson
Fetches a JSON secret and returns the content injsonOut.- Parameters:
jsonId- thejsonIdargument (notnull)jsonOut- thejsonOutargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getSecretSb
Fetches a string secret and returns the content insb.- Parameters:
jsonId- thejsonIdargument (notnull)sb- thesbargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getSecretStr
Fetches a string secret and returns the content of the secret.- Parameters:
jsonId- thejsonIdargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
listSecrets
Lists secrets matching the wildcarded or exact values passed injson. The results of the query are returned injsonOut.- Parameters:
json- thejsonargument (notnull)jsonOut- thejsonOutargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
secretSpecToJson
Converts a secret specification string (secretSpec) to JSON. A secret specification string is formatted as "!!part1|part2|part3|part4" where parts 3 and 4 are optional.jsonis the output argument.- Parameters:
secretSpec- thesecretSpecargument (notnull)json- thejsonargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setBootstrapSecret
Accessing a cloud-based secrets manager requires authentication credentials, which cannot be stored in the manager itself. Instead, they must be securely stored locally.One solution is to store the authentication credentials as a secret in the Windows Credentials Manager or Apple Keychain. These credentials serve as the
bootstrap secretfor authenticating with the cloud-based secrets manager.jsonIdcontains the name of the bootstrap secret.secretContentcontains the bootstrap's secret content.- Parameters:
jsonId- thejsonIdargument (notnull)secretContent- thesecretContentargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
updateSecretBd
Creates a binary secret if it does not yet exist, or updates an existing secret. The name of the secret is specified injsonId, and the binary content of the secret insecret.- Parameters:
jsonId- thejsonIdargument (notnull)secret- thesecretargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
updateSecretJson
Creates a JSON secret if it does not yet exist, or updates an existing secret. The name of the secret is specified injsonId, and the JSON content of the secret insecret.- Parameters:
jsonId- thejsonIdargument (notnull)secret- thesecretargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
updateSecretSb
Creates a string secret if it does not yet exist, or updates an existing secret. The name of the secret is specified injsonId, and the string content of the secret insb.- Parameters:
jsonId- thejsonIdargument (notnull)sb- thesbargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
updateSecretStr
Creates a string secret if it does not yet exist, or updates an existing secret. The name of the secret is specified injsonId, and the string content of the secret insecret.Note: Starting in Chilkat v11.3.0, if the
service="Chilkat"and theusername="unlock_code", then the secret (which is the Chilkat unlock code) can be stored and retrieved without Chilkat being unlocked. This allows for the Chilkat unlock code itself to be persisted to a secrets manager.- Parameters:
jsonId- thejsonIdargument (notnull)secret- thesecretargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setProgressListener
Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.- Parameters:
listener- the listener, ornull- Throws:
IllegalStateException- if called from inside one of this object's own callbacks
-
getProgressListener
Returns the installed listener, ornull.- Returns:
- the listener installed with
setProgressListener(ProgressListener)or one of theon...methods
-
onAbortCheck
Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onPercentDone
Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onProgressInfo
Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-