cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@media.demon.co.uk>
Subject Re: Access session user data from flow
Date Mon, 08 Dec 2003 10:58:50 GMT

On 6 Dec 2003, at 20:26, Jean-Christophe Kermagoret wrote:

> Hi List,
> it it possible to access from flow user data stored in the session  
> after an authentication ?
>
> I authenticate with success and I put the following data in the  
> session :
>
> /authentication
>  /ID
>  /data
>        /firstname
>        /surname
> ...
>
> How to access it with Flowscript ?

There are two possibilities that I know of ...... there are probably  
more ....

1. Via input modules :

<map:parameter name="userid"  
value="{session-context:authentication/authentication/ID}"/>

which might be used to get the Sitemap to pass a parameter from the  
Session Context to your FlowScript.

2. Via the AuthenticationManager at login time :

The auth flowscripts call the 'login' method of  
'AuthenticationManager'. 'login' returns a 'UserHandler', the  
'UserHandler' can give you access to your data:

var authMgr = cocoon.getComponent 	
	 
(Packages.org.apache.cocoon.webapps.authentication.AuthenticationManager 
.ROLE);
var userhandler =  authMgr.login (handler, null, authParams);
if (userhandler != null) {
	cocoon.log.info ("firstname: " + userhandler.getContext  
().getContextInfo ().get ("firstname"));
	cocoon.log.info ("surname: " + userhandler.getContext  
().getContextInfo ().get ("surname"));
}


Keep in mind that the authentication context is only available while  
you are in a protected URL.

HTH

regards Jeremy
Mime
View raw message