Custom implementation

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

In addition to the basic and advanced encryption methods that you can use in Bitbucket Data Center, you can also choose to create your own SecretStore implementation. This might be especially useful if:

  • you're required to use a specific vault to store the password

  • you want to use encryption algorithms beyond those we ship with Bitbucket

Step 1. Create a Maven project and get API dependencies

  1. Navigate to the <Bitbucket_installation_directory>/atlassian-bitbucket/WEB-INF/lib directory.

  2. Install the atlassian-secrets-api.jar file into local maven repository with the following command:

    mvn install:install-file \
       -Dfile=./atlassian-secrets-api-<version>.jar \
       -DgroupId=com.atlassian.secrets \
       -DartifactId=atlassian-secrets-api \
       -Dversion=<version> \
       -Dpackaging=jar \
  3. Install the atlassian-secrets-store.jar file into local maven repository with the following command:

    mvn install:install-file \
       -Dfile=./atlassian-secrets-store-<version>.jar \
       -DgroupId=com.atlassian.secrets \
       -DartifactId=atlassian-secrets-store \
       -Dversion=<version> \
       -Dpackaging=jar \
  4. Create a Maven project with the following pom:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns=""

Step 2. Implement the SecretStore interface

The SecretStore interface contains two methods that you need to implement according to your requirements; store and get. The get method is called during Bitbucket startup, which means that long-running tasks can affect the startup time. The store method is not called by Bitbucket, as it's only used in the encryption tool.

From Bitbucket 8.13, the Cipher interface should be considered deprecated. Instead, you should use the new interface, SecretStore, and its corresponding methods, store and get. These methods supersede the equivalent Cipher interface methods, encrypt and decrypt.

The Cipher interface and its methods can still be used, but will eventually be retired, and should not be used when setting up new encryption functionality.

You can use Base64Cipher and AlgorithmSecretStore as examples. 

Step 3. Test your implementation

The encryption tool described in Basic encryption and Advanced encryption uses the same code as Bitbucket to decrypt the password. You can use it to test your implementation.

Assuming that the CLI and your jar is in the same folder:

java -cp "./*" com.atlassian.secrets.cli.db.DbCipherTool -c

Step 4. Make your library available

Bitbucket must be able to access your library. Your class will be instantiated using reflection. Put the library in the following directory:

Last modified on Nov 10, 2023

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.