cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Hoskens ...@schaubroeck.be>
Subject Re: [Auth-FW] Edit authentication/data nodes
Date Tue, 05 Apr 2005 06:37:47 GMT
Hi,

When I first used cocoon, I had xsp's all around. If I remember correctly, I did something
like this 
to get the value from the authentication session:

<xsp:page
	xmlns:xsp="http://apache.org/xsp"
	xmlns:xsp-session-fw="http://apache.org/xsp/session-fw/1.0">

<xsp:logic>
	String email = <xsp-session-fw:getxml  context="authentication" 
path="/authentication/data/UserEmail"/>;
	String login = <xsp-session-fw:getxml  context="authentication"  path="/authentication/ID"/>;
</xsp:logic>

email: <xsp:expr>email</xsp:expr> user: <xsp:expr>login</xsp-expr>

I never changed the value though and looking at the session-fw.xsl stylesheet, it seems that
there 
isn't a way to set values. You may

Nowadays, I don't use xsp anymore. I now use flowscript to access the authenticationsession
and pass 
it in my bizdata:

var bizdata = new Object();
var contextMan = null;
try
{

contextMan =cocoon.getComponent(Packages.org.apache.cocoon.webapps.session.ContextManager.ROLE);
var sessionContext = contextMan.getContext("authentication");
var id = documentFragment2String(sessionContext.getXML("/authentication/ID"));
var userEmail = documentFragment2String(sessionContext.getXML("/authentication/data/UserEmail"));
bizdata["id"] = id;
bizdata["email"] = userEmail;
cocoon.sendPage("mypage", bizdata);
}
finally
{
	cocoon.releaseComponent(contextMan);
}			

Pay attention to some restrictions on the authenticationsession, there are some functions
that are 
not available although the session interface does define them. Look at the api's to see what
you can 
do with the authenticationsession: 
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/webapps/authentication/context/AuthenticationContext.html

If you need to alter a lot of data in the session, you may want to consider adding a session
context 
for this specific task alone (so not touching the authentication session):

contextManager =cocoon.getComponent(Packages.org.apache.cocoon.webapps.session.ContextManager.ROLE);
if (!contextManager.existsContext("Information"))
{
	contextManager.createContext("Information", null, null);
}
var sessionContext = contextManager.getContext("Information");
// showing how to set a result of a pipeline as xml in a sessioncontext
var pipelineUtil = cocoon.createObject(Packages.org.apache.cocoon.components.flow.util.PipelineUtil);
var document = pipelineUtil.processToDOM("mySessionSettingsToChange", null);
var documentFragment = document.createDocumentFragment();
documentFragment.appendChild(document.getDocumentElement().cloneNode(true));
sessionContext.setXML("Bestuur", documentFragment);

...
sessionContext.removeXML("...");
sessionContext.setAttribute("...", null);
...

If you don't want to use flowscript, the same can be done with the session tags:

<session:createcontext name="Information"/>
<session:setxml context="Information" path="/mypath/">
<cinclude:include>
     <xsp:attribute name="src"><xsp:expr>myDynamicFormedPipelinePath</xsp:expr></xsp:attribute>
</cinclude:include>
</session:setxml>
				

There are probably some more ways to do the same so you may want to look around a bit longer.

Kind regards,
Jan

Philippe Guillard wrote:
> Hi,
> 
> I use Portal, so i use Auth-Fw, and want to change the data part for a 
> user without asking him to sign-in again.
> 
> Lest's say i put nickname in the data section,
> <authentication>
>    <ID>foo_id</ID>
>    <data>foo_nickname</data>
> </authentication>
> and i want to afford the possibility for the user to change it's Nickname.
> 
> Is there a simple way?  Today i can get the nickname from Sitemap 
> (InputModule), Flow, Java, XspSessionFw logicsheet, but i don't know a 
> simple way to use the set functions.
> AuthenticationFw/ SessionContext seems to be there to make session 
> attributes manipulation easier, so i think i lack some understanding on it.
> 
> For the moment i just use the "normal" Session object doing this after 
> the <autentication> node made in XSP:
> <authentication>
>    <ID>foo_id</ID>
>    <data></data>
> </authentication>
> <xsp:logic>
>    session.setAttribute("nickname", "foo_nickname"); </xsp:logic>
> (i'm sad to mix these 2 things and i do not use the framework provided...)
> 
> 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


Mime
View raw message