是否可以对域类(而不是域实例?)应用ACL权限。我有一个场景,我想提供一类用户对域对象完全CRUD的一揽子权限,而第二类用户必须有特定的ACL条目来执行此操作。
当然可以将ACL条目与基于角色的权限混合来实现这一点,但我觉得有一个更优雅的解决方案,除了实例级别之外,Spring ACL还可以在类级别上工作
答案 0 :(得分:1)
查看界面ObjectIdentity
。它表示在系统中受保护的对象。
/**
* Obtains the actual identifier. This identifier must not be reused to represent other domain objects with
* the same javaType.
*
* Because ACLs are largely immutable, it is strongly recommended to use
* a synthetic identifier (such as a database sequence number for the primary key). Do not use an identifier with
* business meaning, as that business meaning may change in the future such change will cascade to the ACL
* subsystem data.
*
* @return the identifier (unique within this type; never null)
*/
Serializable getIdentifier();
/**
* Obtains the "type" metadata for the domain object. This will often be a Java type name (an interface or a class)
* – traditionally it is the name of the domain object implementation class.
*
* @return the "type" of the domain object (never null).
*/
String getType();
正如您所见,Spring Security使用Serializable
来描述标识符的类型。
因此可以使用带有类名的String。
您需要更新SQL架构,因为Spring Security的作者假设大多数人都会通过长/整数ID识别对象。
create table acl_object_identity(
...
object_id_class bigint not null,
object_id_identity bigint not null,
在我查看时,JdbcMutableAclService
能够处理该自定义,因为它只使用ObjectIdentity
接口。
研究org.springframework.security.acls
包的源代码。