Thanks for the info Peter. Basically i am looking for a sample code to accomplish autologin mechanism. This is i what i want to acheive from the client broswer make a call to server to get the userid and password in encrypted format, decrypt on the browser and use the id and password to launch another site (new window) which requires id and password.
Look at the following
servlet code. Hardcoding the userid and password, runnung this servlet will launch the amecanexpress site logged in.
Now i do not want to hardcode the user id and password in the code but want to make a call to a server and get them in encrypted format, decrypt them and launch the amex site.
Any pointers and sample code is greatly appreciated.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
/**
* Redirect the browser to the Amex welcome page.
*
* The process is as follows:
* <BR>
* <UL>
* <LI>Scrape the Amex login form to obtain a current hidden field. (I'm skipping
* this step for now. A hidden field obtained yesterday seems to work ok.)
* <LI>Send down a "autoload" form that logs in.
* <LI>
* </UL>
*/
public class AmexAutoLogin extends HttpServlet {
public void service(HttpServletRequest req, HttpServletResponse res) throws IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
Enumeration flds = req.getParameterNames();
out.print("<html>");
out.print("<BODY onLoad=doIt()>");
out.print("<form method=POST name=LOGINFORM action=\"https://www.americanexpress.com/en/expressnet/logon/LogLogon\">");
out.print("<INPUT TYPE=\"hidden\" NAME=\"UserID\" VALUE=\"abc123\">");
out.print("<INPUT TYPE=\"hidden\" NAME=\"Password\" VALUE=\"hunter\">");
out.print("<INPUT TYPE=\"hidden\" NAME=\"OKButton.x\" VALUE=\"Continue...\">");
out.print("<INPUT TYPE=\"hidden\" NAME=\"hidden\" VALUE=\" NCdBNNYhFndP2lyHCQUbtnZpMzBD02OZLZzoohuFDYcdk6LhucvDXzZB0X549 H7RkN6oIXusCZZk2e0dEoRlGZTRotisQfyPrpXI5ieUq6vXZcvDNw\">");
out.print("</form>");
out.print("<script>");
out.print("function doIt(){");
out.print(" var current_form=document.forms[\"LOGINFORM\"];");
out.print(" current_form.submit();");
out.print("");
out.print("}");
out.print("</script>");
out.print("</html>");
out.close();
}
}