test_class.declarator: KMS_KEY_ID = "testKeyId"
test_class.modifier: private static final
test_class.original_string: private static final String KMS_KEY_ID = "testKeyId";
test_class.type: String
test_class.var_name: KMS_KEY_ID
test_class.declarator: PLAINTEXT = "plaintext"
test_class.modifier: private static final
test_class.original_string: private static final String PLAINTEXT = "plaintext";
test_class.type: String
test_class.var_name: PLAINTEXT
test_class.declarator: CIPHER_TEXT = "C1PHERT3XT"
test_class.modifier: private static final
test_class.original_string: private static final String CIPHER_TEXT = "C1PHERT3XT";
test_class.type: String
test_class.var_name: CIPHER_TEXT
test_class.declarator: BASE64_CIPHER_TEXT = new String(Base64.getEncoder().encode(CIPHER_TEXT.getBytes()))
test_class.modifier: private static final
test_class.original_string: private static final String BASE64_CIPHER_TEXT = new String(Base64.getEncoder().encode(CIPHER_TEXT.getBytes()));
test_class.type: String
test_class.var_name: BASE64_CIPHER_TEXT
test_class.declarator: mockKms
test_class.modifier: private
test_class.original_string: private AWSKMS mockKms;
test_class.type: AWSKMS
test_class.var_name: mockKms
test_class.declarator: textEncryptor
test_class.modifier: private
test_class.original_string: private KmsTextEncryptor textEncryptor;
test_class.type: KmsTextEncryptor
test_class.var_name: textEncryptor
test_class.declarator: expectedEncryptRequest
test_class.modifier: private
test_class.original_string: private EncryptRequest expectedEncryptRequest;
test_class.type: EncryptRequest
test_class.var_name: expectedEncryptRequest
test_class.declarator: encryptResult
test_class.modifier: private
test_class.original_string: private EncryptResult encryptResult;
test_class.type: EncryptResult
test_class.var_name: encryptResult
test_class.declarator: expectedDecryptRequest
test_class.modifier: private
test_class.original_string: private DecryptRequest expectedDecryptRequest;
test_class.type: DecryptRequest
test_class.var_name: expectedDecryptRequest
test_class.declarator: decryptResult
test_class.modifier: private
test_class.original_string: private DecryptResult decryptResult;
test_class.type: DecryptResult
test_class.var_name: decryptResult
test_class.file: library/src/test/java/de/zalando/spring/cloud/config/aws/kms/KmsTextEncryptorTest.java
test_class.identifier: KmsTextEncryptorTest
test_case.body: @Test
      public void testDecryptEmptyResult() {
          decryptResult.setPlaintext(ByteBuffer.allocate(0));
          assertThat(textEncryptor.decrypt(BASE64_CIPHER_TEXT)).isEqualTo("");
          verify(mockKms).decrypt(eq(expectedDecryptRequest));
      }
test_case.class_method_signature: KmsTextEncryptorTest.testDecryptEmptyResult()
test_case.full_signature: @Test public void testDecryptEmptyResult()
test_case.identifier: testDecryptEmptyResult
test_case.invocations: setPlaintext allocate isEqualTo assertThat decrypt decrypt verify eq
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDecryptEmptyResult()
focal_class.declarator: BASE64_ENCODER = Base64.getEncoder()
focal_class.modifier: private static final
focal_class.original_string: private static final Base64.Encoder BASE64_ENCODER = Base64.getEncoder();
focal_class.type: Base64.Encoder
focal_class.var_name: BASE64_ENCODER
focal_class.declarator: EMPTY_STRING = ""
focal_class.modifier: private static final
focal_class.original_string: private static final String EMPTY_STRING = "";
focal_class.type: String
focal_class.var_name: EMPTY_STRING
focal_class.declarator: IS_ALGORITHM_AVAILABLE
focal_class.modifier: private static final
focal_class.original_string: private static final boolean IS_ALGORITHM_AVAILABLE;
focal_class.type: boolean
focal_class.var_name: IS_ALGORITHM_AVAILABLE
focal_class.declarator: log = LoggerFactory.getLogger(getClass())
focal_class.modifier: private final
focal_class.original_string: private final Logger log = LoggerFactory.getLogger(getClass());
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: kms
focal_class.modifier: private final
focal_class.original_string: private final AWSKMS kms;
focal_class.type: AWSKMS
focal_class.var_name: kms
focal_class.declarator: kmsKeyId
focal_class.modifier: private final
focal_class.original_string: private final String kmsKeyId;
focal_class.type: String
focal_class.var_name: kmsKeyId
focal_class.declarator: encryptionAlgorithm
focal_class.modifier: private final
focal_class.original_string: private final String encryptionAlgorithm;
focal_class.type: String
focal_class.var_name: encryptionAlgorithm
focal_class.file: library/src/main/java/de/zalando/spring/cloud/config/aws/kms/KmsTextEncryptor.java
focal_class.identifier: KmsTextEncryptor
focal_class.interfaces: implements TextEncryptor
focal_class.class_method_signature: KmsTextEncryptor.KmsTextEncryptor(final AWSKMS kms, final String kmsKeyId, final String encryptionAlgorithm)
focal_class.full_signature: public  KmsTextEncryptor(final AWSKMS kms, final String kmsKeyId, final String encryptionAlgorithm)
focal_class.identifier: KmsTextEncryptor
focal_class.modifiers: public
focal_class.parameters: (final AWSKMS kms, final String kmsKeyId, final String encryptionAlgorithm)
focal_class.signature:  KmsTextEncryptor(final AWSKMS kms, final String kmsKeyId, final String encryptionAlgorithm)
focal_class.class_method_signature: KmsTextEncryptor.encrypt(final String text)
focal_class.full_signature: @Override public String encrypt(final String text)
focal_class.identifier: encrypt
focal_class.modifiers: @Override public
focal_class.parameters: (final String text)
focal_class.return: String
focal_class.signature: String encrypt(final String text)
focal_class.class_method_signature: KmsTextEncryptor.decrypt(final String encryptedText)
focal_class.full_signature: @Override public String decrypt(final String encryptedText)
focal_class.identifier: decrypt
focal_class.modifiers: @Override public
focal_class.parameters: (final String encryptedText)
focal_class.return: String
focal_class.signature: String decrypt(final String encryptedText)
focal_class.class_method_signature: KmsTextEncryptor.extractString(final ByteBuffer bb, final OutputMode outputMode)
focal_class.full_signature: private static String extractString(final ByteBuffer bb, final OutputMode outputMode)
focal_class.identifier: extractString
focal_class.modifiers: private static
focal_class.parameters: (final ByteBuffer bb, final OutputMode outputMode)
focal_class.return: String
focal_class.signature: String extractString(final ByteBuffer bb, final OutputMode outputMode)
focal_class.class_method_signature: KmsTextEncryptor.checkAlgorithm(String algorithm)
focal_class.full_signature: private void checkAlgorithm(String algorithm)
focal_class.identifier: checkAlgorithm
focal_class.modifiers: private
focal_class.parameters: (String algorithm)
focal_class.return: void
focal_class.signature: void checkAlgorithm(String algorithm)
focal_class.class_method_signature: KmsTextEncryptor.isAsymmetricEncryption(String algorithm)
focal_class.full_signature: private static boolean isAsymmetricEncryption(String algorithm)
focal_class.identifier: isAsymmetricEncryption
focal_class.modifiers: private static
focal_class.parameters: (String algorithm)
focal_class.return: boolean
focal_class.signature: boolean isAsymmetricEncryption(String algorithm)
focal_method.body: @Override
      public String decrypt(final String encryptedText) {
          if (encryptedText == null || encryptedText.isEmpty()) {
              return EMPTY_STRING;
          } else {
  
              final EncryptedToken token = EncryptedToken.parse(encryptedText);
  
              final DecryptRequest decryptRequest = new DecryptRequest()
                      .withCiphertextBlob(token.getCipherBytes())
                      .withEncryptionContext(token.getEncryptionContext());
              final KmsTextEncryptorOptions options = token.getOptions();
              final String keyId = Optional.ofNullable(options.getKeyId()).orElse(kmsKeyId);
              final String algorithm = Optional.ofNullable(options.getEncryptionAlgorithm()).orElse(encryptionAlgorithm);
  
              checkAlgorithm(algorithm);
  
              if (IS_ALGORITHM_AVAILABLE) {
                  decryptRequest.setEncryptionAlgorithm(algorithm);
                  if (isAsymmetricEncryption(algorithm)) {
                      Assert.hasText(keyId, "kmsKeyId must not be blank. Asymmetric decryption requires the key to be known");
                      decryptRequest.setKeyId(keyId);
                  }
              }
  
              return extractString(kms.decrypt(decryptRequest).getPlaintext(), options.getOutputMode());
          }
      }
focal_method.class_method_signature: KmsTextEncryptor.decrypt(final String encryptedText)
focal_method.full_signature: @Override public String decrypt(final String encryptedText)
focal_method.identifier: decrypt
focal_method.invocations: isEmpty parse withEncryptionContext withCiphertextBlob getCipherBytes getEncryptionContext getOptions orElse ofNullable getKeyId orElse ofNullable getEncryptionAlgorithm checkAlgorithm setEncryptionAlgorithm isAsymmetricEncryption hasText setKeyId extractString getPlaintext decrypt getOutputMode
focal_method.modifiers: @Override public
focal_method.parameters: (final String encryptedText)
focal_method.return: String
focal_method.signature: String decrypt(final String encryptedText)