title: How to check the user role in granted authorities inside method
body: <p>I have a custom(synthetic) user role in my app to limit users activities. We use @Secured()  and  in many parts of our application with synthetic user roles.</p>
  
  <p>The problem is I need to check a whether the logged in user has this synthetic role or not to perform some action.
  I tried using HttpServletRequest's isUserInRole(), but this method is returning true if the user role is checked with his original role and not true with synthetic/granted role.
  I also tried using RoleHierarchy.getReachableGrantedAuthorities() but my manager wants me to do it in higher level.
  The getAuthorities in SecurityContextHolder is also returning only the user's original role and not his granted roles.</p>
  
  <p>security-context file contains</p>
  
  <pre><code>&lt;bean id="roleHierarchy"
      class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl"
      xmlns="http://www.springframework.org/schema/beans"&gt;
      &lt;property name="hierarchy"&gt;
          &lt;value&gt;             
              ROLE_SysAdmin &gt; ROLE_UserPassowrdResetInfoManager
              ROLE_FacilityGroupAdmin &gt; ROLE_UserPassowrdResetInfoManager            
          &lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>The ROLE_SysAdmin is the user's original role and ROLE_UserPassowrdResetInfoManager is the granted role.
  My question is similar to this one <a href="https://stackoverflow.com/questions/6277682/spring-security-user-authorization-in-java-class">Spring Security: User Authorization in Java Class</a> except I need to check for synthetic.granted role for a user.
  Thanks.</p>