2012-02-24 99 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適用於在接收端提取數據。

相關問題