Hi here is my secruity configuration (auth mechanism omitted)
Code:
<!-- HTTP security configurations -->
<http auto-config="true" use-expressions="true">
<form-login login-processing-url="/static/j_spring_security_check" login-page="/login" authentication-failure-url="/login?login_error=t"/>
<logout logout-url="/static/j_spring_security_logout"/>
<!-- Configure these elements to secure URIs in your application -->
<!-- <intercept-url pattern="/choice/**" access="hasRole('ROLE_ADMIN')"/>--><!--
<intercept-url pattern="/member/**" access="isAuthenticated()" />
--><intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/static/**" access="permitAll" />
<intercept-url pattern="/login" access="permitAll" />
<intercept-url pattern="/**" access="isAuthenticated()" />
</http>
Here is the controller method, that should be used:
Code:
@RequestMapping(method = RequestMethod.PUT)
public String update(@Valid ScriptFile scriptFile, BindingResult result, ModelMap modelMap, HttpServletRequest request) {
if (scriptFile == null) throw new IllegalArgumentException("A scriptFile is required");
if (result.hasErrors()) {
modelMap.addAttribute("scriptFile", scriptFile);
modelMap.addAttribute("showcases", ShowCase.findAllShowCases());
return "scriptfile/update";
}
setFileParameters(scriptFile, request);
scriptFile.merge();
return "redirect:/scriptfile/" + scriptFile.getId();
}
And here is waht the log says:
Code:
Converted URL to lowercase, from: '/scriptfile/3'; to: '/scriptfile/3'
Candidate is: '/scriptfile/3'; pattern is /resources/**; matched=false
Candidate is: '/scriptfile/3'; pattern is /static/**; matched=false
Candidate is: '/scriptfile/3'; pattern is /login; matched=false
Candidate is: '/scriptfile/3'; pattern is /**; matched=true
Secure object: FilterInvocation: URL: /scriptfile/3; Attributes: [isAuthenticated()]
Previously Authenticated: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@bad9b5a1: Principal: org.springframework.security.core.userdetails.User@0: Username: admin; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMIN; Password: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@fffc7f0c: RemoteIpAddress: 127.0.0.1; SessionId: 127lj3enf736d; Granted Authorities: ROLE_ADMIN
Voter: org.springframework.security.web.access.expression.WebExpressionVoter@73db92, returned: 1
Authorization successful
RunAsManager did not change Authentication object
/scriptfile/3 reached end of additional filter chain; proceeding with original chain
Using EntityManagerFactory 'entityManagerFactory' for OpenEntityManagerInViewFilter
Returning cached instance of singleton bean 'entityManagerFactory'
Opening JPA EntityManager in OpenEntityManagerInViewFilter
DispatcherServlet with name 'sc' processing POST request for [/sc/app/scriptfile/3]
Found multipart file [file] of size 1167 bytes with original filename [Lesson-1A-SQL-Injection.html], stored in memory
Matching patterns for request [/scriptfile/3] are [/scriptfile/{id}, /scriptfile/**/, /scriptfile/**]
Mapping [/scriptfile/3] to handler 'com.mycompany.sc.web.ScriptFileController@19a13e5'
Resolving exception from handler [com.mycompany.sc.web.ScriptFileController@19a13e5]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
Resolving to view 'uncaughtException' for exception of type [org.springframework.web.HttpRequestMethodNotSupportedException], based on exception mapping [.lang.Exception]
Exposing Exception as model attribute 'exception'
Handler execution resulted in exception - forwarding to resolved error view: ModelAndView: reference to view with name 'uncaughtException'; model is {exception=org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported}
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodResolver.resolveHandlerMethod(AnnotationMethodHandlerAdapter.java:567)
Here is the form-Tag as I use it (ony small modification from what roo generated):
Code:
<form:form action="${form_url}" method="PUT" modelAttribute="scriptFile" enctype="multipart/form-data">
As you can see the form states PUT but the logoutput shows that spring-mvc is trying to map a POST method. I'll check the requests again with firebug.