title: spring security redirect based on role not working
body: <p>well i try to redirect user base on role but my custom class do nothing i do some system out but nothing happen.</p>
  
  <p>i follow this small tutorial <a href="http://oajamfibia.wordpress.com/2011/07/07/role-based-login-redirect/#comment-12" rel="nofollow">http://oajamfibia.wordpress.com/2011/07/07/role-based-login-redirect/#comment-12</a></p>
  
  <p>but i change my extention class for <strong>SavedRequestAwareAuthenticationSuccessHandler</strong> i also try the one in the tutorial nothing happen don't know what i missing. Any help will be appreciate.</p>
  
  <p>this is my class</p>
  
  <pre><code>@Component
  public class RoleBaseAuthentification extends SavedRequestAwareAuthenticationSuccessHandler{
  
      private Map&lt;String, String&gt; roleMap;
  
      @Override
      public void onAuthenticationSuccess(HttpServletRequest request,
              HttpServletResponse response, Authentication authentication)
              throws ServletException, IOException {
          System.out.println(request.getUserPrincipal());
          if(authentication.getPrincipal() instanceof UserDetails){
              UserDetails userDetails = (UserDetails) authentication.getPrincipal();
              System.out.println(userDetails);
              String role = userDetails.getAuthorities().isEmpty() ? null : userDetails.getAuthorities().toArray()[0].toString();
              System.out.println(role);
              response.sendRedirect(request.getContextPath() + roleMap.get(role));
          }
          super.onAuthenticationSuccess(request, response, authentication);
      }
  
      public Map&lt;String, String&gt; getRoleMap() {
          return roleMap;
      }
  
      public void setRoleMap(Map&lt;String, String&gt; roleMap) {
          this.roleMap = roleMap;
      }
  
  
  }
  </code></pre>
  
  <p>and here is my security-context.xml</p>
  
  <pre><code>&lt;security:authentication-manager alias="authenticationManager"&gt; 
      &lt;security:authentication-provider&gt;
          &lt;security:jdbc-user-service data-source-ref="dataSource"
              users-by-username-query="select username,password,enabled from users where username = ?"
              authorities-by-username-query="select u.username, ur.authority from users u, user_roles ur where u.user_id =  ur.user_id and u.username = ?" /&gt;
      &lt;/security:authentication-provider&gt;
  &lt;/security:authentication-manager&gt;
  &lt;security:http use-expressions="true"&gt;
      &lt;security:intercept-url pattern="/management" access="hasRole('ROLE_ADMIN')"/&gt;
      &lt;security:form-login login-page="/login" authentication-success-handler-ref="redirectByRole"/&gt;
  &lt;/security:http&gt;
  
  &lt;bean id="redirectByRole" class="com.freelogic.spring.web.service.RoleBaseAuthentification"&gt;
  &lt;property name="roleMap"&gt;
      &lt;map&gt;
          &lt;entry key="ROLE_ADMIN" value="/management.jsp" /&gt;
          &lt;entry key="ROLE_USER" value="/home.jsp" /&gt;
      &lt;/map&gt;
  &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>