Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -27,7 +27,6 @@
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;
Expand Down Expand Up @@ -70,15 +69,15 @@ public static String[] splitKerberosName(String fullName) {
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
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;
Expand All @@ -47,7 +48,6 @@
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;
Expand Down Expand Up @@ -77,7 +77,6 @@
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;
Expand Down Expand Up @@ -671,20 +670,19 @@ protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throw

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) {
Expand Down