Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-695

WebRequestServicerFilter lacks support for tapestry.globals.*

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.1.2
    • Framework, Web
    • None

    Description

      problem description:

      step 1: let there be an "Authenticator" service which uses the current request (for credentials lookup)

      // ----------------------------------------------------------
      <service-point id="Authenticator">
      <invoke-factory model="threaded">
      <construct class="AuthenticatorImpl">
      <set-service property="request" service-id="tapestry.globals.WebRequest" />
      </construct>
      </invoke-factory>
      </service-point>

      // ----------------------------------------------------------
      public class AuthenticatorImpl implements Authenticator
      {
      private WebRequest request; // injected

      // setters + other stuff omitted

      public boolean isAuthenticated()

      { if(request.getSession(false) == null) return false; // more stuff comes here... }

      }
      // ----------------------------------------------------------

      step 2: now inject the authenticator into a request filter

      // ----------------------------------------------------------

      <service-point id="AuthenticationFilter" interface="org.apache.tapestry.services.WebRequestServicerFilter">
      <invoke-factory>
      <construct class="AuthenticationFilter">
      <set-service property="authenticator" service-id="Authenticator" />
      </construct>
      </invoke-factory>
      </service-point>

      <contribution configuration-id="tapestry.request.WebRequestServicerPipeline">
      <filter name="auth" object="service:AuthenticationFilter" />
      </contribution>

      // ----------------------------------------------------------

      public class AuthenticationFilter implements WebRequestServicerFilter
      {
      private Authenticator authenticator; // injected

      // setters + other stuff omitted

      public void service(WebRequest request, WebResponse response, WebRequestServicer servicer) throws IOException
      {
      if(authenticator.isAuthenticated())

      { // ***************************************************** // the above operation "isAuthenticated()" will fail !!! // request == NULL // ***************************************************** }

      }

      }

      // ----------------------------------------------------------

      Property 'webRequest' of <OuterProxy for tapestry.globals.RequestGlobals(org.apache.tapestry.services.RequestGlobals)> is null.

      this should not happen as the request is available at this time (it's a parameter of the service method)
      however, I do not want to handle the request to the authenticator as it's used not only in the filter
      but also in the login page.

      I think this is a general problem with filters being called before tapestry.globals is fully initialized

      Attachments

        Activity

          People

            jkuhnert Jesse Kuhnert
            pete Peter Ertl
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: