title: How to get spring security role hierarchy in jsp to work?
body: <p>I try to get role hierarchies to work in my application. The only thing I want is the defined hierarchy at all levels: At the url-level and for now also at the view level (in my jsp files).</p>
  
  <p>I use the following setup:</p>
  
  <pre><code>     &lt;beans:bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased"&gt;
          &lt;beans:property name="decisionVoters"&gt;
              &lt;beans:list&gt;
                  &lt;beans:ref bean="roleHierarchyVoter"/&gt;
                  &lt;beans:bean class="org.springframework.security.web.access.expression.WebExpressionVoter"&gt;
                      &lt;beans:property name="expressionHandler"&gt;
                          &lt;beans:bean class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"&gt;
                              &lt;beans:property name="roleHierarchy" ref="roleHierarchy"/&gt;
                          &lt;/beans:bean&gt;
                      &lt;/beans:property&gt;
                  &lt;/beans:bean&gt;
                  &lt;beans:bean class="org.springframework.security.access.vote.AuthenticatedVoter"/&gt;
              &lt;/beans:list&gt;
          &lt;/beans:property&gt;
      &lt;/beans:bean&gt;
  
      &lt;beans:bean id="roleHierarchyVoter" class="org.springframework.security.access.vote.RoleHierarchyVoter"&gt;
          &lt;beans:constructor-arg ref="roleHierarchy"/&gt;
      &lt;/beans:bean&gt;
  
      &lt;beans:bean id="roleHierarchy" class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl"&gt;
          &lt;beans:property name="hierarchy"&gt;
              &lt;beans:value&gt;
                  ROLE_ADMIN &gt; ROLE_OWNER
                  ROLE_OWNER &gt; ROLE_DISTRIBUTOR
                  ROLE_DISTRIBUTOR &gt; ROLE_RESELLER
                  ROLE_RESELLER &gt; ROLE_USER
              &lt;/beans:value&gt;
          &lt;/beans:property&gt;
      &lt;/beans:bean&gt;
  
  &lt;http auto-config="true" use-expressions="true" access-decision-manager-ref="accessDecisionManager"&gt;
      ...
  &lt;/http&gt;
  </code></pre>
  
  <p>For the URL Level (intercept URLs) it works very good, but in my jsp files that did not work. The problem is I did not properly understood the config to get the role hierarchy to work.</p>
  
  <pre><code>&lt;security:authorize access="hasRole('ROLE_ADMIN')"&gt;
      &lt;div class="span4"&gt;
          &lt;h2&gt;Admin&lt;/h2&gt;
      &lt;/div&gt;&lt;!--/span--&gt;
  &lt;/security:authorize&gt;
  &lt;security:authorize access="hasRole('ROLE_OWNER')"&gt;
      &lt;div class="span4"&gt;
          &lt;h2&gt;Owner&lt;/h2&gt;
      &lt;/div&gt;&lt;!--/span--&gt;
  &lt;/security:authorize&gt;
  &lt;security:authorize access="hasRole('ROLE_DISTRIBUTOR')"&gt;
      &lt;div class="span4"&gt;
          &lt;h2&gt;Distributor&lt;/h2&gt;
      &lt;/div&gt;&lt;!--/span--&gt;
  &lt;/security:authorize&gt;
  </code></pre>
  
  <p>I use this simple example to test the role hierarchy at the view level, but it does not work. Only the user with the admin role can see his block but not the others.</p>
  
  <p>Had some one an idea what I'm doing wrong with my config.</p>