La autorización / autenticación de taglib Spring Security 3.1.4 no funciona con la jerarquía de roles en JSF 2.2 en Tomcat 7

Se tienen en cuenta los rolesHeirarchies para las expresiones de seguridad web definidas como URL de intercepción a través del espacio de nombres http, pero no en expresiones que utilizan el taglib Autorizar JSP.

Ya leí un montón de cosas ...ref1 ref2 ref3 ref4 ref5 ref6

****EDITAR:****Ref1 y Ref6 mencionan cosas sobre un problema con el orden de los filtros y el contexto de seguridad no disponible en jsp ... (por cierto, estoy usando jsf2) tal vez haya algo para investigar ...

EDIT 2: ¿JSF está manejando la etiqueta de seguridad lib? Yo leoesta y pruebaese sin éxito

EDITAR 3: : Traté de instalar a través de Maven spring-faces 2.3.2 y spring-security-taglibs ... no pasa nada ... Algunos tuto dijeron que crearan un taglib.xml personalizado pero no funcionó también, creo que fue para versión antigua...

Probé este facesContext.externalContext.isUserInRole ('ROLE') y sec: authorize access = "hasRole ('Role') ... El primero funciona solo si es el mismo ROLE pero no tiene en cuenta las cosas de la jerarquía ... Y sec: autorize simplemente no hace nada, se imprimen todos los roles.

Vea el ejemplo anterior con un usuario con ROLE ROLE_ADMIN_PROFILER_NGS:

    <h:outputText rendered="#{facesContext.externalContext.isUserInRole('ROLE_ADMIN_PROFILER_NGS')}"  value ="ROLE_ADMIN_PROFILER_NGS"></h:outputText> // WORKS <br></br>
<h:outputText rendered="#{facesContext.externalContext.isUserInRole('ROLE_GUEST')}"  value ="ROLE_GUEST"></h:outputText> // SHOULD APPEAR BUT NOTHING HAPPENS<br></br>
<h:outputText rendered="#{facesContext.externalContext.isUserInRole('ROLE_ADMIN')}"  value ="ROLE_ADMIN"> // SHOULD NOT APPEAR AND THAT'S THE CASE</h:outputText><br></br>

/* ALL THE THREE NEXT ARE DISPLAYED WHITHOUT CONTROL AUTORIZATION.*/

<sec:authorize access="hasRole('ROLE_ADMIN_PROFILER_NGS')">ROLE_ADMIN_PROFILER_NGS<br></br></sec:authorize>
<sec:authorize access="hasRole('ROLE_GUEST')">ROLE_GUEST <br></br></sec:authorize>
<sec:authorize access="hasRole('ROLE_ADMIN')">ROLE_ADMIN  <br></br></sec:authorize>

Esto es lo que intenté acceder para probar con las funciones de jerarquías de roles:

Cuando un usuario viene solo con un rol GUEST ... Se muestran todas las etiquetas ... no deberían aparecer, solo debe aparecer GUEST (ver definición en la parte inferior):

    <sec:authentication property="username" />
    <sec:authorize access="hasRole('ROLE_BABAB')">BABA</sec:authorize>
    <sec:authorize access="hasRole('ROLE_GUEST')">GUEST</sec:authorize>
    <sec:authorize access="hasRole('ROLE_ADMIN')">ADMIN</sec:authorize>

Esta es mi configuración de seguridad:

   <security:http auto-config="true" access-decision-manager-ref="accessDecisionManager" use-expressions="true" disable-url-rewriting="true">
    <security:intercept-url pattern="/Participant/New/*" access="hasRole('ROLE_ADMIN')" />  
    <security:intercept-url pattern="/Home" access="hasRole('ROLE_GUEST')" />  
    <security:intercept-url pattern="/Login" access="hasRole('ROLE_ANONYMOUS')" />   
     <security:intercept-url pattern="/Login/Error" access="hasRole('ROLE_ANONYMOUS')" />    
    <security:form-login  login-page="/Login"  login-processing-url="/j_spring_security_check"  authentication-failure-url="/Login/Error" default-target-url="/Home" />
    <security:logout logout-url="/j_spring_security_logout" logout-success-url="/Home" delete-cookies="JSESSIONID"  invalidate-session="true"/>
    <security:anonymous/>
     <security:expression-handler ref="defaultWebSecurityExpressionHandler" />
    <security:session-management invalid-session-url="/Login" >
        <security:concurrency-control max-sessions="1" error-if-maximum-exceeded="true"  />
    </security:session-management>
   <security:port-mappings>
     <security:port-mapping http="8086" https="8443"/>
    </security:port-mappings>
  </security:http>

<beans:bean id="defaultWebSecurityExpressionHandler" class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler">
      <beans:property name="roleHierarchy" ref="roleHierarchy"/>
</beans:bean>

<beans:bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
  <beans:property name="decisionVoters">
    <beans:list>
       <beans:ref bean="roleVoter" />
        <beans:bean class="org.springframework.security.web.access.expression.WebExpressionVoter">
            <beans:property name="expressionHandler" ref="defaultWebSecurityExpressionHandler"/>
        </beans:bean>
       <beans:bean class="org.springframework.security.access.vote.AuthenticatedVoter"/>

    </beans:list>
  </beans:property>
</beans:bean>


<beans:bean id="roleVoter" class="org.springframework.security.access.vote.RoleHierarchyVoter">
    <beans:constructor-arg ref="roleHierarchy" />
</beans:bean>

<beans:bean id="roleHierarchy" class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl">
    <beans:property name="hierarchy">
        <beans:value>
            ROLE_ADMIN > ROLE_ADMIN_PROFILER_NGS
            ROLE_ADMIN_PROFILER_NGS > ROLE_GUEST
            ROLE_GUEST > ROLE_GUEST_PROFILER_NGS  
            ROLE_ADMIN > ROLE_ADMIN_PROFILER_CGH
            ROLE_ADMIN_PROFILER_CGH > ROLE_GUEST
            ROLE_GUEST > ROLE_GUEST_PROFILER_CGH
        </beans:value>
    </beans:property>
 </beans:bean>

Muchas gracias, son bienvenidos si tienen otra idea para probar ...

EDITAR 3:

¿Por qué devuelve 0 para RoleHierarchyVoter y 1 para WebExpressionVoter ... es normal?

14: 48: 32,861 DEBUG FilterSecurityInterceptor: 194 - Objeto seguro: FilterInvocation: URL: / Home; Atributos: [hasRole ('ROLE_GUEST')] 14: 48: 32,861 DEBUG FilterSecurityInterceptor: 310 - Anteriormente autenticado: org.springframework.security.authentication.Username.as.as.pros.payas.payas.payas.payas.payas.payas.payas.payas.payas.payas.payas.payas.payas.payas.payas. : Nombre de usuario: jp; Contraseña protegida]; Habilitado: verdadero; AccountNonExpired: true; credenciales no expira: verdadero; AccountNonLocked: true; Autoridades otorgadas: ROLE_ADMIN_PROFILER_NGS; Credenciales: [PROTEGIDO]; Autenticado: verdadero; Detalles: org.springframework.security.web.authentication.WebAuthenticationDetails@0: RemoteIpAddress: 192.168.154.18; Id. De sesión: 084939D4E097F41ACA6A1F24CD8390BE; Autoridades otorgadas: ROLE_ADMIN_PROFILER_NGS 14: 48: 32,861 DEBUG RoleHierarchyImpl: 117 - getReachableGrantedAuthorities () - Desde las funciones de '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '. 14: 48: 32,861 DEBUG AffirmativeBased: 65 - Voter: org.springframework.security.access.vote.RoleHierarchyVoter@6ff43d69, devolvió: 0 14: 48: 32,862 DEBUG RoleHierarchyImpl: 117 - getReachableGrantedAuthoras () A partir de las prácticas de los grupos de los mismos. puede llegar a [ROLE_GUEST_PROFILER_NGS, ROLE_GUEST_PROFILER_CGH, ROLE_ADMIN_PROFILER_NGS, ROLE_GUEST] en cero o más pasos. 14: 48: 32,862 DEBUG AffirmativeBased: 65 - Votante: org.springframework.security.web.access.expression.WebExpressionVoter@3fe932d5, devolvió: 1 14: 48: 32,862 DEBUG FilterSecurityInterceptor: 215 - Autorización exitosa

EDITAR 5:

     <beans:bean id="login" class="com.clb.genomic.lyon.beans.LoginBean" scope ="session">
          <beans:property name="authenticationManager" ref="authenticationManager" /> 
     </beans:bean>

>     <security:authentication-manager alias="authenticationManager">
>         <security:authentication-provider user-service-ref="userBo" >
>             <security:password-encoder ref="standardPasswordEncoder"/>   
>         </security:authentication-provider>
>     </security:authentication-manager>

Respuestas a la pregunta(1)

Su respuesta a la pregunta