Spring Security ACL:来自 JDBCMutableAclService.createAcl 的 NotFoundException
我已经在这个任务上工作了太长时间,无法放弃使用 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()
时)。我的应用程序服务器是 Tomcat 6.0,我的数据库服务器是 MySQL 6.0
我希望尽快得到答复,因为我需要完成这项任务
I've been working on this task for too long to abandon the idea of using Spring Security to achieve it, but I wish that the community will provide with some support that will help reduce the regret that I have for choosing Spring Security. Enough ranting and now let's get to the point.
I'm trying to create an ACL by using JDBCMutableAclService.createAcl as follows:
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);
}
The call throws a NotFoundException from the line:
// Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc)
Acl acl = readAclById(objectIdentity);
I believe this is caused by something related to Transactional, and that's why I have tested with many TransactionDefinition attributes. I have also doubted the annotation and tried with declarative transaction definition, but still with no luck.
One important point is that I have used the statement used to insert the oid in the database earlier in the method directly on the database and it worked, and also threw a unique constraint exception at me when it tried to insert it in the method.
I'm using Spring Security 2.0.8 and IceFaces 1.8 (which doesn't support spring 3.0 but definetely supprorts 2.0.x, specially when I keep caling SpringSecurityUtils.assureThreadLocalAuthSet())
. My AppServer is Tomcat 6.0, and my DB Server is MySQL 6.0
I wish to get back a reply soon because I need to get this task off my way
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码格式不太好,无法理解在哪一行抛出错误。
无论如何,必须捕获 NotFoundException 并创建一个新的 acl :
Your code isn't formatted very well to understand on which line error is thrown.
Anyway a NotFoundException has to catched and create a new acl :