1

I am trying to use Apache Camel's rss module to use an basic authentication protected RSS feed as Endpoint. However, I can't find any documentation how to pass it the user credentials. Does anybody know how to do this? Good workarounds are also appreciated!

Fritz Duchardt
  • 11,026
  • 4
  • 41
  • 60

1 Answers1

1

I think it's not possible at the moment. camel-rss uses rome to read RSS Feeds. Take a look to the code of org.apache.camel.component.rss.RssUtils:

public static SyndFeed createFeed(String feedUri, ClassLoader classLoader) throws Exception {
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(classLoader);
        InputStream in = new URL(feedUri).openStream();
        SyndFeedInput input = new SyndFeedInput();
        return input.build(new XmlReader(in));
    } finally {
        Thread.currentThread().setContextClassLoader(tccl);
    }
}

To use basic authentication there must be something like

public static SyndFeed createFeed(String feedUri, ClassLoader classLoader) throws Exception {
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(classLoader);
        URL feedUrl = new URL(feedUri);
        HttpURLConnection httpcon = (HttpURLConnection)feedUrl.openConnection();
        String encoding = new sun.misc.BASE64Encoder().encode("username:password".getBytes());
        httpcon.setRequestProperty  ("Authorization", "Basic " + encoding);
        SyndFeedInput input = new SyndFeedInput();
        return input.build(new XmlReader(httpcon));
    } finally {
        Thread.currentThread().setContextClassLoader(tccl);
    }
}

This is the way described here --> rome-xmlreader-not-reading-https-feed

I opened a new ticket for this feature. --> CAMEL-9009

Community
  • 1
  • 1