I am writing a REST web service and I am using Spring 4 with annotation-based configuration.
I am also using Spring security for HTTP Basic authentication and authorization.
I have an ItemRestPresentation
class purely used for the presentation layer whose instances are created in my controller method using instances of another class called Item (the actual domain object). ItemRestPresentation
instances get converted to the following JSON by my controller method:
ItemRestPresentation class:
public class ItemRestPresentation {
private String name;
private String description;
private boolean canDelete;
// ... private constructor, public getters and public static factory method to create an ItemRestPresentation instance from an Item instance
}
Generated JSON :
{
"name" : "item1",
"description": "Sample item for testing",
"canDelete" : true
}
Is it possible to use Spring Security ACL to set the canDelete
member of the ItemRestPresentation
instance to the correct value depending on whether the current user has permission to delete it?