罗马XmlReader不读取https提要 [英] Rome XmlReader not reading https feed

查看:98
本文介绍了罗马XmlReader不读取https提要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试阅读 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.

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

我正在这样做

    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?

更新

我已经完成了

  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);

推荐答案

当我从浏览器中访问该URL时,它要求进行基本身份验证.您可以使用ROME做到这一点:

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));

您可能不应该使用sun.misc.BASE64Encoder.宁可在某个地方找到另一个.

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

来自: 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆