Hello Nils,
I'm afraid there is currently no support for accessing URLs that require
authentication.
While I think this is a feature all components should have, it will take
some time to add this and you'd have to wait for the next release or
change to the trunk in order to use it.
A faster way would be to create a new XSLTTransformer and add the
authentication to it.
The code for accessing the URL (currently in the
createTransformerHandler() method) should look like this (just top off
my head, no guarantees ;-) )
String userPassword = "Username" + ":" + "Password";
String encoded = new
sun.misc.BASE64Encoder().encode(userPassword.getBytes());
URLConnection connection = this.source.openConnection();
connection.setRequestProperty("Authorization", "Basic " + encoded);
InputStream inputStream = connection.getInputStream();
InputSource inputSource = new InputSource();
inputSource.setByteStream(inputStream);
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(templatesHandler);
xmlReader.parse(inputSource);
inputStream.close();
But as I said above, this is a sound feature request and you can expect
this to be in one of the next releases...
Regards,
Steven
Nils Preusker schrieb:
Hi all,
I just started trying out cocoon 3 alpha 1 and I'm wondering if there
is a solution for the following scenario: I'm retrieving all my XML
and XSLT content via URLs that require authentication. Without the
authentication I could simply create a pipeline like this:
...
Pipeline pipeline = new NonCachingPipeline();
pipeline.addComponent(new StringGenerator("<x></x>"));
pipeline.addComponent(new XSLTTransformer(new
URL("http://example.com/somexslt.xslt")));
pipeline.addComponent(new XMLSerializer());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
pipeline.setup(baos);
pipeline.execute();
...
That's almost the same as the example on the cocoon website. The only
difference is that instead of a file I'm using a URL to provide the
XSLT. This works if I disable authentication for my XML/XSLT
repository. But when I enable authentication, I'll end up with an
exception and a 401 from apache somewhere in the stack trace...
So in short: I'm wondering if there is a way to create an
XSLTTransformer that can retrieve data from URLs that require
authentication?
Any help would be greatly appreciated! Cheers, Nils
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]