MY Domino Sever is enabled for Session Authentication and the HTTP Port number is configured to 8080.
When I execute the below program to obtain a domino HTTP session I always get the below out put.
I know RESPONSE CODE 200 indicates smooth operation. But I don’t see any HTTP session created on the server. Even if I provide wrong credentials to the UsernamePasswordCredentials(“xxxxx”, “xxxxx”) still it is returning 200 as its response code. Any suggestions on this ?
public class ClientAuthentication {
public static void main(String[] args) {
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
httpclient.getCredentialsProvider().setCredentials( new AuthScope("10.40.xx.xx", 8080),
new UsernamePasswordCredentials("xxxxx", "xxxxx"));
HttpPost httppost = new HttpPost("http://10.40.xx.xx:8080/names.nsf?Login");
System.out.println("executing request" + httppost.getRequestLine());
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
if (response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK){
System.out.println("---------------OKAY OKAY-------------------------");
System.out.println("RESPONSE CODE " + response.getStatusLine().getStatusCode());
}
if (entity != null) {
System.out.println("Response content length: " + entity.getContentLength());
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
OUTPUT :
executing requestPOST http://10.40.xx.xx:8080/names.nsf?Login HTTP/1.1
---------------OKAY OKAY-------------------------
RESPONSE CODE 200
Response content length: 4256
You are set up for session authentication. but you are attempting to do basic authentication via the default getCredentialsProvider. The 200 response that you are getting is the actual session authentication login form, which you are supposed to POST.
The proper sequence is
Theoretically you should write your own class that implements the CredentialsProvider interface tailored to the Domino session authentication form, and use it with your own DominoHttpClient class extending AbstractHttpClient in order to implement this seuqence cleanly; but I don’t think it’s really worth that effort.