mirror of
https://github.com/corda/corda.git
synced 2024-12-21 22:07:55 +00:00
Close Hikari CP around external auth database on shutdown (RPCSecurityManagerImpl.kt) (#2359)
This commit is contained in:
parent
fb1d3087de
commit
2082168cf7
@ -25,6 +25,7 @@ import org.apache.shiro.realm.AuthorizingRealm
|
||||
import org.apache.shiro.realm.jdbc.JdbcRealm
|
||||
import org.apache.shiro.subject.PrincipalCollection
|
||||
import org.apache.shiro.subject.SimplePrincipalCollection
|
||||
import java.io.Closeable
|
||||
import javax.security.auth.login.FailedLoginException
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.TimeUnit
|
||||
@ -43,10 +44,6 @@ class RPCSecurityManagerImpl(config: AuthServiceConfig) : RPCSecurityManager {
|
||||
manager = buildImpl(config)
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
manager.destroy()
|
||||
}
|
||||
|
||||
@Throws(FailedLoginException::class)
|
||||
override fun authenticate(principal: String, password: Password): AuthorizingSubject {
|
||||
password.use {
|
||||
@ -67,6 +64,10 @@ class RPCSecurityManagerImpl(config: AuthServiceConfig) : RPCSecurityManager {
|
||||
subjectId = SimplePrincipalCollection(principal, id.value),
|
||||
manager = manager)
|
||||
|
||||
override fun close() {
|
||||
manager.realms?.filterIsInstance<Closeable>()?.forEach { it.close() }
|
||||
manager.destroy()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@ -240,7 +241,7 @@ private class InMemoryRealm(users: List<User>,
|
||||
authorizationInfoByUser[principals.primaryPrincipal as String]
|
||||
}
|
||||
|
||||
private class NodeJdbcRealm(config: SecurityConfiguration.AuthService.DataSource) : JdbcRealm() {
|
||||
private class NodeJdbcRealm(config: SecurityConfiguration.AuthService.DataSource) : JdbcRealm(), Closeable {
|
||||
|
||||
init {
|
||||
credentialsMatcher = buildCredentialMatcher(config.passwordEncryption)
|
||||
@ -248,6 +249,10 @@ private class NodeJdbcRealm(config: SecurityConfiguration.AuthService.DataSource
|
||||
dataSource = HikariDataSource(HikariConfig(config.connection!!))
|
||||
permissionResolver = RPCPermissionResolver
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
(dataSource as? Closeable)?.close()
|
||||
}
|
||||
}
|
||||
|
||||
private typealias ShiroCache<K, V> = org.apache.shiro.cache.Cache<K, V>
|
||||
|
Loading…
Reference in New Issue
Block a user