In C# code we are using network authentication:

```
req = HttpWebRequest.Create(Url)
req.Method = "POST"
req.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate")
req.Credentials = New NetworkCredential(Username, Password)

```

We need to implement same in Java. I have tried folowing two approach but it is not working:

1. httppost.setHeader("Authorization", "Basic " + "username:password");
2. Authenticator.setDefault(new PaswordAuthentication());

but both did not work.
Any lead will be highly appreciated.