The Akeyless Dev Hub

If you're looking for help with the only zero-trust, SaaS, unified platform for secrets management - you've come to the right place.

This is our documentation and updates center.

Documentation

To run the SDK you will need Java 1.7+. In the event you do not have it, go to Java SE Downloads on the Oracle website, then download and install the Java SE Development Kit (JDK). The recommended version is Java 8 or higher.

Note: If you use the Oracle JDK, you must also download and install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.

Get the latest release

To get the latest release, you can either download from github, or, get the latest release from Maven:

<dependency>
    <groupId>com.akeyless-security</groupId>
    <artifactId>akeyless-java-sdk</artifactId>
    <version>0.0.10</version>
</dependency>

Create, get, and update a Secret

package com.akeyless.examples;

import com.akeyless.AkeylessAdminClient;
import com.akeyless.config.AkeylessClientConfiguration;
import com.akeyless.uam.swagger.model.GetItemReplyObj;

public class SecretManagementExample {
    public static void main(final String[] args) throws Exception {
        String adminUserAccessId = args[0];
        String adminUserApiKey = args[1];

        String akeylessServerUrl = "<Akeyless URL>"; 
        AkeylessClientConfiguration config = new
          AkeylessClientConfiguration.Builder().
                setAddress(new URL(akeylessServerUrl)).
                setAccessId(adminUserAccessId).
                setApiKey(adminUserApiKey).build();

        AkeylessAdminClient adminClient = AkeylessAdminClient.Factory.newInstance(config);

        // Create new secret named "mySecret" that contains the value - "this is a secret"
        String secretName = "mySecret";
        String secretValue = "s3cr3t-va1ue#";
        String secretMetadata = "This is my Secret, don't tell anyone";
        adminClient.createSecret(secretName, secretValue, secretMetadata);

        // Get secret value
        String val = adminClient.getSecretValue(secretName);
        System.out.println("Secret value: " + val);

        // Get secret details
        GetItemReplyObj secretDetails = adminClient.describeItem(secretName);
        System.out.println("Secret details: " + secretDetails.toString());

        // Update secret value
        String newSecretValue = "NEW-s3cr3t-va1ue#";
        adminClient.updateSecretValue(secretName, newSecretValue);

        val = adminClient.getSecretValue(secretName);
        System.out.println("New secret value: " + val);

        adminClient.close();
    }
}

Now let's get a taste of some of the advanced stuff...

Encryption has never been easier

The following code sample demonstrates how to encrypt/decrypt data, doing so with no without messing around with Keys whatsoever:

// This sample code encrypts and then decrypts a string using an AES key from your AKEYLESS account.

package com.akeyless.examples;

import com.akeyless.AkeylessClient;
import com.akeyless.config.AkeylessClientConfiguration;


public class EncryptDecryptStringExample {

    public static void main(final String[] args) throws Exception {
        String userAccessId = args[0];
        String userApiKey = args[1];
        String encKeyName = args[2];
        String data = args[3];

        String akeylessServerUrl = "<AKEYLESS_URL>"; 
        AkeylessClientConfiguration config = new
          AkeylessClientConfiguration.Builder().
                setAddress(new URL(akeylessServerUrl)).
                setAccessId(userAccessId).
                setApiKey(userApiKey).build();

        AkeylessClient client = AkeylessClient.Factory.newInstance(config);

        String ciphertext = client.encryptString(encKeyName, data);
        System.out.println("Ciphertext: " + ciphertext);

        String decryptResult = client.decryptString(encKeyName, ciphertext);
        System.out.println("Decrypted: " + decryptResult);

        client.close();
    }
}

📘

Authentication methods

In addition to authentication with Access-ID and Access-Key, you can authenticate to Akeyless Vault with username and password.

Digital Signature using RSA Key

The following code sample demonstrates how to sign/verify a message via RSA-PKCS1v15 where the RSA key fragments are stored in multiple locations and are never combined Distributed Fragments Cryptography

package com.akeyless.examples;

import com.akeyless.AkeylessClient;
import com.akeyless.config.AkeylessClientConfiguration;

public class RsaPKCS1v15SignatureExample {

    public static void main(final String[] args) throws Exception {
        String userAccessId = args[0];
        String userApiKey = args[1];
        String rsaKeyName = args[2];
        String message = args[3];

        String akeylessServerUrl = "<AKEYLESS_URL>"; 
        AkeylessClientConfiguration config = new AkeylessClientConfiguration.Builder().
                setAddress(new URL(akeylessServerUrl)).
                setAccessId(userAccessId).
                setApiKey(userApiKey).build();

        AkeylessClient client = AkeylessClient.Factory.newInstance(config);

        byte[] signature = client.signPKCS1v15(rsaKeyName, message.getBytes());
        System.out.println("Signature: " + new String(signature));

        if(client.verifyPKCS1v15(rsaKeyName, message.getBytes(), signature)) {
            System.out.println("Signature successfully verified");
        } else {
            System.out.println("Error - something goes wrong");
        }

        client.close();
    }
}

Additional examples for Akeyless Java SDK can be found below.

📘

Documentation for API calls

https://github.com/akeylesslabs/akeyless-java-sdk

Updated 4 months ago

Java SDK


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.