Reference
Java SDK
You can use our Java SDK to:
- Encrypt data server-side
- Invoke Functions
- Decrypt data through Outbound Relay
Encrypting data with our backend SDKs instead of Inbound Relay may expose you to greater compliance burden because plaintext data touches your server before it is encrypted.
Instead you can:
- Use an Inbound Relay to encrypt data before it reaches your server.
- Use our client-side SDKs to encrypt data before sending it to your server.
Quickstart
Install SDK
First, let's install the Evervault SDK using either gradle
or maven
.
Initialize SDK
Now, let's initialize the SDK using our App's API key. If you don't have one yet, you can get one by creating an App in the Evervault Dashboard.
Encrypt a string
Now that the SDK is initialized, we can encrypt a string.
Full example
Pulling all of this together leaves us with the following working example. You can copy and paste the code below (using a sandbox API key), run it in your own environment and run the encryption and decryption for yourself.
Reference
Evervault()
The SDK constructor accepts the following parameters:
- Your App's API key
- Optional configuration parameters
- Domain names to route through Outbound Relay
- Whether to enable Outbound Relay and fetch domain configuration from the Evervault API.
Example
Whether to enable Outbound Relay, and automatically intercept requests to Outbound Relay destinations.
evervault.encrypt(data)
Encrypts data using Evervault Encryption. Evervault Strings can be used across all of our products.
To encrypt data using the Java SDK, simply pass a string
or a map
into the evervault.encrypt()
function. encrypt()
will encrypt your data and return an object which is a String
in case you passed a literal type like bool
, String
, int
, float
, char
, byte
.
In case you pass a Map<literal, literal>
then the key will be preserved and the value will be an encrypted string. If a value is another map, for example, it will follow the sample principle recursively.
In case you pass a Vector
with literals the return will be a Vector
with encrypted strings.
The encrypted data can be stored in your database as normal and can be used with any of Evervault’s other services.
evervault.run(functionName, data, options)
Lets you invoke an Evervault Function with a given payload.
Additional options for running the function.
Response
Function runs will return a POJO containing a Function Run ID (public String runId
) and the result from your Function (public Object result
).
evervault.createRunToken(functionName, data)
Creates a single use, time bound token (5 minutes) for invoking an Evervault Function with a given payload.
Run Tokens can be used to invoke an Evervault Function client-side without providing a sensitive API Key.
Response
When you create a Run Token, a POJO containing 1 attribute is returned.
Run Tokens can then be used to authenticate Function runs from the client-side.