The following screenshot will explain the POM file creation. We need to add the following dependencies in the POM file in order to create a Spring RESTful web service security project:
spring-security-web
spring-security-config
spring-core
spring-context
spring-web
spring-webmvc
The next step is to configure the XML files for Spring set up. The following is the screenshot of web.xml
where AnnotationConfigWebApplicationContext
, ContextLoaderListener
, DispatcherServlet
, and DelegatingFilterProxy
are configured. Here, servlet-mapping and URL pattern are also specified:
We can configure the Security Configurations
as shown in the following webSecurityConfig.xml
file:
The entry point references are given in this security config
file, along with the interceptor URL pattern. We can also see the entries for RestAuthenticationSuccessHandler
and SimpleUrlAuthenticationFailureHandler
. Here, we have mentioned the credentials for two different roles: admin and user with...