SHARE
TWEET

Untitled

a guest May 22nd, 2017 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package WebRequest;
  2.  
  3.  
  4. import org.json.JSONObject;
  5.  
  6. public class WebLoginClass {
  7.  
  8.     private WebRequest richiesta_web;
  9.     private String username;
  10.     private String password;
  11.  
  12.     private static String URL_Login = "localhost:8080/MyLibreria/LoginAndroid";
  13.  
  14.     public WebLoginClass(){
  15.         richiesta_web = new WebRequest();
  16.     }
  17.  
  18.     public void setUsername(String username) {  //
  19.         this.username = username;
  20.     }
  21.  
  22.     public void setPassword(String password) {
  23.         this.password = password;
  24.     }
  25.  
  26.     public int effettuaLogin() throws Exception{
  27.  
  28.         if(password == null || username == null)
  29.             throw new Exception();
  30.  
  31.         richiesta_web.aggiungiParametro("username", username);
  32.         richiesta_web.aggiungiParametro("password" , password);
  33.  
  34.         richiesta_web.setURL(URL_Login);
  35.  
  36.         richiesta_web.inviaRichiesta();
  37.  
  38.         String result = richiesta_web.getRisultatoRichiesta();
  39.  
  40.         richiesta_web.svuotaParametri();
  41.  
  42.         JSONObject my_object = new JSONObject(result);
  43.  
  44.         return my_object.getInt("msg");
  45.  
  46.     }
  47.  
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top