hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [hbase] branch branch-2 updated: HBASE-23628: Remove Apache Commons Digest Base64 (#977)
Date Fri, 10 Jan 2020 21:46:18 GMT
This is an automated email from the ASF dual-hosted git repository.

busbey pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 76a6fe6  HBASE-23628: Remove Apache Commons Digest Base64 (#977)
76a6fe6 is described below

commit 76a6fe6a8be51bac4d6ba2edfb07f5604d73b7f2
Author: belugabehr <12578579+belugabehr@users.noreply.github.com>
AuthorDate: Thu Jan 2 15:06:19 2020 -0500

    HBASE-23628: Remove Apache Commons Digest Base64 (#977)
    
    Signed-off-by: stack <stack@apache.org>
    (cherry picked from commit 280b94434cbd63495c78ae40d33a720e406dc272)
---
 .../main/java/org/apache/hadoop/hbase/security/SaslUtil.java |  9 ++++-----
 .../io/asyncfs/FanOutOneBlockAsyncDFSOutputSaslHelper.java   | 12 +++++-------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/SaslUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/SaslUtil.java
index 7091df5..72851b6 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/SaslUtil.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/SaslUtil.java
@@ -18,7 +18,7 @@
  */
 package org.apache.hadoop.hbase.security;
 
-import java.nio.charset.StandardCharsets;
+import java.util.Base64;
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -27,7 +27,6 @@ import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
 
-import org.apache.commons.codec.binary.Base64;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.yetus.audience.InterfaceAudience;
 import org.slf4j.Logger;
@@ -70,15 +69,15 @@ public class SaslUtil {
   }
 
   static String encodeIdentifier(byte[] identifier) {
-    return new String(Base64.encodeBase64(identifier), StandardCharsets.UTF_8);
+    return Base64.getEncoder().encodeToString(identifier);
   }
 
   static byte[] decodeIdentifier(String identifier) {
-    return Base64.decodeBase64(Bytes.toBytes(identifier));
+    return Base64.getDecoder().decode(Bytes.toBytes(identifier));
   }
 
   static char[] encodePassword(byte[] password) {
-    return new String(Base64.encodeBase64(password), StandardCharsets.UTF_8).toCharArray();
+    return Base64.getEncoder().encodeToString(password).toCharArray();
   }
 
   /**
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputSaslHelper.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputSaslHelper.java
index 96efe7c..c160391 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputSaslHelper.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputSaslHelper.java
@@ -31,6 +31,7 @@ import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.security.GeneralSecurityException;
 import java.util.Arrays;
+import java.util.Base64;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -47,7 +48,6 @@ import javax.security.sasl.RealmChoiceCallback;
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslException;
-import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.crypto.CipherOption;
@@ -77,7 +77,6 @@ import org.apache.yetus.audience.InterfaceAudience;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.hbase.thirdparty.com.google.common.base.Charsets;
 import org.apache.hbase.thirdparty.com.google.common.base.Throwables;
 import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hbase.thirdparty.com.google.common.collect.Maps;
@@ -666,20 +665,19 @@ public final class FanOutOneBlockAsyncDFSOutputSaslHelper {
 
   private static String getUserNameFromEncryptionKey(DataEncryptionKey encryptionKey) {
     return encryptionKey.keyId + NAME_DELIMITER + encryptionKey.blockPoolId + NAME_DELIMITER
-        + new String(Base64.encodeBase64(encryptionKey.nonce, false), Charsets.UTF_8);
+        + Base64.getEncoder().encodeToString(encryptionKey.nonce);
   }
 
   private static char[] encryptionKeyToPassword(byte[] encryptionKey) {
-    return new String(Base64.encodeBase64(encryptionKey, false), Charsets.UTF_8).toCharArray();
+    return Base64.getEncoder().encodeToString(encryptionKey).toCharArray();
   }
 
   private static String buildUsername(Token<BlockTokenIdentifier> blockToken) {
-    return new String(Base64.encodeBase64(blockToken.getIdentifier(), false), Charsets.UTF_8);
+    return Base64.getEncoder().encodeToString(blockToken.getIdentifier());
   }
 
   private static char[] buildClientPassword(Token<BlockTokenIdentifier> blockToken)
{
-    return new String(Base64.encodeBase64(blockToken.getPassword(), false), Charsets.UTF_8)
-        .toCharArray();
+    return Base64.getEncoder().encodeToString(blockToken.getPassword()).toCharArray();
   }
 
   private static Map<String, String> createSaslPropertiesForEncryption(String encryptionAlgorithm)
{


Mime
View raw message