Skip to content

Commit 47f8f9c

Browse files
committed
[KYUUBI #3092] Replace apache commons Base64 w/ JDK
### _Why are the changes needed?_ Minor code clean-up, prefer to use the JDK-provided tools. ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #3092 from pan3793/base64. Closes #3092 8e8f227 [Cheng Pan] Replace apache commons Base64 w/ JDK Authored-by: Cheng Pan <chengpan@apache.org> Signed-off-by: Cheng Pan <chengpan@apache.org>
1 parent 77b6ee0 commit 47f8f9c

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/HttpAuthUtils.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
package org.apache.kyuubi.jdbc.hive.auth;
1919

2020
import java.security.PrivilegedExceptionAction;
21+
import java.util.Base64;
2122
import javax.security.auth.Subject;
22-
import org.apache.commons.codec.binary.Base64;
2323
import org.apache.hadoop.security.UserGroupInformation;
2424
import org.ietf.jgss.GSSContext;
2525
import org.ietf.jgss.GSSManager;
@@ -58,11 +58,9 @@ private HttpAuthUtils() {
5858
*/
5959
public static class HttpKerberosClientAction implements PrivilegedExceptionAction<String> {
6060
private final String serverPrincipal;
61-
private final Base64 base64codec;
6261

6362
public HttpKerberosClientAction(String serverPrincipal) {
6463
this.serverPrincipal = serverPrincipal;
65-
base64codec = new Base64(0);
6664
}
6765

6866
@Override
@@ -84,7 +82,7 @@ public String run() throws Exception {
8482
byte[] outToken = gssContext.initSecContext(inToken, 0, inToken.length);
8583
gssContext.dispose();
8684
// Base64 encoded and stringified token for server
87-
return new String(base64codec.encode(outToken));
85+
return Base64.getEncoder().encodeToString(outToken);
8886
}
8987
}
9088
}

kyuubi-server/src/main/scala/org/apache/kyuubi/server/http/util/CookieSigner.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
package org.apache.kyuubi.server.http.util
1919

2020
import java.security.{MessageDigest, NoSuchAlgorithmException}
21-
22-
import org.apache.commons.codec.binary.Base64
21+
import java.util.Base64
2322

2423
import org.apache.kyuubi.Logging
2524

@@ -78,7 +77,7 @@ class CookieSigner(secret: Array[Byte]) extends Logging {
7877
md.update(str.getBytes)
7978
md.update(secretBytes)
8079
val digest = md.digest
81-
new Base64(0).encodeToString(digest)
80+
Base64.getEncoder.encodeToString(digest)
8281
} catch {
8382
case ex: NoSuchAlgorithmException =>
8483
throw new RuntimeException(

0 commit comments

Comments
 (0)