|
| 1 | +/* |
| 2 | + * Copyright 2020 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.vault.core; |
| 17 | + |
| 18 | +import org.springframework.vault.support.*; |
| 19 | + |
| 20 | +import java.util.List; |
| 21 | + |
| 22 | +/** |
| 23 | + * Interface that specifies operations using the {@code transform} backend. |
| 24 | + * |
| 25 | + * @author Lauren Voswinkel |
| 26 | + * @see <a href="https://www.vaultproject.io/docs/secrets/transform/index.html">Transform |
| 27 | + * Secrets Engine</a> |
| 28 | + * @since 2.3 |
| 29 | + */ |
| 30 | +public interface VaultTransformOperations { |
| 31 | + /** |
| 32 | + * Encodes the provided plaintext using the named role. |
| 33 | + * @param roleName must not be empty or {@literal null}. |
| 34 | + * @param plaintext must not be empty or {@literal null}. |
| 35 | + * @return cipher text. |
| 36 | + */ |
| 37 | + String encode(String roleName, String plaintext); |
| 38 | + |
| 39 | + /** |
| 40 | + * Encodes the provided plaintext using the named role. |
| 41 | + * @param roleName must not be empty or {@literal null}. |
| 42 | + * @param plaintext must not be {@literal null}. |
| 43 | + * @return cipher text. |
| 44 | + */ |
| 45 | + TransformCiphertext encode(String roleName, TransformPlaintext plaintext); |
| 46 | + |
| 47 | + /** |
| 48 | + * Encodes the provided plaintext using the named role. |
| 49 | + * @param roleName must not be empty or {@literal null}. |
| 50 | + * @param plaintext must not be empty or {@literal null}. |
| 51 | + * @param transformRequest must not be {@literal null}. Use |
| 52 | + * {@link VaultTransformContext#empty()} if no request options provided. |
| 53 | + * @return cipher text. |
| 54 | + */ |
| 55 | + String encode(String roleName, byte[] plaintext, VaultTransformContext transformRequest); |
| 56 | + |
| 57 | + /** |
| 58 | + * Encode the provided batch of plaintext using the role given and transformation in |
| 59 | + * each list item. The encryption is done using transformation secret backend's batch |
| 60 | + * operation. |
| 61 | + * @param roleName must not be empty or {@literal null}. |
| 62 | + * @param batchRequest a list of {@link Plaintext} which includes plaintext and an |
| 63 | + * optional context. |
| 64 | + * @return the encrypted result in the order of {@code batchRequest} plaintexts. |
| 65 | + */ |
| 66 | + List<VaultTransformEncodeResult> encode(String roleName, List<TransformPlaintext> batchRequest); |
| 67 | + |
| 68 | + /** |
| 69 | + * Decode the provided ciphertext using the named role. |
| 70 | + * @param roleName must not be empty or {@literal null}. |
| 71 | + * @param ciphertext must not be empty or {@literal null}. |
| 72 | + * @return plain text. |
| 73 | + */ |
| 74 | + String decode(String roleName, String ciphertext); |
| 75 | + |
| 76 | + /** |
| 77 | + * Decode the provided ciphertext using the named role. |
| 78 | + * @param roleName must not be empty or {@literal null}. |
| 79 | + * @param ciphertext must not be {@literal null}. |
| 80 | + * @return plain text. |
| 81 | + */ |
| 82 | + TransformPlaintext decode(String roleName, TransformCiphertext ciphertext); |
| 83 | + |
| 84 | + /** |
| 85 | + * Decode the provided ciphertext using the named role. |
| 86 | + * @param roleName must not be empty or {@literal null}. |
| 87 | + * @param ciphertext must not be empty or {@literal null}. |
| 88 | + * @param transformContext must not be {@literal null}. Use |
| 89 | + * {@link VaultTransformContext#empty()} if no request options provided. |
| 90 | + * @return plain text. |
| 91 | + */ |
| 92 | + String decode(String roleName, String ciphertext, VaultTransformContext transformContext); |
| 93 | + |
| 94 | + /** |
| 95 | + * Decode the provided batch of ciphertext using the role given and transformation in |
| 96 | + * each list item. The decryption is done using transformation secret backend's batch |
| 97 | + * operation. |
| 98 | + * @param roleName must not be empty or {@literal null}. |
| 99 | + * @param batchRequest a list of {@link Ciphertext} which includes plaintext and an |
| 100 | + * optional context. |
| 101 | + * @return the decrypted result in the order of {@code batchRequest} ciphertexts. |
| 102 | + */ |
| 103 | + List<VaultTransformDecodeResult> decode(String roleName, List<TransformCiphertext> batchRequest); |
| 104 | +} |
0 commit comments