public static String getS3EncryptionContextBase64Encoded(
      String bucket,
      Configuration conf,
      boolean propagateExceptions) throws IOException {
    try {
      final String encryptionContextValue = getS3EncryptionContext(bucket, conf);
      if (StringUtils.isBlank(encryptionContextValue)) {
        return "";
      }
      final Map<String, String> encryptionContextMap = S3AUtils
          .getTrimmedStringCollectionSplitByEquals(encryptionContextValue);
      if (encryptionContextMap.isEmpty()) {
        return "";
      }
      final String encryptionContextJson = JacksonUtil.getSharedWriter()
          .writeValueAsString(encryptionContextMap);
      return Base64.encodeBase64String(encryptionContextJson.getBytes(StandardCharsets.UTF_8));
    } catch (IOException e) {
      if (propagateExceptions) {
        throw e;
      }
      LOG.warn("Cannot retrieve {} for bucket {}",
          S3_ENCRYPTION_CONTEXT, bucket, e);
      return "";
    }
  }
@Test
  public void testGetS3EncryptionContextBase64Encoded() throws IOException {
    Configuration configuration = new Configuration(false);
    configuration.set(S3_ENCRYPTION_CONTEXT, GLOBAL_CONTEXT);
    final String result = S3AEncryption.getS3EncryptionContextBase64Encoded("bucket",
        configuration, true);
    final String decoded = new String(Base64.decodeBase64(result), StandardCharsets.UTF_8);
    final TypeReference<Map<String, String>> typeRef = new TypeReference<Map<String, String>>() {};
    final Map<String, String> resultMap = new ObjectMapper().readValue(decoded, typeRef);
    Assert.assertEquals("hadoop", resultMap.get("project"));
    Assert.assertEquals("HADOOP-19197", resultMap.get("jira"));
  }