Dispatcher servlet configuration for spring mvc-oauth
Hi,
We have RESTFul web services which we are now securing using spring security Oauth2.
The existing code in production uses a Jersey servlet to call the EJB resource.
Now I have configured a Dispatcher servlet for accepting the Oauth2 request for access token.
Issue is that the Jersey servlet is already using the /* URL pattern.
We don't want to change the URL pattern the web service endpoint.
So I wanted a more specific url pattern for the
dispatcher servlet. But if I use a pattern like /oauth/* for my dispatcher servlet then its not working.
Below is my web.xml. right now I have done a workaround by using a /ws/* for my jersey servlet. But as I said we don't want to change the existing web service endpoint urls. Please suggest.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name></display-name>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>ServiceContextFilter</filter-name>
<filter-class>com.magellanhealth.tds.mps.base.ServiceContextFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ServiceContextFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:appConfig.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:appConfig.xml</param-value>
</init-param>
<load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>JAX-RS Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Application</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
<persistence-unit-ref>
<persistence-unit-ref-name>persistence/claimsPU</persistence-unit-ref-name>
<persistence-unit-name>claimsPU</persistence-unit-name>
</persistence-unit-ref>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>