2012-11-19 4 views
2

도메인 인스턴스 대신 도메인 클래스에 대한 ACL 권한을 적용 할 수 있습니까? 나는 두 번째 클래스의 사용자가이 작업을 수행하기 위해 특정 ACL 항목을 가져야하는 반면 도메인 객체에 대한 완전한 CRUD에 대해 한 클래스의 사용자 담요 사용 권한을 제공하려는 시나리오가 있습니다.스프링 보안 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(); 

당신이 볼 수 있듯이 봄 보안 식별자의 유형을 설명하는 Serializable를 사용합니다. 그래서 클래스 이름과 함께 String을 사용할 수 있습니다.

스프링 시큐리티의 저자는 대부분의 사람들이 long/integer ID로 객체를 식별한다고 가정하므로 SQL 스키마를 업데이트해야합니다.

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

내가 검사로서, JdbcMutableAclService 그것은 단지 ObjectIdentity 인터페이스를 사용하기 때문에 그 정의를 처리 할 수 ​​있습니다.

org.springframework.security.acls 패키지의 소스 코드를 연구하십시오.

관련 문제