Browse Source

Tidying up.

3.0.x
Luke Taylor 17 years ago
parent
commit
da823b2396
  1. 14
      acl/src/main/java/org/springframework/security/acls/jdbc/JdbcMutableAclService.java
  2. 2
      acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTests.java

14
acl/src/main/java/org/springframework/security/acls/jdbc/JdbcMutableAclService.java

@ -116,8 +116,7 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
return acl.getEntries().size(); return acl.getEntries().size();
} }
public void setValues(PreparedStatement stmt, int i) public void setValues(PreparedStatement stmt, int i) throws SQLException {
throws SQLException {
AccessControlEntry entry_ = acl.getEntries().get(i); AccessControlEntry entry_ = acl.getEntries().get(i);
Assert.isTrue(entry_ instanceof AccessControlEntryImpl, "Unknown ACE class"); Assert.isTrue(entry_ instanceof AccessControlEntryImpl, "Unknown ACE class");
AccessControlEntryImpl entry = (AccessControlEntryImpl) entry_; AccessControlEntryImpl entry = (AccessControlEntryImpl) entry_;
@ -187,28 +186,27 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
Assert.notNull(sid, "Sid required"); Assert.notNull(sid, "Sid required");
String sidName = null; String sidName = null;
boolean principal = true; boolean sidIsPrincipal = true;
if (sid instanceof PrincipalSid) { if (sid instanceof PrincipalSid) {
sidName = ((PrincipalSid) sid).getPrincipal(); sidName = ((PrincipalSid) sid).getPrincipal();
} else if (sid instanceof GrantedAuthoritySid) { } else if (sid instanceof GrantedAuthoritySid) {
sidName = ((GrantedAuthoritySid) sid).getGrantedAuthority(); sidName = ((GrantedAuthoritySid) sid).getGrantedAuthority();
principal = false; sidIsPrincipal = false;
} else { } else {
throw new IllegalArgumentException("Unsupported implementation of Sid"); throw new IllegalArgumentException("Unsupported implementation of Sid");
} }
List<Long> sidIds = jdbcTemplate.queryForList(selectSidPrimaryKey, List<Long> sidIds = jdbcTemplate.queryForList(selectSidPrimaryKey,
new Object[] {new Boolean(principal), sidName}, Long.class); new Object[] {Boolean.valueOf(sidIsPrincipal), sidName}, Long.class);
if (!sidIds.isEmpty()) { if (!sidIds.isEmpty()) {
return sidIds.get(0); return sidIds.get(0);
} }
if (allowCreate) { if (allowCreate) {
jdbcTemplate.update(insertSid, new Object[] {new Boolean(principal), sidName}); jdbcTemplate.update(insertSid, new Object[] {Boolean.valueOf(sidIsPrincipal), sidName});
Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(), Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(), "Transaction must be running");
"Transaction must be running");
return new Long(jdbcTemplate.queryForLong(sidIdentityQuery)); return new Long(jdbcTemplate.queryForLong(sidIdentityQuery));
} }

2
acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTests.java

@ -383,7 +383,7 @@ public class JdbcMutableAclServiceTests extends AbstractTransactionalJUnit4Sprin
@Test @Test
@Transactional @Transactional
@Rollback @Rollback
public void identityWithIntegerIdIsSupported() throws Exception { public void identityWithIntegerIdIsSupportedByCreateAcl() throws Exception {
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
ObjectIdentity oid = new ObjectIdentityImpl("org.springframework.security.TargetObject", Integer.valueOf(101)); ObjectIdentity oid = new ObjectIdentityImpl("org.springframework.security.TargetObject", Integer.valueOf(101));
jdbcMutableAclService.createAcl(oid); jdbcMutableAclService.createAcl(oid);

Loading…
Cancel
Save