cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Pietschmann" <sp186...@inf.tu-dresden.de>
Subject Retrieving AuthenticationContext from custom Action
Date Thu, 23 Dec 2004 10:12:04 GMT
Hi guys,

I'm currently writing an action which merges some things from the request
and deli into the AuthenticationContext.

I just don't seem to get the Context, though. 
I'd prefer to get it as DOM (a Document or DocumentFragment), so I don't
really want to use streamContextFragment(..) from the sessionManager like
Cocoon's SessionPreTransformer does.

I have the ContextManager and the SessionManager. 
I tried with the AuthenticationContextProvider (though I'm really not sure
why this is needed at all), but it returned a NullPointerException.

Well, the action (shortened to the important bits) looks like this:

public void service(ServiceManager manager)... {
super.service(manager);
        try {
            getDeli();
            getContextManager();
            getSessionManager();
        }
        catch (ProcessingException pe) {
            throw new ServiceException("Error looking up components.");
        }
} 

public Map act( ...) ..{

if
(contextManager.existsContext(AuthenticationConstants.SESSION_CONTEXT_NAME))
{
	authContext =
(AuthenticationContext)contextManager.getContext(AuthenticationConstants.SES
SION_CONTEXT_NAME);
	System.out.println("1st way:
"+sessionManager.getContextFragment(authContext.getName(),"/authentication")
.toString());
	System.out.println("2nd way:
"+authContext.getXML("/authentication").toString());}
}

So far this is only for debugging purpose to see if I get the context or not
- but it doesn't look so. This is what the console says:
1st way: [#document-fragment: null]
2nd way: [#document-fragment: null]

My first question would be: 
Which is the best way to obtain the authentication context? Via the
SessionManager, ContextManager.. or AuthenticationContextProvider? Is there
any striking difference?

Second question of course: How do I get the context??

The pipeline part looks like this:

<map:act type="auth-protect">
	<map:parameter name="handler" value="portalhandler"/>
	 ...
	<!-- my action: -->
	<map:act type="updateModel">
		<map:parameter name="requestParam" value="xml:Foo"/>
	</map:act>
	...
	<map:transform type="session"/>
		<map:transform
src="{global:trans}outputauthentication.xsl"/>
	<map:transform type="session"/>
	...
</map:act>

Funnily the outputauthentication stylesheet (see below) returns the context,
so it must be possible with my action as well :O

<xsl:template match="/">
	<authContext ...>
		<session:getxml context="authentication"
path="/authentication"/>
	</authContext>
</xsl:template>

Thank you for your help!

Cheers and Merry Christmas,
Stefan 

P.S.: Using Cocoon 2.1.6 on Tomcat 5.0.28 on JDK 1.4.2_06


Mime
View raw message