Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Suppose now we want to secure our contact application. Only those users who logged into the application with a valid user ID can add a new contact or update existing contacts. Other users, known as anonymous users, can only view contact information.
Spring Security is the best choice for securing Spring-based applications. Although mostly used in the presentation layer, Spring Security can help secure all layers within the application, including the service layer. In the following sections, we will demonstrate how to use Spring Security to secure the contact application.
Table 17-8 lists the dependencies required for Spring Security.
To configure Spring Security, first we need to configure a filter in the web deployment descriptor (web.xml). Listing 17-57 shows the code snippet you need to add to the web.xml file.