我在这个任务上工作了太久,放弃了使用 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);
我相信这是由与事务相关的东西引起的,这就是为什么我用许多 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
我希望尽快得到答复,因为我需要完成这项任务