You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stefan Pietschmann <de...@gmail.com> on 2005/10/12 09:18:04 UTC

Re: How to access the AuthenticationContext in a SessionListener?

Hm. isn't there any way I can do something "onAuthSessionDestroyed"? Is
there some kind of Auth Listener perhaps?


Stefan

 

  _____  

Von: Stefan Pietschmann [mailto:dev.sensei@gmail.com] 
Gesendet: Donnerstag, 29. September 2005 11:15
An: 'users@cocoon.apache.org'
Betreff: How to access the AuthenticationContext in a SessionListener?

 

In our project we're storing information about the user in the
AuthenticationContext. So far this information has been written on disk with
every request processed by the server, however this is not very good
performance-wise and leads to some problems due to concurrent access.
Instead it would be great if the information stored in the Context could be
written back to disk when the user logs out OR the session times out. Thus
it is not sufficient to add the method to the logout matcher, but to do this
using a HTTPSessionListener which I added to Cocoon's web.xml. 

 

In the method public void sessionDestroyed(HttpSessionEvent event) I can
retrieve the user's HTTPSession and via this the ServletContext, but how can
I access the AuthenticationContext? Is it accessable at all? I tought one of
these should work, but both are null.

 

        AuthenticationContext authContext =
(AuthenticationContext)session.getServletContext().getContext("authenticatio
n");

        AuthenticationContext authContext2 =
(AuthenticationContext)session.getServletContext().getContext(Authentication
Constants.SESSION_CONTEXT_NAME)

 

Cheers,

Stefan