My server has been using spring security (current version 3.0.5.RELEASE) successfully on its SOAP interface for a long time.
The server also has a REST interface implemented using jersey. I am now adding spring security based authentication on some of the Jersey resource methods. I want the REST client to be forced to authenticate when accessing the search() method of my jersey resource. So I annotate it with the org.springframework.security.access.prepost.PreAut horize annotation as follows:
Next I edited my web.xml to add the following:Code:@Path("/") @Component @Scope("singleton") public class MyRestResource { @Path("/search") @GET @PreAuthorize("isAuthenticated()") public Response search(...) { } }
Finally I edited my servers application context to enable form based authentication on my REST interface with teh following additions:Code:<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> ... <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>/rest/*</url-pattern> </filter-mapping> ... </web-app>
When I start my server it works as normal with SOAP requests (good, nothing broke). When I try the REST request it tries to navigate to http://localhost:8080/my-app-context...security_login (good, redirect is being attempted). However, it gets a 404 when accessing that page (bad).Code:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security" xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> ... <security:global-method-security pre-post-annotations="enabled" /> <security:http auto-config='true'> <security:intercept-url pattern="/**" /> <security:anonymous username="guest" granted-authority="ROLE_Guest"/> <security:form-login/> <security:logout/> </security:http> <beans>
Can any one guide me as to why I am getting a 404 on the spring-security provided web page spring_security_login? Also, where can I find the source to this page so I can customize it.
Thank you for your help.


Reply With Quote
