2012-02-24 73 views
1

我已经设置了从Android应用程序到远程服务器调用远程服务器的代码。下面是代码:从Android AsyncTask发送参数到远程服务器

private class DownloadWebPageTask extends AsyncTask<String, Void, String> 
{ 
     @Override 
     protected String doInBackground(String... theParams) 
     { 
      Log.d("Inner class: " , "Doing stuff in background"); 

      String myUrl = theParams[0]; 
      String myEmail = theParams[1]; 
      String myPassword = theParams[2]; 

     Log.d("Inner myURL: " , myUrl); 
     Log.d("myEmail: " , myEmail); 
     Log.d("myPass: " , myPassword); 

     ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); 
     postParameters.add(new BasicNameValuePair("username", myEmail)); 
     postParameters.add(new BasicNameValuePair("password", myPassword));    

     String response = ""; 

     DefaultHttpClient client = new DefaultHttpClient(); 
     HttpGet httpGet = new HttpGet(myUrl); 

     try 
     { 
       HttpResponse execute = client.execute(httpGet); 
       InputStream content = execute.getEntity().getContent(); 

       BufferedReader buffer = new BufferedReader(
         new InputStreamReader(content)); 
       String s = ""; 
       while ((s = buffer.readLine()) != null) 
       { 
        response += s; 
       } 

       Log.d("After call, response: " , " " + response); 
      } 
      catch (Exception e) 
      { 
       Log.d("Exception: " , "Yup"); 
       e.printStackTrace(); 
      } 

     return response; 
    } 


    @Override 
    protected void onPostExecute(String result) 
    { 
     Log.d("Post execute: " , "In the post-execute method"); 
     //textView.setText(result); 

     if (result != null && result == "Ok") 
     { 
      Log.d("Post execute: " , "OKKKK :)");  

     } 
     else 
     { 
      Log.d("Post execute: " , "NOOOT OKKKK :)");    
     } 
}  

}

这是要进行身份验证和登录请求现在你可以看到,我收集来自用户的登录名和密码,但不知道如何。以最好地将其附加到请求URL。

我可以做类似urlString +这样做在Android环境同样的良好做法‘的方式,我的网址是不是HTPPS“登录=登录&通=通过,但我不知道是否有?’? - 有没有一种方法,以确保安全?

谢谢!

回答

1

只好只是回答Heesham赛义德的“答案”发表评论(这实际上是一个指令拧你的应用程序可能曾经有任何安全感):

的移动电话(包括机器人)可能是一个烟雾对简单的人来说,但它不是一个有技术能力的人看不到的黑盒子。如果用户检查代理日志,用户可以看到电话发送的URL。陌生人检查HTTP流量路由通过的任何代理的日志可以看到URL。这是严重的误解,例如Hesham提出的将误解提交给新成员,导致发展中脆弱的应用程序。

Next ...

MD5不是加密! MD5无法解密!神圣的狗屎,在你说话前得到线索,就像你有线索一样! MD5是一种单向哈希算法。任何MD5哈希都可以通过使用Rainbow Tables IFF来逆转,您有足够的时间和CPU能力(并且说某人/某事不具备这两者)。实际上,所有的散列算法和加密算法也是如此 - 但是MD5是最不重要的,花费最少的时间+ CPU来逆转的代价之一。 MD5不适用于保护通过未加密通道传输的数据。NOR适用于在接收端提取数据。

相关问题