title: How configure the Spring Security to allow the use for hasPermission in the JSP page?
body: <p>I am trying use hasPermission in my jsp pages from my spring project. I already use this with no problem in the methods from my controller / service classes. Reading the article:</p>
  
  <p><a href="http://docs.spring.io/spring-security/site/docs/4.0.0.M1/reference/htmlsingle/#the-accesscontrollist-tag" rel="nofollow">http://docs.spring.io/spring-security/site/docs/4.0.0.M1/reference/htmlsingle/#the-accesscontrollist-tag</a></p>
  
  <p>from official documentation, I understood that for do that I nwill need implement a class derived from DefaultPermission which would be loaded from a custom AclService class.</p>
  
  <p>My problem it's i can't find any information of how implement all that classes, and even don't know if this approach it's the only one or if I understood the subject in the right way (the official documentation is very brief about this subject, and in the rest of internet i can't find more information).</p>
  
  <p>Anyone can point me in the right direction here? Maybe indicate some tutorial or sample of code.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Reading other topics here from StackOverflow, I found this sugestion:</p>
  
  <blockquote>
  <pre><code>This is what I have done. I created my own permission evaulator:
  </code></pre>
  </blockquote>
  
  <pre><code>&gt;     public class MyPermissionEvaluator implements PermissionEvaluator {
  &gt;     ...
  &gt;     }
  </code></pre>
  
  <blockquote>
  <pre><code>Then I configured spring to use that evaulator via
  </code></pre>
  </blockquote>
  
  <pre><code>&gt;     &lt;beans:bean id="expressionHandler"
  &gt;         class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler"&gt;
  &gt;           &lt;beans:property name="permissionEvaluator" ref="permissionEvaluator"/&gt;
  &gt;     &lt;/beans:bean&gt;
  &gt;     
  &gt;     &lt;beans:bean id="webExpressionHandler" 
  &gt;         class="com.bulb.learn.webapp.security.CustomWebSecurityExpressionHandler"&gt;
  &gt;         &lt;beans:property name="permissionEvaluator" ref="permissionEvaluator"/&gt;
  &gt;     &lt;/beans:bean&gt;
  &gt;     
  &gt;     &lt;beans:bean id="permissionEvaluator" class="my.domain.MyPermissionEvaluator" /&gt;
  </code></pre>
  
  <blockquote>
  <pre><code>That way all expression handlers have access to my evaulator.
  
  Then, in JSP (actually, I am using jspx), I can make tags like this:
  </code></pre>
  </blockquote>
  
  <pre><code>&gt;     &lt;sec:authorize access="hasPermission(#childUnit, 'read')"&gt;
  &gt;          ...
  &gt;     &lt;/sec:authorize&gt;
  </code></pre>
  
  <blockquote>
  <pre><code>Hope that gets you heading in the right direction.
  </code></pre>
  </blockquote>
  
  <p>As I already have a Custom PermissionEvaluator, I try this method. It works partially, but now, even when the user has the permission, the element inside the tag isn't displayed. Also, the eclipse indicate an error related to this tag ('Syntax error on token(s), misplaced construct(s)'), despite the application being built and executed without errors.</p>
  
  <p>In the console, this error is displayed:</p>
  
  <pre><code>un 03, 2014 7:48:40 PM org.springframework.security.access.expression.DenyAllPermissionEvaluator hasPermission
  Advertência: Denying user klebermo permission 'cadastra_usuario' on object null
  Jun 03, 2014 7:48:40 PM org.springframework.security.access.expression.DenyAllPermissionEvaluator hasPermission
  Advertência: Denying user klebermo permission 'altera_usuario' on object null
  Jun 03, 2014 7:48:40 PM org.springframework.security.access.expression.DenyAllPermissionEvaluator hasPermission
  Advertência: Denying user klebermo permission 'remove_usuario' on object null
  Jun 03, 2014 7:48:45 PM org.springframework.security.access.expression.DenyAllPermissionEvaluator hasPermission
  Advertência: Denying user klebermo permission 'cadastra_permissao' on object null
  Jun 03, 2014 7:48:45 PM org.springframework.security.access.expression.DenyAllPermissionEvaluator hasPermission
  Advertência: Denying user klebermo permission 'altera_permissao' on object null
  Jun 03, 2014 7:48:45 PM org.springframework.security.access.expression.DenyAllPermissionEvaluator hasPermission
  Advertência: Denying user klebermo permission 'remove_permissao' on object null
  Jun 03, 2014 7:48:57 PM org.springframework.security.access.expression.DenyAllPermissionEvaluator hasPermission
  Advertência: Denying user klebermo permission 'cadastra_usuario' on object null
  Jun 03, 2014 7:48:57 PM org.springframework.security.access.expression.DenyAllPermissionEvaluator hasPermission
  Advertência: Denying user klebermo permission 'altera_usuario' on object null
  Jun 03, 2014 7:48:57 PM org.springframework.security.access.expression.DenyAllPermissionEvaluator hasPermission
  Advertência: Denying user klebermo permission 'remove_usuario' on object null
  </code></pre>
  
  <p>In the Internet, I found some articles sugesting I should implement a Interface for WebSecurityExpressionHandler.</p>
  
  <p>Anyone know what the right step here?</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Previously, I was using this tag:</p>
  
  <pre><code>&lt;sec:accesscontrollist hasPermission="1,2" domainObject="${someObject}"&gt;
  </code></pre>
  
  <p>This will be shown if the user has either of the permissions represented by the values "1" or "2" on the given object.</p>
  
  <pre><code>&lt;/sec:accesscontrollist&gt;
  </code></pre>
  
  <p>where no error was displayed in the console, but still doesn't work. My question which object I need implement to atribute domainObject of the tag?</p>