Hi, Benjamin

Benjamin Boksa-2 wrote:
> 
> I use the following code to access the currently authenticated User in  
> flowscript:
> 
>     var appUtil =  
> cocoon.createObject('org.apache.cocoon.auth.ApplicationUtil');
>     var user = appUtil.getUser();
> 
> The last call returns an instance of my User object which implements  
> the org.apache.cocoon.auth.User interface. Using that interface you  
> should be able to develop a specific User class for your application.  
> A good starting point are Alessandro's examples [1].
> 

Thank you very much for this information. That worked out of the box.
I only needed to tweek my setup a bit for my purposes:

I added this to my test-application context : (don't worry, 
the final application will use another authentication class ;-)

===== application-context.xml ===================================

  <bean name="org.apache.cocoon.auth.SecurityHandler/simple"
                       
class="org.apache.cocoon.auth.impl.SimpleSecurityHandler"
                        scope="singleton">
        <property name="userProperties">
                <value>
                        manager=mana
                        manager.roles=admin_admin
                        manager.name=King Salomon
                </value>
        </property>
  </bean>

  <bean name="org.apache.cocoon.auth.Application/cocoon-app"
                       
class="org.apache.cocoon.auth.impl.StandardApplication"
                        scope="singleton">

  <property name="securityHandler"
ref="org.apache.cocoon.auth.SecurityHandler/simple"/>

==== end application-context.xml
=============================================

I needed the user's true name, so i simply added another property
"manager.name=<full name>"
to the security-handler bean above. And i was able to retrieve the full name
from within the flowscript
below:

function bookingPage() 
{
    var appUtil =
cocoon.createObject('org.apache.cocoon.auth.ApplicationUtil');
    var user    = appUtil.getUser();
    var userName= user.getAttribute("name");
    cocoon.sendPage("booking.jx", { userId: user.id, userName: userName } );
}

It works like a charm! Thanks again!

regards,
hussayn

-- 
View this message in context: 
http://www.nabble.com/Authentication-block%3A-how-to-access-user-credentials-from-flowscript---tp19469122p19491431.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to