AlanGomes

DevPainel

Mar 14th, 2015
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. package me.plugin.auth;
  2.  
  3. import java.io.IOException;
  4. import java.net.URL;
  5. import java.net.URLConnection;
  6. import java.util.Scanner;
  7.  
  8.  
  9. class DevPainel {
  10.    
  11.     public static boolean autoriza(String identificacao, String chave) {
  12.         if (identificacao==null || chave==null) return false;
  13.         if (!sistemaOnline()) {
  14.             return false;
  15.         }
  16.         String response=getText("http://minecraftdv.com/devpainel/api/autenticar.php?plugin="+identificacao+"&chave="+chave);
  17.         if (response==null) return false;
  18.         response=response.trim();
  19.         if (response.equalsIgnoreCase("false")) return false;
  20.         return true;
  21.     }
  22.    
  23.     public static boolean sistemaOnline() {
  24.         return getText("http://minecraftdv.com/devpainel/api/autenticar.php")!=null;
  25.     }
  26.    
  27.     private static String getText(String urlloc) {
  28.         try {
  29.           URL url = new URL(urlloc);
  30.           URLConnection openConnection = url.openConnection();    
  31.             openConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0");
  32.           Scanner r = new Scanner(openConnection.getInputStream());
  33.           StringBuilder sb = new StringBuilder();
  34.           while (r.hasNext()) {
  35.             sb.append(r.next());
  36.           }
  37.           r.close();
  38.           return sb.toString();
  39.         } catch (IOException e) {
  40.         }
  41.         return null;
  42.       }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment