Skip to content

Commit 96351c8

Browse files
committed
Move random into object
1 parent f5a840b commit 96351c8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

kyuubi-common/src/main/scala/org/apache/kyuubi/service/authentication/InternalSecurityAccessor.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class InternalSecurityAccessor(conf: KyuubiConf, val isServer: Boolean) {
3333
val cryptoKeyAlgorithm = conf.get(ENGINE_SECURITY_CRYPTO_KEY_ALGORITHM)
3434
val cryptoCipher = conf.get(ENGINE_SECURITY_CRYPTO_CIPHER_TRANSFORMATION)
3535

36-
private val random = new SecureRandom()
3736
private val tokenMaxLifeTime: Long = conf.get(ENGINE_SECURITY_TOKEN_MAX_LIFETIME)
3837
private val provider: EngineSecuritySecretProvider = EngineSecuritySecretProvider.create(conf)
3938
private val (secretKeySpec, encryptor, decryptor) =
@@ -65,7 +64,7 @@ class InternalSecurityAccessor(conf: KyuubiConf, val isServer: Boolean) {
6564

6665
private[authentication] def encrypt(value: String): String = synchronized {
6766
val nonce = new Array[Byte](cryptoIvLength)
68-
random.nextBytes(nonce)
67+
InternalSecurityAccessor.random.nextBytes(nonce)
6968
encryptor.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(nonce))
7069
byteArrayToHexString(nonce ++ encryptor.doFinal(value.getBytes))
7170
}
@@ -114,6 +113,7 @@ class InternalSecurityAccessor(conf: KyuubiConf, val isServer: Boolean) {
114113

115114
object InternalSecurityAccessor extends Logging {
116115
@volatile private var _engineSecurityAccessor: InternalSecurityAccessor = _
116+
private val random: SecureRandom = new SecureRandom()
117117

118118
def initialize(conf: KyuubiConf, isServer: Boolean): Unit = {
119119
if (_engineSecurityAccessor == null) {

0 commit comments

Comments
 (0)