【发布时间】:2011-02-19 01:19:24
【问题描述】:
我在这个任务上工作了太久,放弃了使用 Spring Security 来实现它的想法,但我希望社区能够提供一些支持,以帮助减少我选择 Spring Security 的遗憾.废话不多说,现在让我们进入正题。
我正在尝试使用 JDBCMutableAclService.createAcl 创建 ACL,如下所示:
public void addPermission(IWFArtifact securedObject, Sid recipient, Permission permission,
Class clazz) {
ObjectIdentity oid = new ObjectIdentityImpl(clazz.getCanonicalName(), securedObject.getId());
this.addPermission(oid, recipient, permission);
}
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_UNCOMMITTED, readOnly = false)
public void addPermission(ObjectIdentity oid, Sid recipient, Permission permission) {
SpringSecurityUtils.assureThreadLocalAuthSet();
MutableAcl acl;
try {
acl = this.mutableAclService.createAcl(oid);
} catch (AlreadyExistsException e) {
acl = (MutableAcl) this.mutableAclService.readAclById(oid);
}
// try {
// acl = (MutableAcl) this.mutableAclService.readAclById(oid);
// } catch (NotFoundException nfe) {
// acl = this.mutableAclService.createAcl(oid);
// }
acl.insertAce(acl.getEntries().length, permission, recipient, true);
this.mutableAclService.updateAcl(acl);
}
调用从该行抛出 NotFoundException:
// Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc)
Acl acl = readAclById(objectIdentity);
我相信这是由与 Transactional 相关的某些东西引起的,这就是我使用许多 TransactionDefinition 属性进行测试的原因。我也怀疑注释并尝试使用声明性事务定义,但仍然没有运气。
重要的一点是,我之前在方法中直接在数据库中使用了用于在数据库中插入 oid 的语句并且它起作用了,并且当它试图将它插入到方法。
我正在使用 Spring Security 2.0.8 和 IceFaces 1.8(它不支持 spring 3.0 但绝对支持 2.0.x,特别是当我不断调用 SpringSecurityUtils.assureThreadLocalAuthSet()) 时。我的 AppServer 是 Tomcat 6.0,而我的数据库服务器是MySQL 6.0
我希望尽快得到回复,因为我需要完成这项任务
【问题讨论】:
标签: spring-security spring-transactions