2012-11-19 51 views
2

是否可以在域类(而不是域实例?)上应用ACL权限?我有一个场景,我希望提供一类用户一揽子权限,以便在域对象上完全CRUD,而第二类用户必须具有特定的ACL条目才能执行此操作。春季安全ACL可以应用于域类级别吗?

这当然是可能的基于角色的权限混合ACL条目来实现这一点,但我觉得有春天的ACL更优雅的解决方案可以在除了实例级别上的一流水平的工作。

我期待在微薄Spring Security ACL documentationthis question

回答

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来描述标识符的类型。 所以有可能使用带类名的字符串。

您将需要更新SQL模式为春季安全的作者认为大多数人会通过长/整数ID识别物体。

create table acl_object_identity(
... 
object_id_class bigint not null, 
object_id_identity bigint not null, 

正如我检查,JdbcMutableAclService能,因为它仅使用ObjectIdentity接口来处理定制。

研究org.springframework.security.acls包的源代码。