1 Reply Latest reply on Jul 16, 2009 5:14 PM by phillip

    RestEasy and URL Rewrite

    phillip

      I'm in the process of adding some web services to an existing seam application using the new resteasy support. I would like to make the base URL for webservices /api/ without changing our existing seam resources path.


      I've tried adding a url rewrite rule using the tukey URL rewrite filter and the following rule. But this results in a java.lang.IllegalArgumentException: no file extension in servlet path: /api/... exception.


      <rule>
        <from casesensitive="true">^/api/(.*)$</from>
        <to last="true" type="forward">/seam/resource/api/$1</to>
      </rule>



      Any suggestions?

        • 1. Re: RestEasy and URL Rewrite
          phillip

          I've made some progress by writing my own nasty rewrite filter, this now rewrites the url and is executing RestEasy resource but the authentication filter is not firing correctly


          <web:authentication-filter url-pattern="/seam/resource/api/*" auth-type="basic" />



          Here is the filter


          @Startup
          @Scope(ScopeType.APPLICATION)
          @Name("apiRewriteFilter")
          @BypassInterceptors
          @Filter
          @Install(value = true, precedence = Install.APPLICATION)
          public class APIRewriteFilter extends  AbstractFilter {
          
          public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
            String fullPath = ((HttpServletRequest)request).getRequestURI();
                  
            if (fullPath.startsWith("/api/")) {
                RequestDispatcher dispatcher = request.getRequestDispatcher("/seam/resource" + fullPath);
                dispatcher.forward(request, response);
             } else {
                chain.doFilter(request, response);
             }
          }
          }



          And the exception i'm getting being triggered from a


          @Restrict("#{s:hasRole('api')"})



          attached to the class.


          15:03:54,991 ERROR [[Seam Resource Servlet]] Servlet.service() for servlet Seam Resource Servlet threw exception
          org.jboss.seam.security.NotLoggedInException
               at org.jboss.seam.security.Identity.checkRestriction(Identity.java:217)