Skip to main content

Vault | Java SDK

List

getBulk(GetBulkRequest request)

Retrieve a list of secrets, keys and folders.

required parameters

GetBulkRequest

Request parameters.

Response Object

ListResponse

A list of items.

 final var filter = new HashMap<String, String>();
 filter.put("folder", "/tmp");
 final var response = client.getBulk(GetBulkRequest.builder().filter(filter).build());

State change

stateChange(String id, ItemVersionState state, int version, String destroyPeriod)

Change the state of a specific version of a secret or key.

required parameters

String

Item id to change.

ItemVersionState

State to set to item version.

int

Item version to change.

String

Response Object

StateChangeResponse

StateChangeResponse

 final var stateChangeResponse = client.stateChange("id", ItemVersionState.DEACTIVATED);

Delete

delete(String id)

Delete a secret or key.

required parameters

String
  • item id to delete

Response Object

DeleteResponse

DeleteResponse

 DeleteResponse deleteResponse = client.delele("id");

Retrieve

get(GetRequest request)

Retrieve a secret or key, and any associated information.

required parameters

GetRequest
  • request to /get endpoint

Response Object

GetResponse

GetResponse

 GetResponse getResponse = client.get(
 	new GetRequest.GetRequestBuilder("id").build()
 );

List

list(ListRequest request)

Retrieve a list of secrets, keys and folders, and their associated information.

required parameters

ListRequest
  • request parameters to send to list endpoint

Response Object

ListResponse

ListResponse

 ListResponse listResponse = client.list(
 	new ListRequest.ListRequestBuilder().build()
 );

Update

update(UpdateRequest request)

Update information associated with a secret or key.

required parameters

UpdateRequest
  • request parameters to send to update endpoint

Response Object

UpdateResponse

UpdateResponse

 UpdateResponse updateResponse = client.update(
 	new UpdateRequest.UpdateRequestBuilder("id")
 	.setFolder("updated")
 	.build()
 );

Store a secret

secretStore(SecretStoreRequest request)

Store a secret in vault service.

required parameters

SecretStoreRequest
  • request parameters to send to /secret/store endpoint

Response Object

SecretStoreResponse

SecretStoreResponse

 SecretStoreResponse storeResponse =
 	client.secretStore(new SecretStoreRequest.SecretStoreRequestBuilder("mysecret", "mysecretname").build());

Store a Pangea Token

pangeaTokenStore(PangeaTokenStoreRequest request)

Store a pangea token in vault service.

required parameters

PangeaTokenStoreRequest
  • request parameters to send to /secret/store endpoint

Response Object

SecretStoreResponse

SecretStoreResponse

 SecretStoreResponse storeResponse =
 	client.pangeaTokenStore(new PangeaTokenStoreRequest.PangeaTokenStoreRequestBuilder("mytoken", "mytokenname").build());

Rotate a secret

secretRotate(SecretRotateRequest request)

Rotate a secret in vault service.

required parameters

SecretRotateRequest
  • secret rotate request

Response Object

SecretRotateResponse

SecretRotateResponse

 SecretRotateResponse rotateResponse = client.secretRotate(
 	new SecretRotateRequest.SecretRotateRequestBuilder("secretid", "mynewsecret")
 		.setRotationState(ItemVersionState.SUSPENDED)
 		.build()
 );

Rotate a Pangea Token

pangeaTokenRotate(PangeaTokenRotateRequest request)

Rotate a Pangea Token in vault service.

required parameters

PangeaTokenRotateRequest
  • pangea token store request

Response Object

SecretRotateResponse

SecretRotateResponse

 SecretRotateResponse rotateResponse = client.pangeaTokenRotate(
 	new PangeaTokenStoreRequest.PangeaTokenRotateRequestBuilder("tokenid", "3m")
 		.build()
 );

Symmetric generate

symmetricGenerate(SymmetricGenerateRequest request)

Generate a symmetric key.

required parameters

SymmetricGenerateRequest
  • request parameters to send to /key/generate endpoint

Response Object

SymmetricGenerateResponse

SymmetricGenerateResponse

 SymmetricGenerateRequest generateRequest = new SymmetricGenerateRequest.SymmetricGenerateRequestBuilder(
 	SymmetricAlgorithm.AES128_CFB,
 	KeyPurpose.ENCRYPTION,
 	"keyname"
 ).build();
 SymmetricGenerateResponse generateResp = client.symmetricGenerate(generateRequest);

Asymmetric generate

asymmetricGenerate(AsymmetricGenerateRequest request)

Generate an asymmetric key.

required parameters

AsymmetricGenerateRequest
  • request parameters to send to /key/generate endpoint

Response Object

AsymmetricGenerateResponse

AsymmetricGenerateResponse

 AsymmetricGenerateRequest generateRequest = new AsymmetricGenerateRequest.AsymmetricGenerateRequestBuilder(
 	AsymmetricAlgorithm.ED25519,
 	KeyPurpose.SIGNING,
 	"keyname"
 ).build();
 AsymmetricGenerateResponse generateResp = client.asymmetricGenerate(generateRequest);

Asymmetric store

asymmetricStore(AsymmetricStoreRequest request)

Import an asymmetric key.

required parameters

AsymmetricStoreRequest
  • request parameters to send to /key/store endpoint

Response Object

AsymmetricStoreResponse

AsymmetricStoreResponse

 AsymmetricStoreRequest storeRequest = new AsymmetricStoreRequest.AsymmetricStoreRequestBuilder(
 	"encodedprivatekey",
 	"encodedpublickey",
 	AsymmetricAlgorithm.ED25519,
 	KeyPurpose.SIGNING,
 	"keyname"
 ).build();
 AsymmetricStoreResponse storeResp = client.asymmetricStore(storeRequest);

Symmetric store

symmetricStore(SymmetricStoreRequest request)

Import a symmetric key.

required parameters

SymmetricStoreRequest
  • request parameters to send to /key/store endpoint

Response Object

SymmetricStoreResponse

SymmetricStoreResponse

 SymmetricStoreRequest storeRequest = new SymmetricStoreRequest.SymmetricStoreRequestBuilder(
 	"encodedkey"
 	SymmetricAlgorithm.AES,
 	KeyPurpose.ENCRYPTION,
 	"keyname"
 ).build();
 SymmetricStoreResponse storeResp = client.symmetricStore(storeRequest);

Key rotate

keyRotate(KeyRotateRequest request)

Manually rotate a symmetric or asymmetric key.

required parameters

KeyRotateRequest
  • request parameters to send to /key/rotate endpoint

Response Object

KeyRotateResponse

KeyRotateResponse

 KeyRotateResponse rotateResponse = client.keyRotate(
 	new KeyRotateRequest.KeyRotateRequestBuilder("keyid", ItemVersionState.SUSPENDED).build()
 );

Encrypt

encrypt(EncryptRequest request)

Encrypt a message using a key.

required parameters

EncryptRequest
  • request to be send to /key/encrypt

Response Object

EncryptResponse

EncryptResponse

 EncryptResponse encryptResponse = client.encrypt(
 	new EncryptRequest.EncryptRequestBuilder("keyid", "base64message").setVersion(2).build()
 );

Decrypt

decrypt(DecryptRequest request)

Decrypt a message using a key.

required parameters

DecryptRequest
  • request to be send to /key/decrypt

Response Object

DecryptResponse

DecryptResponse

 DecryptResponse decryptResponse = client.decrypt(
 	new DecryptRequest.DecryptRequestBuilder("keyid", "validciphertext")
 		.setVersion(2)
 		.build()
 );

Sign

sign(String id, String message)

Sign a message using a key.

required parameters

String
  • key id to sign message
String
  • message to sign

Response Object

SignResponse

SignResponse

 SignResponse signResponse = client.sign("keyid", "base64data2sign");

Sign

sign(String id, String message, int version)

sign a message

required parameters

String
  • key id to sign message
String
  • message to sign
int
  • key version to sign message

Response Object

SignResponse

SignResponse

 SignResponse signResponse = client.sign("keyid", "base64data2sign", 2);

JWT Sign

jwtSign(String id, String payload)

Sign a JSON Web Token (JWT) using a key.

required parameters

String
  • key id to sign payload
String
  • message to sign

Response Object

JWTSignResponse

JWTSignResponse

 String payload = """
      {'message': 'message to sign', 'data': 'Some extra data'}
       """;
 JWTSignResponse signResponse1 = client.jwtSign("keyid", payload);

Verify

verify(String id, String message, String signature)

Verify a signature using a key.

required parameters

String
  • key id to verify message/signature
String
  • message to verify
String
  • signature to verify

Response Object

VerifyResponse

VerifyResponse

 VerifyResponse verifyResponse = client.verify("keyid", "data2verify", "signature");

Verify

verify(String id, String message, String signature, Integer version)

Verify a signature using a key.

required parameters

String
  • key id to verify message/signature
String
  • message to verify
String
  • signature to verify
Integer
  • key version to use on verification

Response Object

VerifyResponse

VerifyResponse

 VerifyResponse verifyResponse = client.verify("keyid", "data2verify", "signature", 1);

JWT Verify

jwtVerify(String jws)

Verify the signature of a JSON Web Token (JWT).

required parameters

String
  • signature to verify

Response Object

JWTVerifyResponse

JWTVerifyResponse

 JWTVerifyResponse verifyResponse = client.jwtVerify(signResponse.getResult().getJws());

JWT Retrieve

jwkGet(String id)

Retrieve a key in JWK format.

required parameters

String
  • item id to get

Response Object

JWKGetResponse

GetResponse

 JWKGetResponse getResponse = client.jwkGet("jwkid");

JWT Retrieve

jwkGet(String id, String version)

Retrieve a key in JWK format.

required parameters

String
  • item id to get
String
  • item version/versions to get

Response Object

JWKGetResponse

GetResponse

 JWKGetResponse getResponse = client.jwkGet("jwkid", 2);

Create

folderCreate(FolderCreateRequest request)

Creates a folder.

required parameters

FolderCreateRequest
  • request parameters to send to /folder/create endpoint

Response Object

FolderCreateResponse

FolderCreateResponse

 FolderCreateResponse createParentResp = client.folderCreate(
 	new FolderCreateRequest.Builder("folder_name", "parent/folder/name").build()
 );

Encrypt structured

encryptStructured(EncryptStructuredRequest request)

Encrypt parts of a JSON object.

required parameters

EncryptStructuredRequest

Request parameters.

Response Object

EncryptStructuredResponse

Encrypted result.

 var request = new EncryptStructuredRequest.Builder<SomeModel>(
     key,
     data,
     "$.field1[2:4]"
 ).build();
 var encrypted = client.encryptStructured(request);

Decrypt structured

decryptStructured(EncryptStructuredRequest request)

Decrypt parts of a JSON object.

required parameters

EncryptStructuredRequest

Request parameters.

Response Object

EncryptStructuredResponse

Decrypted result.

 var request = new EncryptStructuredRequest.Builder<SomeModel>(
     key,
     data,
     "$.field1[2:4]"
 ).build();
 var encrypted = client.decryptStructured(request);

Encrypt transform

encryptTransform(EncryptTransformRequest request)

Encrypt using a format preserving algorithm (FPE).

required parameters

EncryptTransformRequest

Request parameters.

Response Object

EncryptTransformResponse

Encrypted response.

 var encrypted = client.encryptTransform(
 	new EncryptTransformRequest.Builder(
 		"pvi_[...]",
 		"123-4567-8901",
 		TransformAlphabet.ALPHANUMERIC
 	).tweak("MTIzMTIzMT==").build()
 );

Decrypt transform

decryptTransform(DecryptTransformRequest request)

Decrypt using a format preserving algorithm (FPE).

required parameters

DecryptTransformRequest

Request parameters.

Response Object

DecryptTransformResponse

Decrypted response.

 var decrypted = client.decryptTransform(
 	new DecryptTransformRequest.Builder(
 		"pvi_[...]",
 		"tZB-UKVP-MzTM",
 		"MTIzMTIzMT==",
 		TransformAlphabet.ALPHANUMERIC
 	).build()
 );

Export

export(ExportRequest request)

Export a symmetric or asymmetric key.

required parameters

ExportRequest

Request parameters.

Response Object

ExportResponse

Exported result.

 // Generate an exportable key.
 final var generateRequest = new AsymmetricGenerateRequest.Builder(
 	AsymmetricAlgorithm.RSA4096_OAEP_SHA512,
 	KeyPurpose.ENCRYPTION,
 	"a-name-for-the-key"
 )
 	.exportable(true)
 	.build();
 final var generated = client.asymmetricGenerate(generateRequest);
 final var key = generated.getResult().getId();

 // Then it can be exported whenever needed.
 final var request = ExportRequest.builder(key).build();
 final var exported = client.export(request);