Announcement Announcement Module
Collapse
No announcement yet.
authz tags not working Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • authz tags not working

    I've put this piece in one of my JSP pages:
    Code:
        	<authz&#58;authorize ifNotGranted="ROLE_ANONYMOUS">
        		<authz&#58;authentication operation="principal"/> - 
        		<a href="$&#123;ctx&#125;/logoff.do">Logout</a>
        	</authz&#58;authorize>
    Both tags are not working, the result is always something like:
    Code:
     - Logout
    no matter if the user is authenticated or not.

    I put a breakpoint in doStartTag() in net.sf.acegisecurity.taglibs.authz.AuthenticationT ag to do some debugging with eclipse, and when the execution pauses, I get this on the log:
    Code:
    &#91;DEBUG,HttpSessionContextIntegrationFilter,http-8080-Processor22&#93; Context stored to HttpSession&#58; 'net.sf.acegisecurity.context.security.SecureContextImpl@204d14&#58; Authentication&#58; net.sf.acegisecurity.providers.anonymous.AnonymousAuthenticationToken@a48d59&#58; Username&#58; anonymousUser; Password&#58; &#91;PROTECTED&#93;; Authenticated&#58; true; Details&#58; null; Granted Authorities&#58; ROLE_ANONYMOUS'
    &#91;DEBUG,HttpSessionContextIntegrationFilter,http-8080-Processor22&#93; ContextHolder set to null as request processing completed
    After that, going step by step throug the code, the method returns because ContextHolder.getContext() == null .

    A debug in AuthorizeTag reveals that also fails because ContextHolder.getContext() returns null.

    Seems like the ContextHolder is set to null before its time.

    I would appreciate any help on this.

    Thanks.[/code]

  • #2
    I found the problem.
    I was placing the tags in a Sitemesh decorator, but the Sitemesh filter was before the Acegi filters, so when the tags were evaluated, the Acegi filters were already finished, and the ContextHolder was back in null.

    Sorry for any inconvenience.

    Comment


    • #3
      Hi, thank you for the response, after two hours of banging my head on the wall I found you post by Google and it saved me another several hours.
      I had the same problem.

      Comment


      • #4
        Yep, this fixed it for me too. The SiteMesh filter must be placed after the Acegi ones for me to be able to login.
        But I have another issue with this: when navigating to a SiteMesh decoreated page, the <authz>-tag seems to stop working. I have downloaded Equinox in order to grasp what mr Raible have done to make SiteMesh and Acegi work, but so far I haven't got any clues. Anybody experienced and solved this?
        Last edited by kantorn; Apr 28th, 2007, 01:16 AM.

        Comment


        • #5
          Filter mapping has to be declared in the same order

          OK. Acegi filters must be declared before the SiteMesh filter, and so does the corresponding filter-mappings! Otherwise the <authz>-tags doesn't work.
          Cheers!

          Comment

          Working...
          X