mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-01-04 22:59:58 +01:00
(#1490)Use java.util.Base64 instead of sun.misc or commons-codec
This commit is contained in:
@@ -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 @@ object ApiContents{
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package gitbucket.core.plugin
|
||||
|
||||
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 gitbucket.core.util.Directory._
|
||||
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 @@ class PluginRegistry {
|
||||
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))
|
||||
}
|
||||
|
||||
|
||||
@@ -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 @@ object SshUtil {
|
||||
}
|
||||
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 =>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package gitbucket.core.util
|
||||
|
||||
import java.util.Base64
|
||||
import javax.servlet.http.HttpServletResponse
|
||||
|
||||
/**
|
||||
@@ -13,9 +14,9 @@ object AuthUtil {
|
||||
|
||||
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 => ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 @@ object StringUtil {
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user