You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Philippe Guillard <pg...@citycita.net> on 2005/03/25 06:00:37 UTC

[AuthFW] authentication/ID from Java code

Hi all,

I found this wiki:  http://wiki.apache.org/cocoon/AuthFWWithFlow, tried 
this in an action to get thie ID of the user in the Portal, added the 
import statements that seem to be needed :

......
import org.apache.cocoon.webapps.session.SessionManager;
import org.apache.cocoon.components.*;

public class auth extends ServiceableAction implements ThreadSafe {
   
    public Map act(Redirector redirector, SourceResolver resolver,
            Map objectModel, String src, Parameters par) throws Exception {

            org.apache.avalon.framework.component.ComponentManager 
componentManager = CocoonComponentManager.getSitemapComponentManager();
            SessionManager sessionManager = 
(SessionManager)componentManager.lookup(org.apache.cocoon.webapps.session.SessionManager.ROLE);
            String user = sessionManager.getContextFragment( 
"authentication", "/authentication/ID").getFirstChild().getNodeValue();
            
Eclipse says : "CocoonComponentManager cannot be resolved".  I can't 
find why. My knowledge in Java is still poor...(cocoon 2.1.6rls)

Somebody can help ?

Another related question : I use Portal so it uses Authentication 
Framwork anyway, but until now i was adding some attributes with Java 
Session object, just because it is easier for mee to get that parameters 
in java actions. Is there something wrong with this practice ?
It looks like this in authentication part:
        <ID>userName</ID>
            <role>guest</role>
        <data><!-- i don't use it</data>
        <xsp-session:set-attribute 
name="foo"><xsp:expr>foo</xsp:expr></xsp-session:set-attribute>


Regards,

Phil

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


AW: [AuthFW] authentication/ID from Java code

Posted by Claus Straube <cl...@xdoo.de>.

Hello Phil,

pherhaps I don't understand the second question right, but you can add any
element under the data element. For example <data><foo>bar</foo></data>...
If you use an action you can give the content 'foo' to your action with the
parameter element:

	<map:act type="youraction">
		<map:parameter name="foosomething" value="{foo}/>
	</map:act>  

I hope that'll help. Best regards - Claus 

__________________________________________

Claus Straube
Francéstrasse 31
80997 München
+49 (089) 14 16 682
=> -----Ursprüngliche Nachricht-----
=> Von: Philippe Guillard [mailto:pguillard@citycita.net]
=> Gesendet: Freitag, 25. März 2005 06:01
=> An: users@cocoon.apache.org
=> Betreff: [AuthFW] authentication/ID from Java code
=> 
=> Hi all,
=> 
=> I found this wiki:  http://wiki.apache.org/cocoon/AuthFWWithFlow, tried
=> this in an action to get thie ID of the user in the Portal, added the
=> import statements that seem to be needed :
=> 
=> ......
=> import org.apache.cocoon.webapps.session.SessionManager;
=> import org.apache.cocoon.components.*;
=> 
=> public class auth extends ServiceableAction implements ThreadSafe {
=> 
=>     public Map act(Redirector redirector, SourceResolver resolver,
=>             Map objectModel, String src, Parameters par) throws Exception
=> {
=> 
=>             org.apache.avalon.framework.component.ComponentManager
=> componentManager = CocoonComponentManager.getSitemapComponentManager();
=>             SessionManager sessionManager =
=> (SessionManager)componentManager.lookup(org.apache.cocoon.webapps.session
=> .SessionManager.ROLE);
=>             String user = sessionManager.getContextFragment(
=> "authentication", "/authentication/ID").getFirstChild().getNodeValue();
=> 
=> Eclipse says : "CocoonComponentManager cannot be resolved".  I can't
=> find why. My knowledge in Java is still poor...(cocoon 2.1.6rls)
=> 
=> Somebody can help ?
=> 
=> Another related question : I use Portal so it uses Authentication
=> Framwork anyway, but until now i was adding some attributes with Java
=> Session object, just because it is easier for mee to get that parameters
=> in java actions. Is there something wrong with this practice ?
=> It looks like this in authentication part:
=>         <ID>userName</ID>
=>             <role>guest</role>
=>         <data><!-- i don't use it</data>
=>         <xsp-session:set-attribute
=> name="foo"><xsp:expr>foo</xsp:expr></xsp-session:set-attribute>
=> 
=> 
=> Regards,
=> 
=> Phil
=> 
=> ---------------------------------------------------------------------
=> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
=> For additional commands, e-mail: users-help@cocoon.apache.org



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