2

https://d3ca01230439ce08d4aab0c61810af23:bla@mycon.mycompany.com/recordings.atomを読み込もうとしています

ローマを使用していますが、エラーが発生します

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

ユーザー名パスワードをどこかに置く必要がありますか?

アップデート

これは私がやった

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

3 に答える 3

7

ブラウザからそのURLを押すと、基本認証を要求されます。あなたは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を使用するべきではありません。むしろどこかで別のものを見つけてください。

差出人:http://cephas.net/blog/2005/02/09/retrieveing-an-rss-feed-protected-by-basic-authentication-using-rome/

于 2012-09-24T19:08:25.680 に答える
0

認証に関しては、これはもう少し弾力性があると思います。このコードは、認証の有無にかかわらず機能します。

URL feedUrl = new URL("http://the.url.to/the/feed");
//URL feedUrl = new URL("http://user:pass@the.url.to/the/feed");

HttpURLConnection connection = (HttpURLConnection) feedUrl.openConnection();
if (feedUrl.getUserInfo() != null) {
    String encoding = new sun.misc.BASE64Encoder().encode(feedUrl.getUserInfo().getBytes());
    connection.setRequestProperty("Authorization", "Basic " + encoding);
}

SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(connection));
于 2014-07-10T07:49:12.070 に答える
0

代わりに以下を使用することもできます

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

これに:

String BASIC_AUTH = "Basic " + Base64.encodeToString("username:password".getBytes(), Base64.NO_WRAP);
于 2014-09-03T08:52:21.647 に答える