We will implement the ACL functionality in a Spring Service class now. We can provide the access privileges using ACL classes, as follows:
Create a Spring Service class, as shown in the following:
Create the
Book.java
model class as shown in the following figure:Create the
BookServiceImpl.java
service implementation class. In this block, we will create thegrantPermission()
method that has the ACL implementation to grant permission to the given principal. We also have to provide the read and write permission entries, as follows:In the following block, we are adding the implementations to create, find, and update all books:
After running the first test, the following result will be printed:
To test the ACL implementation, we need to create a
BookServiceTest.java
JUnit test class, where we can include various test cases to access the domain object, as follows:We can test and find all the books services by adding the following test cases...