Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. public class SelectUserAuthRequest extends MarthaRequest {
  2.     private String mUsername;
  3.     private String mPassword;
  4.  
  5.     public SelectUserAuthRequest(String username, String password, Response.Listener<String> listener, Response.ErrorListener errorListener) {
  6.         super("select-user-auth", listener, errorListener);
  7.  
  8.         mUsername = username;
  9.         mPassword = password;
  10.     }
  11.  
  12.     @Override
  13.     public byte[] getBody() {
  14.         byte[] body = new byte[0];
  15.  
  16.         try {
  17.             HashMap h = new HashMap<String, String>();
  18.             h.put("username", mUsername);
  19.             h.put("password", mPassword);
  20.  
  21.             Gson gson = new Gson();
  22.             String str = gson.toJson(h);
  23.  
  24.             body = str.getBytes("UTF-8");
  25.         } catch (UnsupportedEncodingException e) { /* nothing to do */}
  26.  
  27.         return body;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement