Example usage for org.springframework.vault.support VaultTransitContext builder

List of usage examples for org.springframework.vault.support VaultTransitContext builder

Introduction

In this page you can find the example usage for org.springframework.vault.support VaultTransitContext builder.

Prototype

public static VaultTransitRequestBuilder builder() 

Source Link

Usage

From source file:example.encryption.VaultTransitOperationsIntegrationTest.java

/**
 * Encrypt and decrypt binary data with default encoding.
 *//*from   w  ww. j  a v  a2  s  .c  o  m*/
@Test
public void shouldEncryptAndDecryptBinaryData() {

    byte[] input = "That's just some random data. Move on, nothing to see here."
            .getBytes(StandardCharsets.UTF_8);

    String ciphertext = transitOperations.encrypt("foo-key", input, VaultTransitContext.builder().build());

    log.info("Encrypted: {}" + ciphertext);

    byte[] plaintext = transitOperations.decrypt("foo-key", ciphertext, VaultTransitContext.builder().build());

    assertThat(plaintext).hasSize(input.length).isEqualTo(plaintext);
}