SHARE
TWEET

Untitled

a guest May 22nd, 2017 51 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.     private int id;
  12.  
  13.     private static String URL_Login = "localhost:8080/MyLibreria/LoginAndroid";
  14.  
  15.     public WebLoginClass(){
  16.         richiesta_web = new WebRequest();
  17.     }
  18.  
  19.     public int getId(){
  20.         return this.id;
  21.     }
  22.  
  23.     private void setId(int id){
  24.         this.id = id;
  25.     }
  26.  
  27.     public void setUsername(String username) {  //
  28.         this.username = username;
  29.     }
  30.  
  31.     public void setPassword(String password) {
  32.         this.password = password;
  33.     }
  34.  
  35.     public int effettuaLogin() throws Exception{
  36.  
  37.         if(password == null || username == null)
  38.             throw new Exception();
  39.  
  40.         richiesta_web.aggiungiParametro("username", username);
  41.         richiesta_web.aggiungiParametro("password" , password);
  42.  
  43.         richiesta_web.setURL(URL_Login);
  44.  
  45.         richiesta_web.inviaRichiesta();
  46.  
  47.         String result = richiesta_web.getRisultatoRichiesta();
  48.  
  49.         richiesta_web.svuotaParametri();
  50.  
  51.         JSONObject my_object = new JSONObject(result);
  52.  
  53.         this.setId(my_object.getInt("msg"));
  54.  
  55.         return my_object.getInt("msg");
  56.  
  57.     }
  58.  
  59. }
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