ββ Spring API ACL. :
- Spring
org.springframework.security.acls.model.AclService, , , . . foo , READ WRITE; , READ, WRITE DELETE . - , ,
org.springframework.security.access.prepost.PreAuthorize org.springframework.security.access.prepost.PreAuthorize, , . . , "WRITE" X, , "READ" . - , AccessDeniedException. - Spring .
global-method-security Spring XML.
, , - . who-gets-what-permissions-on-which-objects "-----", .
, , . " ", " ", . Spring ACL API - , .
-, :
@PostAuthorize("hasPermission(returnObject, 'READ')")
public MyItem getMyItem(Long id) {
return dao.getMyItem(id);
}
@PreAuthorize("hasPermission(#toDelete, 'DELETE')")
public void deleteMyItem(MyItem toDelete) {
dao.delete(toDelete);
}
AclService , :
public Acl readAclById(ObjectIdentity objectIdentity, List<Sid> sids) throws NotFoundException {
return new AclImpl(...);
}
applicationContext-security.xml:
<beans:bean id="permissionEvaluator"
class="org.springframework.security.acls.AclPermissionEvaluator">
<beans:constructor-arg ref="aclServiceImpl" />
</beans:bean>
<beans:bean id="expressionHandler"
class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler">
<beans:property name="permissionEvaluator" ref="permissionEvaluator" />
</beans:bean>
<global-method-security pre-post-annotations="enabled">
<expression-handler ref="expressionHandler" />
</global-method-security>