mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-13 05:43:29 +00:00
SEC-670: Provide mutator for JdbcMutableAclService.foreignKeysInDatabase property.
This commit is contained in:
parent
8a7bfafce9
commit
54882fe1ea
@ -60,7 +60,7 @@ import javax.sql.DataSource;
|
|||||||
public class JdbcMutableAclService extends JdbcAclService implements MutableAclService {
|
public class JdbcMutableAclService extends JdbcAclService implements MutableAclService {
|
||||||
//~ Instance fields ================================================================================================
|
//~ Instance fields ================================================================================================
|
||||||
|
|
||||||
private boolean foreignKeysInDatabase = false;
|
private boolean foreignKeysInDatabase = true;
|
||||||
private AclCache aclCache;
|
private AclCache aclCache;
|
||||||
private String deleteClassByClassNameString = "DELETE FROM acl_class WHERE class=?";
|
private String deleteClassByClassNameString = "DELETE FROM acl_class WHERE class=?";
|
||||||
private String deleteEntryByObjectIdentityForeignKey = "DELETE FROM acl_entry WHERE acl_object_identity=?";
|
private String deleteEntryByObjectIdentityForeignKey = "DELETE FROM acl_entry WHERE acl_object_identity=?";
|
||||||
@ -385,5 +385,12 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
|
|||||||
Assert.hasText(identityQuery, "New identity query is required");
|
Assert.hasText(identityQuery, "New identity query is required");
|
||||||
this.identityQuery = identityQuery;
|
this.identityQuery = identityQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param foreignKeysInDatabase if false this class will perform additional FK constrain checking, which may
|
||||||
|
* cause deadlocks (the default is true, so deadlocks are avoided but the database is expected to enforce FKs)
|
||||||
|
*/
|
||||||
|
public void setForeignKeysInDatabase(boolean foreignKeysInDatabase) {
|
||||||
|
this.foreignKeysInDatabase = foreignKeysInDatabase;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,11 +318,14 @@ public class JdbcAclServiceTests extends AbstractTransactionalDataSourceSpringCo
|
|||||||
public void testDeleteAclWithChildrenThrowsException() throws Exception {
|
public void testDeleteAclWithChildrenThrowsException() throws Exception {
|
||||||
try {
|
try {
|
||||||
ObjectIdentity topParentOid = new ObjectIdentityImpl("org.springframework.security.TargetObject", new Long(100));
|
ObjectIdentity topParentOid = new ObjectIdentityImpl("org.springframework.security.TargetObject", new Long(100));
|
||||||
|
jdbcMutableAclService.setForeignKeysInDatabase(false); // switch on FK checking in the class, not database
|
||||||
jdbcMutableAclService.deleteAcl(topParentOid, false);
|
jdbcMutableAclService.deleteAcl(topParentOid, false);
|
||||||
fail("It should have thrown ChildrenExistException");
|
fail("It should have thrown ChildrenExistException");
|
||||||
}
|
}
|
||||||
catch (ChildrenExistException expected) {
|
catch (ChildrenExistException expected) {
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
|
} finally {
|
||||||
|
jdbcMutableAclService.setForeignKeysInDatabase(true); // restore to the default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user