Guice plus CAS filters munging webapp output

66 views
Skip to first unread message

garey

unread,
May 4, 2011, 2:07:58 PM5/4/11
to google-guice
I am developing a webapp that I hope will integrate Guice,
VelocityViewServlet, and JASIG's CAS (Centralized Authentication
Service) client.

I have already determined that the VelocityViewServlet cannot be
controlled by Guice. VelocityViewServlet is a template resolver that
allows the template to access Java objects found in the various webapp
contexts(ServletContext, HttpRequestContext, ...), and Guice does not
pass the contexts correctly to VelocityViewServlet when a request is
forwarded to it. So the VelocityViewServlet is included in web.xml,
and here it is:



<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</
filter-class>
</filter>

<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<listener>
<listener-
class>edu.berkeley.library.mapup.GuiceServletConfig</listener-class>
</listener>


<servlet>
<servlet-name>Velocity Servlet</servlet-name>
<servlet-
class>org.apache.velocity.tools.view.VelocityViewServlet</servlet-
class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Velocity Servlet</servlet-name>
<url-pattern>*.vm</url-pattern>
</servlet-mapping>


Using this setup, everything worked fine. Servlets controlled by Guice
could forward to VelocityViewServlet and VelocityViewServlet could see
and use the objects in the contexts. Then I tried to add CAS.

CAS is instantiated as a series of filters, which are configured by
init-params. Here is my ServletModule




bind(org.jasig.cas.client.authentication.AuthenticationFilter.class).in(Singleton.class);
Map<String, String> auth_params = new HashMap<String, String>();
auth_params.put("casServerLoginUrl", "https://auth-test.berkeley.edu/
cas/login");
auth_params.put("serverName", "linuxdev.lib.berkeley.edu:7654");

filter("/in/
*").through(org.jasig.cas.client.authentication.AuthenticationFilter.class,
auth_params);



bind(org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter.class).in(Singleton.class);
Map<String, String> valid_params = new HashMap<String, String>();
valid_params.put("casServerUrlPrefix", "https://auth-
test.berkeley.edu/cas");
valid_params.put("serverName", "linuxdev.lib.berkeley.edu:7654");

filter("/in/
*").through(org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter.class,
valid_params);


bind(org.jasig.cas.client.util.HttpServletRequestWrapperFilter.class).in(Singleton.class);

filter("/in/
*").through(org.jasig.cas.client.util.HttpServletRequestWrapperFilter.class);


bind(org.jasig.cas.client.util.AssertionThreadLocalFilter.class).in(Singleton.class);
filter("/in/
*").through(org.jasig.cas.client.util.AssertionThreadLocalFilter.class);

serve("/in/gisuserform").with(GisRegisterServlet.class);
serve("/in/
contributorDashboard").with(ContributorDashboardServlet.class);


When I put these filters in, output from the VelocityViewServlet,
which should be a text/html file, consists of a couple of control
characters only.

We have integrated CAS into a number of webapps without Guice. There
is something going on in the interaction between Guice and these
filters and VelocityViewServlet, but I can't see even how to debug it.

Anyone have any ideas?

Garey Mills

garey

unread,
May 5, 2011, 1:43:23 PM5/5/11
to google-guice
It appears that when a request is filtered through the
'org.jasig.cas.client.authentication.AuthenticationFilter.class'
using Guice, the request does not even reach the servlet it is
intended for.
Reply all
Reply to author
Forward
0 new messages