Secrets Manager Java SDK
The Java language wrapper for interacting with the Bitwarden Secrets Manager. The SDK, like the Secrets Manager CLI built on-top of it, can be used to execute the following operations:
Authenticate using an access token.
Perform commands for secret and project including:
list
,create
,update
anddelete
.
Hinweis
This SDK is a beta release. Therefore, some functionality may be missing.
Setting up a Secrets Manager account prior to using the Java SDK is recommended. This includes:
Enabling the Secrets Manager CLI.
Setting up machine accounts.
Setting up access tokens.
Locate the Java GitHub repository here.
Insert the created access token
to authorize the Secrets Manager session:
Bashimport com.bitwarden.sdk.*;
BitwardenSettings bitwardenSettings = new BitwardenSettings();
bitwardenSettings.setApiUrl("https://api.bitwarden.com");
bitwardenSettings.setIdentityUrl("https://identity.bitwarden.com");
BitwardenClient bitwardenClient = new BitwardenClient(bitwardenSettings);
bitwardenClient.accessTokenLogin("<access-token>");
Once the Bitwarden client has been created and authorized, Secrets Manager commands can be passed into the client:
The project command is used to access, manipulate, and create projects. The scope of access assigned to your machine account will determine what actions can be completed with the project
command.
create project
BashUUID organizationId = UUID.fromString("<organization-id>");
var projectResponse = bitwardenClient.projects().create(organizationId, "TestProject");
UUID projectId = projectResponse.getID();
get project
Bashvar projectResponse = bitwardenClient.projects().get(projectId);
list projects
Bashvar projectsResponse = bitwardenClient.projects().list(organizationId);
update project
BashprojectResponse = bitwardenClient.projects.update(projectId, organizationId, "TestProjectUpdated");
delete project
BashbitwardenClient.projects().delete(new UUID[]{projectId});
The secret command is used to access, manipulate and create secrets. As with all commands, secrets and projects outside your access token's scope of access cannot be read or written-to.
create secret
BashString key = "key";
String value = "value";
String note = "note";
var secretResponse = bitwardenClient.secrets().create(key, value, note, organizationId, new UUID[]{projectId});
UUID secretId = secretResponse.getID();
get secret
Bashvar secretResponse = bitwardenClient.secrets().get(secretId);
list secrets
Bashvar secretIdentifiersResponse = bitwardenClient.secrets().list(organizationId);
update secret
Bashvar secretResponse = bitwardenClient.secrets().update(secretId, key2, value2, note2, organizationId, new UUID[]{projectId});
delete secret
BashbitwardenClient.secrets().delete(new UUID[]{secretId});
Änderungen an dieser Seite vorschlagen
Wie können wir diese Seite für Sie verbessern?
Bei technischen, Rechnungs- und Produktfragen wenden Sie sich bitte an den Support