After I upgraded spring-security to version 4.0.2 from version 3.2.x, I am able to login to the web application, but I get the access denied if it tries to access a method that has the @PreAuthorized(hasRole()).
I have tried to inject the 'ROLE_' into the GrantAuthorities list, but the result is the same.
The same configuration works fine in version 3.2.x. Can anyone have any idea what did I do wrong?
Thanks
the security-context.xml
<http pattern="/css/**" security="none" />
<http pattern="/Images/**" security="none" />
<http pattern="/javascript/**" security="none" />
<http auto-config='true' use-expressions="true" create-session="always"
authentication-manager-ref="tunAuthenticationManager">
<csrf disabled="true" />
<intercept-url pattern="/new/**"
access="hasRole('eu_rw') or hasRole('sp_rw')" />
<intercept-url pattern="/ajax/**"
access="hasRole('eu_rw') or hasRole('sp_rw')" />
<intercept-url pattern="/v2/**"
access="hasRole('eu_rw') or hasRole('sp_rw')" />
<intercept-url pattern="/monitoring" access="hasRole('sp_rw')" />
<intercept-url pattern="/monitoring/**" access="hasRole('sp_rw')" />
<form-login login-page="/logon.jsp" username-parameter="username"
password-parameter="password" login-processing-url="/j_spring_security_check"
authentication-failure-url="/logon.jsp?login_error=1"
default-target-url="/" always-use-default-target="true" />
<custom-filter position="FIRST" ref="logoutFilter" />
<custom-filter after="FIRST" ref="requestLoggingFilter" />
<custom-filter after="LAST" ref="passwordExpirationCheckFilter" />
<custom-filter after="SWITCH_USER_FILTER" ref="authorizationAdjustmentFilter" />
<custom-filter after="EXCEPTION_TRANSLATION_FILTER" ref="ajaxTimeoutRedirectFilter" />
</http>
<authentication-manager id="tunAuthenticationManager">
<authentication-provider ref="strongDaoAuthenticationProviderProxy" />
<authentication-provider ref="tunAdAuthenticationProvider" />
</authentication-manager>
<beans:bean id="strongDaoAuthenticationProviderProxy"
class="local.company.tun.security.DaoAuthenticationProviderProxy">
<beans:constructor-arg>
<beans:bean id="strongDaoAuthenticationProvider"
class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<beans:property name="userDetailsService" ref="jdbcUserDetailsService" />
<beans:property name="passwordEncoder" ref="strongEncoder" />
<beans:property name="saltSource" ref="saltSource" />
</beans:bean>
</beans:constructor-arg>
</beans:bean>
<beans:bean id="jdbcUserDetailsService"
class="local.company.tun.security.tunUserDetailsService">
</beans:bean>
<beans:bean id="authenticationService"
class="local.company.tun.security.service.impl.AuthenticationServiceImpl">
<beans:qualifier value="authenticationService" />
<beans:property name="authenticationManager" ref="tunAuthenticationManager" />
</beans:bean>
<beans:bean
class="local.company.tun.security.DefaultRolesPrefixPostProcessor" />
servlet-context.xml
<mvc:interceptors>
<!-- Changes the locale when a 'locale' request parameter is sent;
e.g. /?locale=de -->
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
</mvc:interceptors>
<!-- Activate scanning of @Autowired -->
<context:annotation-config />
<!-- Spring Security - enable pre- post- annotations on Spring managed
MVC components -->
<bean id="expressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler" >
</bean>
<security:global-method-security pre-post-annotations="enabled">
<security:expression-handler ref="expressionHandler" />
</security:global-method-security>
....