Acesso a páginas - Web.xml

Bom dia Pessoal,

O arquivo abaixo é o meu web.xml.

Quero autorizar um acesso a uma pagina por ele, se for possivel. As linhas que estão comentadas, quando descomentadas, obrigam o usuario a estar logado para acessar as paginas xhtml. Quero permitir que o usuario acesse uma pagina que se chama products.xhtml sem estar logado. Como faço isso?


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <context-param>
        <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
        <param-value>com.sun.facelets.FaceletViewHandler</param-value>
    </context-param>

    <context-param>
        <param-name>org.richfaces.SKIN</param-name>
        <param-value>blueSky</param-value>
    </context-param>
   
    <context-param>
        <param-name>facelets.LIBRARIES</param-name>
        <param-value>/WEB-INF/htmLib.taglib.xml</param-value>
    </context-param>

<!--    <filter>
        <display-name>Authentication Filter</display-name>
        <filter-name>authentication</filter-name>
        <filter-class>br.com.sigalivre.seguranca.filter.AutenticacaoFiltro</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>authentication</filter-name>
        <url-pattern>*.xhtml</url-pattern>
    </filter-mapping>

    <filter>
        <display-name>Authorization Filter</display-name>
        <filter-name>authorization</filter-name>
        <filter-class>br.com.sigalivre.seguranca.filter.AutorizacaoFiltro</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>authorization</filter-name>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
        <url-pattern>*.xhtml</url-pattern>
    </filter-mapping>-->


    <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>richfaces</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>


    <error-page>
        <exception-type>java.lang.SecurityException</exception-type>
        <location>/faces/login2.xhtml</location>
    </error-page>

  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.jsp</param-value>
  </context-param>

  <!-- Facelets pages will use the .xhtml extension -->
  <context-param>
    <param-name>facelets.VIEW_MAPPINGS</param-name>
    <param-value>*.xhtml</param-value>
  </context-param>

   <context-param>
        <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
        <param-value>40</param-value>
        <description>Only applicable if state saving method is "server" (= default).
                     Defines the amount (default = 20) of the latest views are stored in session.
        </description>
   </context-param>

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>

</web-app>

Não para fazer isso no web.xml pq vc usou um filtro que barra toda as requisições para qualquer coisa:

Para resolver essa questão vc tem liberar acesso para o(s) arquivos(s) específicos dentro do implementação da classe filter.
Implemente um if dentro da classe filter…se caso a requisição for para a “paginaTal.xhtml”, vc liberar o acesso dando seqüencia na execução do chain.

Obrigado Fernando,

Fiz do jeito que voce falou e funcionou com perfeicao.