Apache Abdera Client giving No credentials available for NTLM <any realm>@proxy.tcs.com:8080

2.3k Views Asked by At

I have seen many forum posts for this and tried several suggestions but still I am not able to solve this. The code works good at my home system, but behind the organization firewall it gives a exception message :

No credentials available for NTLM @proxy.tcs.com:8080

Here is the method which I am using

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

This is the exception log I get

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 in thread "main" java.lang.IllegalStateException at org.apache.abdera.protocol.client.CommonsResponse.(CommonsResponse.java:44) at org.apache.abdera.protocol.client.AbderaClient.execute(AbderaClient.java:692) at org.apache.abdera.protocol.client.AbderaClient.get(AbderaClient.java:216) at org.apache.abdera.protocol.client.AbderaClient.get(AbderaClient.java:404) at IBMConnectionMessages_ForumPractice.UseAbdera(IBMConnectionMessages_ForumPractice.java:231) at IBMConnectionMessages_ForumPractice.main(IBMConnectionMessages_ForumPractice.java:45)

Please help, I have spent half a day on it.

1

There are 1 best solutions below

0
On

your proxy may need ntlm authentication, so provide your proxy authentication details as NTCredentials while setting proxy credentials.