2

我已经看过很多论坛帖子并尝试了一些建议,但我仍然无法解决这个问题。该代码在我的家庭系统中运行良好,但在组织防火墙后面它给出了一条异常消息:

没有可用于 NTLM @proxy.tcs.com:8080 的凭据

这是我正在使用的方法

private static void UseAbdera() throws IOException 
{
    try 
    {
        Abdera abdera = new Abdera();
        AbderaClient client = new AbderaClient(abdera);
        client.setProxy("OrgProxyHost", 8080);
        NTLMAuthenticatorClass authenticator = new NTLMAuthenticatorClass("username", "password");
        Authenticator.setDefault(authenticator);
        NTCredentials ntcr = new NTCredentials("username", "password", "greenhouse.lotus.com", "India.TCS.com");

        client.addCredentials("https://greenhouse.lotus.com", null, null, ntcr);
        ClientResponse resp = client.get("https://greenhouse.lotus.com/forums/atom/service");
        org.apache.abdera.model.Document<org.apache.abdera.model.Service> service_doc = resp.getDocument();
        service_doc.writeTo(System.out);
        System.out.println("\n");
        org.apache.abdera.model.Service service = service_doc.getRoot();
        org.apache.abdera.model.Collection collection = service.getCollection("Forums Feed Collection", "My Topics");
        String coll_uri = collection.getResolvedHref().toASCIIString();
        org.apache.abdera.model.Entry entry = abdera.newEntry();
        entry.setTitle("TEST REPLY !");
        // Mark private
        resp = client.post(coll_uri, entry);
        switch (resp.getType()) 
        {
            case SUCCESS:
                String location = resp.getLocation().toASCIIString();
                System.out.println("New entry created at: " + location);
                break;

            default:
                System.out.println("Error: " + resp.getStatusText());
        }
    } catch (URISyntaxException ex) 
      {     
          Logger.getLogger(IBMConnectionMessages_ForumPractice.class.getName()).log(Level.SEVERE, null, ex);
      }
} 

这是我得到的异常日志

org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme INFO: ntlm authentication scheme selected Jul 6, 2012 10:42:03 AM org.apache.commons.httpclient.HttpMethodDirector processProxyAuthChallenge INFO: No credentials available for NTLM @orgProxyHost:8080 Exception在 org.apache.abdera.protocol.client.AbderaClient.execute(AbderaClient.java:692 的 org.apache.abdera.protocol.client.CommonsResponse.(CommonsResponse.java:44) 的线程“主”java.lang.IllegalStateException ) 在 org.apache.abdera.protocol.client.AbderaClient.get(AbderaClient.java:216) 在 org.apache.abdera.protocol.client.AbderaClient.get(AbderaClient.java:404) 在 IBMConnectionMessages_ForumPractice.UseAbdera(IBMConnectionMessages_ForumPractice. java:231) 在 IBMConnectionMessages_ForumPractice。主要(IBMConnectionMessages_ForumPractice.java:45)

请帮忙,我花了半天时间。

4

1 回答 1

0

您的代理可能需要 ntlm 身份验证,因此在设置代理凭据时将您的代理身份验证详细信息作为 NTCredentials 提供。

于 2014-12-23T11:49:27.657 回答