9 Replies Latest reply on Jul 6, 2009 10:23 PM by Chris Au

    CAS Filter with Richfaces

    Chris Au Newbie

      Hi All,

      I used CAS as authentication in my project with Richfaces. I tried to handle the session time out in client side in order to provide a friendly workflow when session timeout. But I found that when I use CAS filter, the JS function A4J.AJAX.onExpired failed to be called. Does any one have any clue on it?

      Everything works fine when I simply remove the CAS filter. I tried to put the CAS filter before or after the richfaces filter, same result.

      Thanks all.

        • 1. Re: CAS Filter with Richfaces
          Nick Belaevski Master

          Hi,

          What CAS filter are you using: looks like there are two available: org.jasic.cas.* and edu.yale.its.tp.cas.*?

          • 2. Re: CAS Filter with Richfaces
            Chris Au Newbie

            Hi nbelaevski,

            I am using the edu.yale.its.tp.cas.* one.

            Any clue?

            Thanks a lot.

            • 3. Re: CAS Filter with Richfaces
              Nick Belaevski Master

              Please post your web.xml also.

              • 4. Re: CAS Filter with Richfaces
                Chris Au Newbie

                Here is my web.xml


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

                <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/applicationContext.xml</param-value>
                </context-param>

                <!-- richfaces configure -->
                <context-param>
                <param-name>org.richfaces.SKIN</param-name>
                <param-value>blueSky</param-value>
                </context-param>
                <context-param>
                <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                <param-value>.xhtml</param-value>
                </context-param>
                <context-param>
                <param-name>org.ajax4jsf.handleViewExpiredOnClient</param-name>
                <param-value>true</param-value>
                </context-param>

                <servlet-name>Faces Servlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                <load-on-startup>1</load-on-startup>

                <servlet-mapping>
                <servlet-name>Faces Servlet</servlet-name>
                <url-pattern>*.jsf</url-pattern>
                </servlet-mapping>

                <filter-name>CAS Filter</filter-name>
                <filter-class>edu.yale.its.tp.cas.client.filter.CASFilter</filter-class>
                <init-param>
                <param-name>edu.yale.its.tp.cas.client.filter.loginUrl</param-name>
                <param-value>
                https://www.oichris.com/esupcas/login
                </param-value>
                </init-param>
                <init-param>
                <param-name>edu.yale.its.tp.cas.client.filter.validateUrl</param-name>
                <param-value>
                https://www.oichris.com/esupcas/serviceValidate
                </param-value>
                </init-param>
                <init-param>
                <param-name>edu.yale.its.tp.cas.client.filter.serverName</param-name>
                <param-value>localhost:8080</param-value>
                </init-param>

                <filter-mapping>
                <filter-name>CAS Filter</filter-name>
                <url-pattern>/*</url-pattern>
                </filter-mapping>

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

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

                <session-config>
                <session-timeout>1</session-timeout>
                </session-config>

                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>


                </web-app>

                • 5. Re: CAS Filter with Richfaces
                  Ilya Shaikovsky Master

                  from the beginning RichFaces filter and its mapping should be declared first in web.xml. Please give it a try.

                  • 6. Re: CAS Filter with Richfaces
                    Ilya Shaikovsky Master

                    sorry.. small addition.. map both filters to servlet by name and declare the RichFaces filter first.

                    • 7. Re: CAS Filter with Richfaces
                      Chris Au Newbie

                      Thanks ilya,

                      I changed my web.xml to the following but still does not work. The page refreshes itself and the session become alive. It simply skip those A4J.AJAX.onExpired function.
                      But if I remove the CAS filter, everything goes fine.

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

                      <context-param>
                      <param-name>contextConfigLocation</param-name>
                      <param-value>/WEB-INF/applicationContext.xml</param-value>
                      </context-param>

                      <!-- richfaces configure -->
                      <context-param>
                      <param-name>org.richfaces.SKIN</param-name>
                      <param-value>blueSky</param-value>
                      </context-param>
                      <context-param>
                      <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                      <param-value>.xhtml</param-value>
                      </context-param>
                      <context-param>
                      <param-name>org.ajax4jsf.handleViewExpiredOnClient</param-name>
                      <param-value>true</param-value>
                      </context-param>

                      <servlet-name>Faces Servlet</servlet-name>
                      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                      <load-on-startup>1</load-on-startup>

                      <servlet-mapping>
                      <servlet-name>Faces Servlet</servlet-name>
                      <url-pattern>*.jsf</url-pattern>
                      </servlet-mapping>

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

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

                      <filter-name>CAS Filter</filter-name>
                      <filter-class>edu.yale.its.tp.cas.client.filter.CASFilter</filter-class>
                      <init-param>
                      <param-name>edu.yale.its.tp.cas.client.filter.loginUrl</param-name>
                      <param-value>
                      https://www.ottoint.com/esupcas/login
                      </param-value>
                      </init-param>
                      <init-param>
                      <param-name>edu.yale.its.tp.cas.client.filter.validateUrl</param-name>
                      <param-value>
                      https://www.ottoint.com/esupcas/serviceValidate
                      </param-value>
                      </init-param>
                      <init-param>
                      <param-name>edu.yale.its.tp.cas.client.filter.serverName</param-name>
                      <param-value>localhost:8080</param-value>
                      </init-param>

                      <filter-mapping>
                      <filter-name>CAS Filter</filter-name>
                      <servlet-name>Faces Servlet</servlet-name>

                      </filter-mapping>

                      <filter-name>paraFilter</filter-name>
                      <filter-class>com.ottoint.cas.client.filter.CASParaFilter</filter-class>

                      <filter-mapping>
                      <filter-name>paraFilter</filter-name>
                      <servlet-name>Faces Servlet</servlet-name>
                      </filter-mapping>


                      <session-config>
                      <session-timeout>1</session-timeout>
                      </session-config>

                      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>


                      </web-app>


                      Thanks a lot for your kind help.

                      • 8. Re: CAS Filter with Richfaces
                        Ilya Shaikovsky Master

                        and thanks for your updates. we will check it additionally.

                        • 9. Re: CAS Filter with Richfaces
                          Chris Au Newbie

                          Hello ilya,

                          May I know if there is any update for this issue? Thanks.