Book Image

Spring Security Essentials

By : Nanda Nachimuthu
Book Image

Spring Security Essentials

By: Nanda Nachimuthu

Overview of this book

<p>Spring Security is a framework that focuses on providing both authentication and authorization to Java applications. Like all Spring projects, the real power of Spring Security is how easily it can be extended to meet custom requirements. The popularity of the Spring framework is increasing and the security package of Spring addresses vast mechanisms of Security in a rich way. Due to an increasing number of applications for various business needs, the integration of multiple applications is becoming inevitable. The standard security procedures available across multiple implementations in Spring will protect vulnerable applications that are open to larger public and private audiences.</p> <p>Spring Security Essentials focuses on the need to master the security layer, which is an area not often explored by a Spring developer.</p> <p>At the beginning, we’ll introduce various industry standard security mechanisms and the practical ways to integrate with them. We will also teach you about some up-to-date use cases such as building a security layer for RESTful web services and applications.</p> <p>The IDEs used and security servers involved are briefly explained, including the steps to install them. Many sample projects are also provided to help you practice your newly developed skills. Step-by-step instructions will help you master the security layer integration with the Server, then implement the experience gained from this book in your own real-time application.</p>
Table of Contents (17 chapters)
Spring Security Essentials
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

ACL implementation example and XML configuration for ACL


We will implement the ACL functionality in a Spring Service class now. We can provide the access privileges using ACL classes, as follows:

  1. Create a Spring Service class, as shown in the following:

  2. Create the Book.java model class as shown in the following figure:

  3. Create the BookServiceImpl.java service implementation class. In this block, we will create the grantPermission() 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:

  4. In the following block, we are adding the implementations to create, find, and update all books:

  5. After running the first test, the following result will be printed:

  6. 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:

  7. We can test and find all the books services by adding the following test cases...