mirror of
https://github.com/corda/corda.git
synced 2025-06-18 23:28:21 +00:00
ENT-6588 Restrict database operations platform flag (#7053)
* ENT-6588 Restrict database operations platform flag Put the restricting of database operations in `RestrictedConnection` and `RestrictedEntityManager` behind a platform version flag. `RESTRICTED_DATABASE_OPERATIONS = 7` was added to signify this. If the version is less than 7, then the database operations will not be restricted. A warning is logged to indicate that they are using potentially dangerous methods. If the version is 7 or greater, then the database operations are restricted and throw an error if called.
This commit is contained in:
@ -1162,7 +1162,7 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
||||
/**
|
||||
* Exposes the database connection as a [RestrictedConnection] to the users.
|
||||
*/
|
||||
override fun jdbcSession(): Connection = RestrictedConnection(database.createSession())
|
||||
override fun jdbcSession(): Connection = RestrictedConnection(database.createSession(), services)
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
override fun <T : Any?> withEntityManager(block: EntityManager.() -> T): T {
|
||||
@ -1172,7 +1172,7 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
||||
withSavePoint { savepoint ->
|
||||
// Restrict what entity manager they can use inside the block
|
||||
try {
|
||||
block(RestrictedEntityManager(manager)).also {
|
||||
block(RestrictedEntityManager(manager, services)).also {
|
||||
if (!manager.transaction.rollbackOnly) {
|
||||
manager.flush()
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user