Note that there are some explanatory texts on larger screens.

plurals
  1. POSecuring GWT servlets with Spring Security
    primarykey
    data
    text
    <p>I'm writing a GWT application secured with Spring security. Logging in works fine, but authorization doesn't.</p> <p>I've tried using @Secured and @PreAuthorize annotations on my methods and that didn't work either.</p> <p>For instance, this is a code snippet from AppUserServiceImpl</p> <pre><code>@Secured("ROLE_ADMINISTRATOR") @Override public List&lt;AppUser&gt; fetch(Integer startRow, Integer endRow, Map criteria) { return appUserManagerBean.getUsers(criteria); } </code></pre> <p>ApplicationContext.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"&gt; &lt;http auto-config="true"&gt; &lt;intercept-url pattern="/testapplication/**" access="ROLE_USER"/&gt; &lt;intercept-url pattern="/gwt/**" access="ROLE_USER"/&gt; &lt;intercept-url pattern="/**/*.html" access="ROLE_USER"/&gt; &lt;intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" /&gt; &lt;intercept-url pattern="/security/*" access="IS_AUTHENTICATED_ANONYMOUSLY" /&gt; &lt;intercept-url pattern="/testapplication/appUserService*" access="ROLE_ADMIN"/&gt; &lt;form-login login-page="/login.jsp" authentication-failure-url="/security/error.html" login-processing-url="/j_spring_security_check" /&gt; &lt;/http&gt; &lt;beans:bean id="appUserService" class="com.test.testapplication.server.admin.appuser.AppUserServiceImpl"/&gt; &lt;beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; [DATASOURCE CONFIGURATION] &lt;/beans:bean&gt; &lt;global-method-security pre-post-annotations="enabled" secured-annotations="enabled" /&gt; &lt;authentication-manager&gt; &lt;authentication-provider&gt; &lt;password-encoder hash="sha" /&gt; &lt;jdbc-user-service data-source-ref="dataSource" users-by-username-query="select username,password,DECODE(enabled,'Y',1,'N',0) as enabled from APP_USER where username=?" authorities-by-username-query="select u.username, ur.role from APP_USER u, APP_USER_ROLE ur where u.id = ur.APP_USER_ID and u.username =? " /&gt; &lt;/authentication-provider&gt; &lt;/authentication-manager&gt; </code></pre> <p></p> <p>To test, I'm trying to secure 'appUserService'.</p> <p>web.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt; /WEB-INF/applicationContext.xml &lt;/param-value&gt; &lt;/context-param&gt; &lt;servlet&gt; &lt;servlet-name&gt;appUserService&lt;/servlet-name&gt; &lt;servlet-class&gt;com.test.testapplication.server.admin.appuser.AppUserServiceImpl&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;!-- Spring security filter --&gt; &lt;filter&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; &lt;!-- Spring listener --&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;!-- Default page to serve --&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;testapplication.html&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; </code></pre> <p></p> <p>I'm looking for the simplest solution and I would prefer not to use AspectJ, help would be greatly appreciated</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload