cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Klein <>
Subject Re: Authentication framework problem
Date Wed, 21 Jan 2004 11:38:24 GMT
Hi Nesto,

not a complete answer, but some pointers that might help you:

> 1) writing a simple action that checks the user parameters
> (username/password) provided through a web form, with those stored in
> the database. Here the problem, for me, is to write java code that
> reuse the connection pool set for other pipelines (but at a transform
> level). I have no idea...

You need to get hold of the DataSourceSelector to get hold of a pooled

1.Write an action that extends ServiceableAction. 
2.Overwrite the service method:
public void service(ServiceManager manager) 
throws ServiceException {
	this.dbselector = (ServiceSelector)
manager.lookup(DataSourceComponent.ROLE + "Selector");
[I am assuming dbSelector is a private field of the action of class

3. Overwrite the dispose method to release the component:
public void dispose() {

Now you can use the dbselector anywhere in your action code to obtain a
datasource which in turn can give you a connection:
DataSourceComponent datasource =
Connection conn = datasource.getConnection();

conn is of class java.sql.Connection, so from here you should be able to
get on yourself using JDBC.

NOTE: I am still not very experienced with avalon and components, so the
code might not be ideal, but it works for me. If someone has corrections,
I'd be happy to hear them.
For a good example of obtaining a pooled connection and using it, look at
the SQLTransformer.

> 2) customize the authentication resource, to use the existing
> authentication framework. But Where can I add the custom code that
> queries my database? Do I Have to change only the AuthAction class?

I don't know the authentication-framework particularly well, but the
authentication handler takes a uri that has to return some xml to grant
authorization or not, doesn't it? You could just write an esql-xsp-page
to query your database and return the xml accordingly. That would
probably be a lot easier than the action-approach, if you're already
using the framework.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message