Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to authenticate to lotus server using URLConnection Please help  RSS feed

sameer K
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have URL in the format'http://host/xxx.nsf?xxx&yyy&user=abc&password=123'(this is not the actual URL but URL has this format)
this URL connects to lotus notes server.We need to authenticate before getting data from this URL.Please notice authentication parameters are passed in the URL itself as 'user=abc&password=123'.

I am usig URL Conection and URL classes to connect and read the data.But,authentication is failing. Where as the same URL gives back the data i require when i run it in the browser.

Please help.

follwing is the code
Hashtable env = new Hashtable();
/*Create the URL and connect.*/

URL url= new URL(kdk_generalProcessingLogic.getMessage(kdk_ResourceBundleClass.sa_ResourceBundle,"LDAPEmailDataURL"));
String ls_UserId=kdk_generalProcessingLogic.getMessage(kdk_ResourceBundleClass.sa_ResourceBundle,"User_LDAPEmailDataURL");
String ls_Password=kdk_generalProcessingLogic.getMessage(kdk_ResourceBundleClass.sa_ResourceBundle,"Pwd_LDAPEmailDataURL");
Authenticator.setDefault(new kdk_ResourceAuthenticator(ls_UserId,ls_Password));
xml_connection= (HttpURLConnection) url.openConnection();
xml_connection.setRequestMethod( "GET" );
xml_connection.setDoInput( true );
xml_connection.setDoOutput( true );
xml_connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");


// document factory for parsing the xml
DocumentBuilderFactory xml_factory = DocumentBuilderFactory.newInstance();

// document builder to create the document and parse the same
DocumentBuilder xml_builder = xml_factory.newDocumentBuilder();
new DefaultHandler()

/*obtain the first element from the document that has been parsed.
This document is obtained from the input stream.*/

//oputput the data

String ls_EmailXMLFile=kdk_generalProcessingLogic.getMessage(kdk_ResourceBundleClass.sa_ResourceBundle,"EmailXMLLog");
System.out.println("Writing to the file:"+ls_EmailXMLFile);

BufferedReader lo_input = new BufferedReader(new InputStreamReader(ipXML));
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!