You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Magnus Haraldsen Amundsen <Ma...@computas.com> on 2008/05/23 13:40:46 UTC

Cocoon Authentication: Getting the User object after logging in

Using Cocoon 2.2 RC2 and the Cocoon Authentication block.

 

First the sitemap uses 

 

<map:act type="cauth-is-logged-in">

    <map:parameter name="application" value="Sublima"/>

    [...]

</map:act>

<map:redirect-to uri="{request:contextPath}/login"/>

 

To check if the user is logged in.

 

The user logs in and we use a Java class that extends
AbstractSecurityHandler to do the username/password check and that
returns a User object.

We can set additional attributes to this User object using
User.setAttribute(key, value) and we want to do this to control which
role the user has.

 

In the other Java code we use the ApplicationManager to see if the user
is logged in, by calling ApplicationManager.isLoggedIn("Sublima").

 

How do we get the User object that were created upon login? We can't
find any methods in ApplicationManager that returns User.

 

- Magnus


IMPORTANT NOTICE:
This message may contain confidential information. 
If you have received this e-mail in error, do not use, copy or 
distribute it. Do not open any attachments. Delete it immediately from
your system and notify the sender promptly by e-mail that you 
have done so. Thank you.


Re: Cocoon Authentication: Getting the User object after logging in

Posted by Carsten Ziegeler <cz...@apache.org>.
Magnus Haraldsen Amundsen schrieb:
> Using Cocoon 2.2 RC2 and the Cocoon Authentication block.
> 
>  
> 
> First the sitemap uses
> 
>  
> 
> <map:act type="cauth-is-logged-in">
> 
>     <map:parameter name="application" value="Sublima"/>
> 
>     […]
> 
> </map:act>
> 
> <map:redirect-to uri="{request:contextPath}/login"/>
> 
>  
> 
> To check if the user is logged in.
> 
>  
> 
> The user logs in and we use a Java class that extends 
> AbstractSecurityHandler to do the username/password check and that 
> returns a User object.
> 
> We can set additional attributes to this User object using 
> User.setAttribute(key, value) and we want to do this to control which 
> role the user has.
> 
>  
> 
> In the other Java code we use the ApplicationManager to see if the user 
> is logged in, by calling ApplicationManager.isLoggedIn(“Sublima”).
> 
>  
> 
> How do we get the User object that were created upon login? We can’t 
> find any methods in ApplicationManager that returns User.
> 
Have a look at the ApplicationUtil class. If you have access to the 
objectModel map (don't know how to get this in 2.2), you can use the 
static methods. If not, create an instance of the ApplicationUtil class 
and call getUser().

HTH
Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org