cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Hutchinson <simon.hutchin...@misgl.com>
Subject Re: Authentication context and modular database action.
Date Fri, 12 Dec 2003 11:35:04 GMT
hed wrote:
>>I am using a ModularDatabaseAction to insert a row into a database.
>>Everything is working fine as most of the field values are available
>>as request parameters.However I also need to store a value that is
>>stored in the authentication context.
>>I am sure that writing my own InputModule for this is overkill as the
>>information is available already.
>>
> 
> 
> I've had the same problem a couple days ago.
> I think that I've found a bug in this module - it doesn't use a parameter
> name correctly.
> So I've write my own - and now everything's ok.
> simply, I've redefined getAttribute method:
> 
> public Object getAttribute(String name,
> Configuration modeConf,
> Map objectModel)
> throws ConfigurationException {
> if ( name == null ) {
> return null;
> }
> if ( modeConf != null ) {
> name = modeConf.getAttribute( "parameter", name );
> // preferred
> name = modeConf.getChild("parameter").getValue(name);
> }
> return super.getAttribute(name,modeConf,objectModel);
> }
> 
> 
>>1). Is it possible to access the authentication context using the
>>session-context InputModule in the database descriptor ?
>>
>>ie
>>
>><value name="fieldname"  type="int">
>><mode name="session-context">
>><parameter>authentication/authentication/ID</parameter>
>>          </mode>
>></value>
>>
>>
>>note: I tried this and it didn't work.The IDs value is available in the
>>sitemap using the same input module
> 
> 
> it is correct, theoretically (but doesn't work cause of the bug)
> 
> regards
> hed
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 

Hi hed,

Thanks for your time and assistance.
I actually resolved the issue by another means, which I am posting in 
case it is useful to anyone else.

I failed to mention that I am using ModularDatabaseAction to save values
from a woody form controlled via flow.
My approach is based on sample.js in the authentication block


########################################################################

//First I get the AuthenticationManager

var authMgr = 
cocoon.getComponent(Packages.org.apache.cocoon.webapps.authentication.AuthenticationManager.ROLE);

//Next I get the name of the handler which I passed as a parameter in 
//the sitemap ie <map:parameter name="handler" value="myHandler"/>

var handler = cocoon.parameters["handler"];

//The user in my case has to be authenticated so I get the UserHandler 
//by calling the isAuthenticated() method on the AuthenticationManager

var userHandler =  authMgr.isAuthenticated(handler);

//From the user handler I can then access authentication data as
//follows.

if(userHandler!=null) {
    var ID =userHandler.getContext().getContextInfo().get("ID");
    cocoon.request.setAttribute("ID",ID);
    cocoon.sendPage("success-pipeline");
}



########################################################################

I can then use the request-attr InputModule in my database descriptor.

I know that it's a hack but thought that the information might be useful
anyway.


Thanks again for your help

Si









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


Mime
View raw message