Hello,

I now have a solution to my problem, as I only needed to authenticate
via HTTPS, encrypting username and password, get the session cookie,
and use this cookie for future HTTP communication.  However, I would
like to understand why there was an IOException generated from a
getResponseMessage(), even though the response from the server was:

Received authentication challenge is null

Even though this would output to the log, the exception would be
thrown:
java.io.IOException: Received authentication challenge is null

If I remove that line, the cookies are pulled from the header with no
problem, and there is no exception.


public void onClick(View v) {
        // Perform action on click
        try {

        URL url = new URL("https://www.mysite.com/session.xml";);

        HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
        conn.setDoOutput(true);
      conn.setDoInput(true);

      conn.setRequestMethod("POST");

      /* used this to force verification (from example
http://25digital.blogspot.com/2008/02/account-authentication-api-y-android.html).
This is a security problem, as host is no longer validated, though
encryption remains between server and client
       *
       * needed because of Android bug
http://groups.google.com/group/android-developers/browse_thread/thread/cd8d3ba7652fd99b
       *
       */
      conn.setHostnameVerifier(new HostnameVerifier(){
                public boolean verify (String hostname, SSLSession session) {
                        return true;
                }
        });

        OutputStreamWriter outputStreamWriter = new OutputStreamWriter
(conn.getOutputStream());
        outputStreamWriter.write("email=" + URLEncoder.encode("userName"));
        outputStreamWriter.write("&");
        outputStreamWriter.write("password=" + URLEncoder.encode
("userPassword"));
        outputStreamWriter.flush();
        outputStreamWriter.close();

        // THIS FAILS
        Log.i("login", "Response message: " + conn.getResponseMessage());

        String[] cookies = conn.getHeaderField("set-cookie").split(";");


        } catch (Exception e) {
                Log.e("login", e.getMessage());
        }
}

Thank you,
Steve

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to