Results 1 to 1 of 1
  1. #1
    hemaljoes is offline Member
    Join Date
    Jan 2011
    Posts
    1
    Rep Power
    0

    Default Authenticate for a website without using a browser.

    Hi everyone,

    I need to create a java class which can do the following requirement.

    - When the openid and the password is given it should create and HttpRequest and send to the https://www.myopenid.com/signin_password page and get the authResponse which has the openid token.

    - I need to do accomplish the above task without using a browser.

    I tried the following code. but it just return the html of the sign_in page.

    URL url = new URL("https://www.myopenid.com/signin_password");
    URLConnection uRLConnection = url.openConnection();
    uRLConnection.setAllowUserInteraction(true);
    uRLConnection.setDoInput(true);
    uRLConnection.setDoOutput(true);
    String authorization ="hemaljoes:password";
    uRLConnection.setRequestProperty("Authorization", "Basic " + authorization);
    uRLConnection.connect();

    OutputStream outputStream = uRLConnection.getOutputStream();
    outputStream.flush();

    InputStream in = uRLConnection.getInputStream();
    InputStreamReader inReader = new InputStreamReader(in);
    BufferedReader reader = new BufferedReader(inReader);

    String newLine = null;
    while ((newLine = reader.readLine()) != null)
    System.out.println(newLine);
    reader.close();

    String headerName=null;
    for (int i=1; (headerName = uRLConnection.getHeaderFieldKey(i))!=null; i++) {
    System.out.println(uRLConnection.getHeaderFieldKey (i));
    System.out.println(uRLConnection.getHeaderField(i) );
    }

    Can anyone help me please.
    Thanks in advanced.
    Last edited by hemaljoes; 01-29-2011 at 07:42 PM.

Similar Threads

  1. How to authenticate code with no internet connect.
    By beardawg in forum Java Applets
    Replies: 1
    Last Post: 04-14-2010, 08:31 PM
  2. Replies: 0
    Last Post: 04-13-2010, 09:16 PM
  3. Replies: 4
    Last Post: 10-07-2009, 10:14 AM
  4. Error: JCE cannot authenticate the provider BC
    By mariabg in forum Java Servlet
    Replies: 0
    Last Post: 02-26-2009, 12:55 PM
  5. Connecting to a Website with the default browser
    By Riftwalker in forum Java Applets
    Replies: 4
    Last Post: 12-04-2007, 05:57 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •