Basic Authentification and SSL

Put your problem here if it does not fit any of the other categories.

Basic Authentification and SSL

Postby timweicker » Wed Jul 01, 2009 5:45 pm

Hello,

i sorta have a big problem with SSL and Basic Authentification. It just doesnt want to work in my code. I tried to log me onto a site by my Android Programm but it throws an exception back at me that i failed to authentify. I tried with not SSL Pages and it worked perfectly. If you guys can help me out, i would be really grateful.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.       try{
  2.  
  3.                 URL asdf = new URL("https://dev.dellaware.com/api/account/verifyCredentials.xml?key=test");
  4.  
  5.  
  6.  
  7.                 Log.i("a","a");
  8.  
  9.                 Authenticator.setDefault(new Authenticator() {
  10.  
  11.                             protected PasswordAuthentication getPasswordAuthentication() {                              return new PasswordAuthentication("testuser12", "asdfasdf12".toCharArray());
  12.  
  13.                             }
  14.  
  15.                         });
  16.  
  17.        
  18.  
  19.                
  20.  
  21.        
  22.  
  23.  
  24.  
  25.                
  26.  
  27.                 Log.i("b","b");
  28.  
  29.                 HttpsURLConnection uc = (HttpsURLConnection) asdf.openConnection();
  30.  
  31.                  
  32.  
  33.                 uc.setDoInput(true);
  34.  
  35.                 Log.i("r","r");
  36.  
  37.         InputStream as = uc.getInputStream();
  38.  
  39.         Log.i("c","c");
  40.  
  41.  
  42.  
  43.         Log.i("d","d");
  44.  
  45.         InputStreamReader inputstreamreader = new InputStreamReader(as);
  46.  
  47.         BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
  48.  
  49.        
  50.  
  51.        
  52.  
  53.  
  54.  
  55.        
  56.  
  57.         Log.i("READ LINE", bufferedreader.readLine());
  58.  
  59.  
  60.  
  61.        
  62.  
  63.  
  64.  
  65.        
  66.  
  67.         }
  68.  
  69.         catch(Exception a){
  70.  
  71.                
  72.  
  73.                 Log.e("asdfgasdf", a.getMessage() );
  74.  
  75.                 a.printStackTrace();
  76.  
  77.         }
  78.  
  79.        
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


This is my code. As you can see i try to authentify by using the Authentificator class but apparrently it does not work in SSL Mode.
timweicker
Junior Developer
Junior Developer
 
Posts: 20
Joined: Wed Jun 10, 2009 7:55 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 18 guests