Search code examples
javarssfeedrss-readerrome

Rome XmlReader not reading https feed


I am trying to read https://d3ca01230439ce08d4aab0c61810af23:bla@mycon.mycompany.com/recordings.atom

using Rome but its giving me error

   INFO: Illegal access: this web application instance has been stopped already.  Could not load org.bouncycastle.jcajce.provider.symmetric.AES$ECB.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.

and

   Server returned HTTP response code: 401 for URL: https://d3ca01230439ce08d4aab0c61810af23:bla@mycon.mycompany.com/recordings.atom .

I am doing this

    URL url =  new URL("https://d3ca01230439ce08d4aab0c61810af23:bla@mycon.mycompany.com/recordings.atom ");

    try {
    SyndFeedInput input = new SyndFeedInput();

        SyndFeed feed = input.build(new XmlReader(url));

        System.out.println("Feed Author:"+feed.getAuthor());

        for(Object entries: feed.getEntries()){

            SyndEntry entry = (SyndEntry) entries;

            System.out.println("title :"+entry.getTitle());
            System.out.println("description : "+entry.getDescription());

        }


    } catch (IllegalArgumentException | FeedException | IOException e) {
        e.printStackTrace();
    }

Do I need to put the username password somewhere?

update

This I have done

  URL url =  new URL("https://d3ca01230439ce08d4aab0c61810af23:bla@mycon.mycompany.com/recordings.atom");

    HttpURLConnection httpcon = (HttpURLConnection)url.openConnection();

    String encoding = new sun.misc.BASE64Encoder().encode("username:pass".getBytes());

    httpcon.setRequestProperty  ("Authorization", "Basic " + encoding);

Solution

  • When I hit that URL from my browser it asks for basic authentication. You can do this with ROME:

    URL feedUrl = new URL(feed)
    HttpURLConnection httpcon = (HttpURLConnection)feedUrl.openConnection();
    String encoding = new sun.misc.BASE64Encoder().encode("username:password".getBytes());
    httpcon.setRequestProperty  ("Authorization", "Basic " + encoding);
    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed = input.build(new XmlReader(httpcon));
    

    You probably shouldn't use sun.misc.BASE64Encoder. Rather find another one somewhere.

    From: http://cephas.net/blog/2005/02/09/retrieving-an-rss-feed-protected-by-basic-authentication-using-rome/