Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 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. "users/login" + this.host
  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. LauncherController LC = new LauncherController("{USERNAME}","{PASSWORD}");
  42. LC.checkPlayerAccount();
  43.  
  44. while ((inputLine = in.readLine()) != null){
  45. a.append(inputLine);
  46. }
  47. in.close();
  48.  
  49. if(debug){
  50. System.out.println("[LauncherController] Value : " + a.toString() + " for the couple username/password : "
  51. + this.username + "/" + this.password + " and salt : " + this.salt);
  52. }
  53. } catch (IOException e) {
  54. e.printStackTrace();
  55. }
  56. return a.toString();
  57. }
  58.  
  59. public boolean checkPlayerAccount(){
  60. String result = this.getResultFromAPI();
  61. if(result.equals("true")){
  62. return true;
  63. }else{
  64. return false;
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement