Applying Spring Security on RESTful web services
REST has become another means of providing web services.
The data can be shared across applications using XML, text, or in JSON format. REST web services are considered as lightweight web services.
Let's apply Spring Security for accessing the REST web service, so that only authorized users can access the RESTful web service. Since the RESTful web service is accessed with a URL and uses HTTP protocol we can easily apply the URL level security. This example demonstrates form-based authentication. But the user can also use BASIC and Digest Authentication.
The following are the annotations used with Spring to generate RESTful web services:
@PathVariable
@RequestMapping
@RequestMethod
Getting ready
Create a RESTful web service using Spring web service API
Add Spring Security dependencies
Add Spring filter configuration to the
Web.xml
fileConfigure the
application-security.xml
fileCreate an
AccessController
class to handle the login and logout actions...