Guest User

dasDA

a guest
Aug 31st, 2016
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. package fr.cynoria.cynoria.launcher;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.net.URL;
  7. import java.net.URLConnection;
  8.  
  9.  
  10. public class LauncherController {
  11.  
  12.  
  13.  
  14. private String salt = "5s355f3985dfr74a";
  15. private String host = "http://cynoria.fr/";
  16. private Boolean debug = false;
  17.  
  18. public String username;
  19. public String password;
  20.  
  21. public LauncherController(String username, String password){
  22. this.username = username;
  23. this.password = password;
  24. }
  25.  
  26. private String getResultFromAPI(){
  27. StringBuilder a = new StringBuilder();
  28. try {
  29. URL uri= new URL(
  30. this.host + "users/login"
  31. + "/launcher/login/" + this.username
  32. + "/" + this.password
  33. + "/" + this.salt
  34. );
  35. URLConnection ec;
  36. ec = uri.openConnection();
  37.  
  38. BufferedReader in = new BufferedReader(new InputStreamReader( ec.getInputStream(), "UTF-8"));
  39. String inputLine;
  40.  
  41.  
  42. while ((inputLine = in.readLine()) != null){
  43. a.append(inputLine);
  44. }
  45. in.close();
  46.  
  47. if(debug){
  48. System.out.println("[LauncherController] Value : " + a.toString() + " for the couple username/password : "
  49. + this.username + "/" + this.password + " and salt : " + this.salt);
  50. }
  51. } catch (IOException e) {
  52. e.printStackTrace();
  53. }
  54. return a.toString();
  55. }
  56.  
  57. public boolean checkPlayerAccount(){
  58. String result = this.getResultFromAPI();
  59. if(result.equals("true")){
  60. return true;
  61. }else{
  62. return false;
  63. }
  64. }
  65. }
Add Comment
Please, Sign In to add comment