I tried the suggested methods, I did the following, it seemed to work beautifully
Added these changes to your web xml
<filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet-mapping> <servlet-name>service</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <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>
Add these changes to spring-security xml
<security:authentication-manager alias="authenticationManager"> <security:authentication-provider> <security:user-service> <security:user name="${resource.service.authentication.name}" authorities="${resource.service.authentication.authorities}" password="${resource.service.authentication.password}"/> </security:user-service> </security:authentication-provider> </security:authentication-manager>
Add these changes to your xml application context or if you have an xml property loader file better
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="placeholderPrefix" value="${" /> <property name="placeholderSuffix" value="}" /> <property name="locations"> <list> <value>classpath:resourceservice.properties</value> </list> </property> </bean>
Then add these changes to your resourceservice.properties property file
memberservice.authentication.name=usename memberservice.authentication.authorities=AUTHORISED memberservice.authentication.password=password
Add these changes to your jersey resource
@PUT @Path("{accountId}") @Consumes("application/xml") @PreAuthorize("hasRole('AUTHORISED')") public Response methodName
Basil zocca
source share