Hi all,
I am trying to read the content from a secured url (https + username and password) with a java agent (the code is attached below). The agent will run on the server as a scheduled agent but for now I am running it manually from the designer client.
I have added the .cer file to the keyfile.kyr as suggested in this post: http://www-10.lotus.com/ldd/nd8forum.nsf/5f27803bba85d8e285256bf10054620d/702cf07838c391c285257403004c1551?OpenDocument
The problem is that I get the content of the loggin page. It is like the code does not successfully loggin to the server.
I would appreciate any help on this problem!
Thank you very much,
Raquel
This is the code:
import lotus.domino.*;
import java.net.*;
import java.io.*;
import javax.net.ssl.HttpsURLConnection;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
System.setProperty("java.protocol.handler.pkgs","com.ibm.net.ssl.www2.protocol");
URL url = new URL("https://xyz.com?modifiedSince=3/4/2010");
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
//set username, password
String username = "123";
String password = "456";
String input = username + ":" + password;
String encoding = new sun.misc.BASE64Encoder().encode (input.getBytes());
connection.setRequestProperty("Authorization", "Basic " + encoding);
//set cookie
connection.setRequestProperty("Cookie", "LocationCode=Geneva");
connection.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
//Loop through every line of the URL.
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine.toString());
}
in.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}