mirror of
https://github.com/corda/corda.git
synced 2025-02-06 11:09:18 +00:00
Ensure that every CheatingSecurityProvider has a unique name. (#3835)
This commit is contained in:
parent
1d05c16942
commit
004ea45a05
@ -5,14 +5,15 @@ import java.security.Provider
|
|||||||
import java.security.SecureRandom
|
import java.security.SecureRandom
|
||||||
import java.security.SecureRandomSpi
|
import java.security.SecureRandomSpi
|
||||||
import java.security.Security
|
import java.security.Security
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporarily restore Sun's [SecureRandom] provider.
|
* Temporarily restore Sun's [SecureRandom] provider.
|
||||||
* This is ONLY for allowing us to generate test data, e.g. signatures.
|
* This is ONLY for allowing us to generate test data, e.g. signatures.
|
||||||
*/
|
*/
|
||||||
class CheatingSecurityProvider : Provider(NAME, 1.8, "$NAME security provider"), AutoCloseable {
|
class CheatingSecurityProvider : Provider("Cheat-${counter.getAndIncrement()}", 1.8, "Cheat security provider"), AutoCloseable {
|
||||||
private companion object {
|
private companion object {
|
||||||
private const val NAME = "Cheat!"
|
private val counter = AtomicInteger()
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -21,7 +22,7 @@ class CheatingSecurityProvider : Provider(NAME, 1.8, "$NAME security provider"),
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun close() {
|
override fun close() {
|
||||||
Security.removeProvider(NAME)
|
Security.removeProvider(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SunSecureRandom : SecureRandom(sun.security.provider.SecureRandom(), null)
|
private class SunSecureRandom : SecureRandom(sun.security.provider.SecureRandom(), null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user