diff --git a/src/main/scala/gitbucket/core/api/ApiContents.scala b/src/main/scala/gitbucket/core/api/ApiContents.scala index 1d5753b..8b3735a 100644 --- a/src/main/scala/gitbucket/core/api/ApiContents.scala +++ b/src/main/scala/gitbucket/core/api/ApiContents.scala @@ -1,8 +1,9 @@ package gitbucket.core.api +import java.util.Base64 + import gitbucket.core.util.JGitUtil.FileInfo import gitbucket.core.util.RepositoryName -import org.apache.commons.codec.binary.Base64 case class ApiContents( `type`: String, @@ -20,7 +21,7 @@ ApiContents("dir", fileInfo.name, fileInfo.path, fileInfo.commitId, None, None)(repositoryName) } else { content.map(arr => - ApiContents("file", fileInfo.name, fileInfo.path, fileInfo.commitId, Some(Base64.encodeBase64String(arr)), Some("base64"))(repositoryName) + ApiContents("file", fileInfo.name, fileInfo.path, fileInfo.commitId, Some(Base64.getEncoder.encodeToString(arr)), Some("base64"))(repositoryName) ).getOrElse(ApiContents("file", fileInfo.name, fileInfo.path, fileInfo.commitId, None, None)(repositoryName)) } } diff --git a/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala b/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala index 7ba1026..b299004 100644 --- a/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala +++ b/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala @@ -2,6 +2,7 @@ import java.io.{File, FilenameFilter, InputStream} import java.net.URLClassLoader +import java.util.Base64 import javax.servlet.ServletContext import gitbucket.core.controller.{Context, ControllerBase} @@ -15,7 +16,6 @@ import io.github.gitbucket.solidbase.Solidbase import io.github.gitbucket.solidbase.manager.JDBCVersionManager import io.github.gitbucket.solidbase.model.Module -import org.apache.commons.codec.binary.{Base64, StringUtils} import org.slf4j.LoggerFactory import scala.collection.mutable @@ -54,7 +54,7 @@ def getPlugins(): List[PluginInfo] = plugins.toList def addImage(id: String, bytes: Array[Byte]): Unit = { - val encoded = StringUtils.newStringUtf8(Base64.encodeBase64(bytes, false)) + val encoded = Base64.getEncoder.encodeToString(bytes) images += ((id, encoded)) } diff --git a/src/main/scala/gitbucket/core/ssh/SshUtil.scala b/src/main/scala/gitbucket/core/ssh/SshUtil.scala index 42167ed..62eb97a 100644 --- a/src/main/scala/gitbucket/core/ssh/SshUtil.scala +++ b/src/main/scala/gitbucket/core/ssh/SshUtil.scala @@ -1,8 +1,8 @@ package gitbucket.core.ssh import java.security.PublicKey +import java.util.Base64 -import org.apache.commons.codec.binary.Base64 import org.apache.sshd.common.config.keys.KeyUtils import org.apache.sshd.common.util.buffer.ByteArrayBuffer import org.eclipse.jgit.lib.Constants @@ -22,7 +22,7 @@ } try { val encodedKey = parts(1) - val decode = Base64.decodeBase64(Constants.encodeASCII(encodedKey)) + val decode = Base64.getDecoder.decode(Constants.encodeASCII(encodedKey)) Some(new ByteArrayBuffer(decode).getRawPublicKey) } catch { case e: Throwable => diff --git a/src/main/scala/gitbucket/core/util/AuthUtil.scala b/src/main/scala/gitbucket/core/util/AuthUtil.scala index 7a83c13..5d937ca 100644 --- a/src/main/scala/gitbucket/core/util/AuthUtil.scala +++ b/src/main/scala/gitbucket/core/util/AuthUtil.scala @@ -1,5 +1,6 @@ package gitbucket.core.util +import java.util.Base64 import javax.servlet.http.HttpServletResponse /** @@ -13,9 +14,9 @@ def decodeAuthHeader(header: String): String = { try { - new String(new sun.misc.BASE64Decoder().decodeBuffer(header.substring(6))) + new String(Base64.getDecoder.decode(header.substring(6))) } catch { case _: Throwable => "" } } -} \ No newline at end of file +} diff --git a/src/main/scala/gitbucket/core/util/StringUtil.scala b/src/main/scala/gitbucket/core/util/StringUtil.scala index 587df35..d1eadf3 100644 --- a/src/main/scala/gitbucket/core/util/StringUtil.scala +++ b/src/main/scala/gitbucket/core/util/StringUtil.scala @@ -1,12 +1,12 @@ package gitbucket.core.util import java.net.{URLDecoder, URLEncoder} +import java.util.Base64 import org.mozilla.universalchardet.UniversalDetector import SyntaxSugars._ import org.apache.commons.io.input.BOMInputStream import org.apache.commons.io.IOUtils -import org.apache.commons.codec.binary.Base64 import scala.util.control.Exception._ @@ -34,14 +34,14 @@ val spec = new javax.crypto.spec.SecretKeySpec(BlowfishKey.getBytes(), "Blowfish") val cipher = javax.crypto.Cipher.getInstance("Blowfish") cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, spec) - new String(Base64.encodeBase64(cipher.doFinal(value.getBytes("UTF-8"))), "UTF-8") + Base64.getEncoder.encodeToString(cipher.doFinal(value.getBytes("UTF-8"))) } def decodeBlowfish(value: String): String = { val spec = new javax.crypto.spec.SecretKeySpec(BlowfishKey.getBytes(), "Blowfish") val cipher = javax.crypto.Cipher.getInstance("Blowfish") cipher.init(javax.crypto.Cipher.DECRYPT_MODE, spec) - new String(cipher.doFinal(Base64.decodeBase64(value)), "UTF-8") + new String(cipher.doFinal(Base64.getDecoder.decode(value)), "UTF-8") } def urlEncode(value: String): String = URLEncoder.encode(value, "UTF-8").replace("+", "%20")