2013-10-28 166 views
2

是否Spring Security Acl支持類級權限?例如,如果我有Asset類,並且我希望允許所有具有Asset類的實例對角色ROLE_USER的任何用戶具有讀取權限。只要我能看到,ObjectIdentityImpl只接受對象實例。Spring Security Acl級別權限

感謝

回答

3

Spring Security的ACL是不是這個真的很方便。我會建議你使用授權預註解來替代:

@PreAuthorize("hasRole('ROLE_USER')") 
public List<Asset> getAllAssets(); 

確保你在你的配置中啓用了前,後的註釋。

3

org.springframework.security.acls.model.ObjectIdentity是代表要保護的單個域對象身份的核心Spring Security ACL接口之一。它強加類型和標識符屬性。如果您需要課程級別的權限,則可以使用例如作爲類型的「類」和作爲標識符的實際類名(例如「資產」或「my.package.Asset」)。

根據具體情況,可能還需要相應地實現org.springframework.security.acls.model.ObjectIdentityRetrievalStrategyorg.springframework.security.acls.model.ObjectIdentityGenerator接口。