HBASE-23628: Remove Apache Commons Digest Base64 (#977)

Signed-off-by: stack <stack@apache.org>
This commit is contained in:
belugabehr 2020-01-02 15:06:19 -05:00 committed by Michael Stack
parent 275cdc6052
commit 280b94434c
2 changed files with 9 additions and 12 deletions

View File

@ -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();
}
/**

View File

@ -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;
@ -671,20 +670,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) {