You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Conal Tuohy <co...@paradise.net.nz> on 2002/08/02 03:10:02 UTC

How to pass authentication data to a Source?

I am writing a Source or Sources to provide access to mail stored on pop3,
imap, etc servers. In some cases the Source will need to log in to the mail
server, so I need a way to pass the credentials to my Source.

It seems to me that the Source can implement Configurable, Contextualizable,
or Parameterizable, and then extract the credentials from its Configuration,
Context, or Parameter. Is that right? Any suggestions? Can anyone point me
at some code which implements something similar?


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


RE: How to pass authentication data to a Source?

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Conal Tuohy [mailto:conalt@paradise.net.nz]
> 
> > > session), but in any case, it seems to me that a Source can keep a
> > > cache of open Connections itself if necessary - it doesn't
> > really have
> > > to be stored in the Session.
> >
> > You can do this (connection pooling) in MailSourceFactory, or, if
such
> > connection pool can be reused somewhere else, it could be a separate
> > connection pool component (a-la datasource).
> 
> Cheers Vadim
> 
> It also strikes me that the user's credentials could be stored in a
session
> using an Action (this is what Justin was suggesting, I see now), so
that the
> SessionTransformer could insert these data into "mail:" URLs, and
XInclude
> could resolve these resulting URLs using the MailSource.

Yep.

Vadim



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


RE: How to pass authentication data to a Source?

Posted by Conal Tuohy <co...@paradise.net.nz>.
> > session), but in any case, it seems to me that a Source can keep a
> > cache of open Connections itself if necessary - it doesn't
> really have
> > to be stored in the Session.
>
> You can do this (connection pooling) in MailSourceFactory, or, if such
> connection pool can be reused somewhere else, it could be a separate
> connection pool component (a-la datasource).

Cheers Vadim

It also strikes me that the user's credentials could be stored in a session
using an Action (this is what Justin was suggesting, I see now), so that the
SessionTransformer could insert these data into "mail:" URLs, and XInclude
could resolve these resulting URLs using the MailSource.


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


RE: How to pass authentication data to a Source?

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Conal Tuohy [mailto:conalt@paradise.net.nz]
> 
> Justin wrote:
...
> > Most mail systems won't
> > make a new connection to the server to retrieve each
> > individual message.
> > They usually download them all at once into a local store. Will
> > the source be responsible for this? If you're just concerned with 
> > viewing
> 
> I don't think the Source should do this: storing messages is what a 
> mail server (or any JavaMail "provider") is for after all. I don't 
> want to write a mail server. ;-)
> 
> > messages and don't want to store them, then you might want to
> > keep the
> > connection open so you don't have to reconnect for each
> > message. In this
> > case you'd want to store the JavaMail connection in the
> > session, and I'm
> > not aware the a source has access to the session.
> 
> You're right - keeping a cache of connections is important (though not

> such an issue if the mail server is local) - but I'm still thinking 
> this can be done with a Source. I'm still not entirely clear about 
> the Source's relationship with the rest of Cocoon (including the 
> session), but in any case, it seems to me that a Source can keep a 
> cache of open Connections itself if necessary - it doesn't really have
> to be stored in the Session.

You can do this (connection pooling) in MailSourceFactory, or, if such
connection pool can be reused somewhere else, it could be a separate
connection pool component (a-la datasource).

Vadim

...


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


RE: How to pass authentication data to a Source?

Posted by Conal Tuohy <co...@paradise.net.nz>.
Justin wrote:
>    I think that putting all the functionality of logging into
> a server,
> retreiving messages and folders, and turning that data into XML is a
> little too much for a Source. If you have to pass parameters to the
> generator to specify servers and passwords, etc.. then why
> not just make
> a MailGenerator?

My plan is to put the login, retrieval of mail, etc into the Source, and the
XML conversion in an XMLizer. So these two functions will be split. As far
as passing passwords etc goes, I think Vadim is right that this should all
be passed to the Source in a URL string. I don't see any big problems there.

I don't think that a Generator should be responsible for dealing with mail
servers, because I also want to be able to retrieve rfc822 messages from
file systems or web servers, not just POP, IMAP, etc. That's why I think the
XML conversion should be UNDERNEATH the Generator layer (as an XMLizer or as
an XMLizable Source).

>Most mail
> systems won't
> make a new connection to the server to retrieve each
> individual message.
> They usually download them all at once into a local store. Will the
> source be responsible for this? If you're just concerned with viewing

I don't think the Source should do this: storing messages is what a mail
server (or any JavaMail "provider") is for after all. I don't want to write
a mail server. ;-)

> messages and don't want to store them, then you might want to
> keep the
> connection open so you don't have to reconnect for each
> message. In this
> case you'd want to store the JavaMail connection in the
> session, and I'm
> not aware the a source has access to the session.

You're right - keeping a cache of connections is important (though not such
an issue if the mail server is local) - but I'm still thinking this can be
done with a Source. I'm still not entirely clear about the Source's
relationship with the rest of Cocoon (including the session), but in any
case, it seems to me that a Source can keep a cache of open Connections
itself if necessary - it doesn't really have to be stored in the Session.

>    Who knows, maybe this is a better job for an action or
> flowscript in
> conjunction with a MailSource, but I don't think a source
> should do it
> all.

Can you elaborate on how that would work, Justin?


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


Re: How to pass authentication data to a Source?

Posted by Justin Fagnani-Bell <ju...@paraliansoftware.com>.
Conal,

   To continue our discussion publically and hopefully get some input 
from the cocoon developers...

   I think that putting all the functionality of logging into a server, 
retreiving messages and folders, and turning that data into XML is a 
little too much for a Source. If you have to pass parameters to the 
generator to specify servers and passwords, etc.. then why not just make 
a MailGenerator?

   There just seems to be too much 'logic' to be performed that has 
nothing to do with actually outputting the XML. Most mail systems won't 
make a new connection to the server to retrieve each individual message. 
They usually download them all at once into a local store. Will the 
source be responsible for this? If you're just concerned with viewing 
messages and don't want to store them, then you might want to keep the 
connection open so you don't have to reconnect for each message. In this 
case you'd want to store the JavaMail connection in the session, and I'm 
not aware the a source has access to the session.

   Who knows, maybe this is a better job for an action or flowscript in 
conjunction with a MailSource, but I don't think a source should do it 
all.

just my $.02

Justin

On Friday, August 2, 2002, at 04:34 PM, Conal Tuohy wrote:

>>>> Context is one per application, Configuration and Parameters
>>>> are one per
>>>> Source type (in your case - one configuration per all instances of
>>>> MailSource).
>
>>> Just to get this clear though - if my Source was a Generator instead,
>>> could I pass parameters to it on a per-pipeline basis, just by
>>> implementing Parameterizable?
>>
>> Yes.
>>
>> Vadim
>
> OK. But why CAN'T I do this with a Source? [Thinking aloud] The 
> Generator is
> the container for my Source isn't it? Presumably the Generator should
> Parameterize my Source when it resolves it (or Reparameterize it), so
> couldn't my Source access the parameters passed to the Generator, in the
> example below? Perhaps the parameter names should be "mail:username" and
> "mail:password" so they don't clash with parameters the Generator might 
> be
> expecting.
>
>>> e.g.
>>>
>>> <map:match pattern="mail/*/*/*">
>>> 	<map:generate type="mail" src="{1}">
>>> 		<map:parameter name="username" value="{2}">
>>> 		<map:parameter name="password" value="{3}">
>>> 	</map:generate>
>>> 	etc.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>


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


RE: How to pass authentication data to a Source?

Posted by Conal Tuohy <co...@paradise.net.nz>.
> > > Context is one per application, Configuration and Parameters
> > > are one per
> > > Source type (in your case - one configuration per all instances of
> > > MailSource).

> > Just to get this clear though - if my Source was a
> Generator instead,
> could
> > I pass parameters to it on a per-pipeline basis, just by
> implementing
> > Parameterizable?
>
> Yes.
>
> Vadim

OK. But why CAN'T I do this with a Source? [Thinking aloud] The Generator is
the container for my Source isn't it? Presumably the Generator should
Parameterize my Source when it resolves it (or Reparameterize it), so
couldn't my Source access the parameters passed to the Generator, in the
example below? Perhaps the parameter names should be "mail:username" and
"mail:password" so they don't clash with parameters the Generator might be
expecting.

> > e.g.
> >
> > <map:match pattern="mail/*/*/*">
> > 	<map:generate type="mail" src="{1}">
> > 		<map:parameter name="username" value="{2}">
> > 		<map:parameter name="password" value="{3}">
> > 	</map:generate>
> > 	etc.


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


RE: How to pass authentication data to a Source?

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Conal Tuohy [mailto:conalt@paradise.net.nz]
> 
> > > It seems to me that the Source can implement Configurable,
> > Contextualizable,
> > > or Parameterizable, and then extract the credentials from its
> > Configuration,
> > > Context, or Parameter. Is that right? Any suggestions? Can anyone
> > point me
> > > at some code which implements something similar?
> >
> > Context is one per application, Configuration and Parameters
> > are one per
> > Source type (in your case - one configuration per all instances of
> > MailSource).
> >
> > I would suggest embedding auth parameters into the URL, as
> > this is done
> > with ftp and http protocols:
> >
> > http://username:password@host:port/path/file.ext#anchor
> 
> Thanks Vadim - I'll go with that.
> 
> Just to get this clear though - if my Source was a Generator instead,
could
> I pass parameters to it on a per-pipeline basis, just by implementing
> Parameterizable?

Yes.

Vadim


> e.g.
> 
> <map:match pattern="mail/*/*/*">
> 	<map:generate type="mail" src="{1}">
> 		<map:parameter name="username" value="{2}">
> 		<map:parameter name="password" value="{3}">
> 	</map:generate>
> 	etc.


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


RE: How to pass authentication data to a Source?

Posted by Conal Tuohy <co...@paradise.net.nz>.
> > It seems to me that the Source can implement Configurable,
> Contextualizable,
> > or Parameterizable, and then extract the credentials from its
> Configuration,
> > Context, or Parameter. Is that right? Any suggestions? Can anyone
> point me
> > at some code which implements something similar?
>
> Context is one per application, Configuration and Parameters
> are one per
> Source type (in your case - one configuration per all instances of
> MailSource).
>
> I would suggest embedding auth parameters into the URL, as
> this is done
> with ftp and http protocols:
>
> http://username:password@host:port/path/file.ext#anchor

Thanks Vadim - I'll go with that.

Just to get this clear though - if my Source was a Generator instead, could
I pass parameters to it on a per-pipeline basis, just by implementing
Parameterizable?

e.g.

<map:match pattern="mail/*/*/*">
	<map:generate type="mail" src="{1}">
		<map:parameter name="username" value="{2}">
		<map:parameter name="password" value="{3}">
	</map:generate>
	etc.


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


RE: How to pass authentication data to a Source?

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Conal Tuohy [mailto:conalt@paradise.net.nz]
> 
> I am writing a Source or Sources to provide access to mail stored on
pop3,
> imap, etc servers. In some cases the Source will need to log in to the
mail
> server, so I need a way to pass the credentials to my Source.
> 
> It seems to me that the Source can implement Configurable,
Contextualizable,
> or Parameterizable, and then extract the credentials from its
Configuration,
> Context, or Parameter. Is that right? Any suggestions? Can anyone
point me
> at some code which implements something similar?

Context is one per application, Configuration and Parameters are one per
Source type (in your case - one configuration per all instances of
MailSource).

I would suggest embedding auth parameters into the URL, as this is done
with ftp and http protocols:

http://username:password@host:port/path/file.ext#anchor


Vadim


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