private boolean pingHost(String hostName) {
   HttpResult result =
       HttpClientHelper.get(
           hostName,
           new Header[] {new BasicHeader(ConstantUtil.VER, ConfigUtil.getValue(ConfigUtil.VER))});
   if (result != null && result.getStatuCode() == 200) {
     return true;
   }
   return false;
 }
Example #2
0
 /**
  * 检测账号是否需要验证码
  *
  * @param context
  * @param user
  * @return 0,不需要 1,需要
  */
 public static int checkVerify(Context context, String user) {
   HttpResult verResult =
       HttpClientHelper.get(
           VER_CODE_URL,
           null,
           new NameValuePair[] {
             new BasicNameValuePair("u", user),
             new BasicNameValuePair("cachetime", String.valueOf(System.currentTimeMillis()))
           });
   Cookie verCodeCookie = verResult.getCookie(CHECK_RESULT);
   String checkResult = verCodeCookie.getValue();
   System.out.println("CHECK_RESULT:" + checkResult);
   saveDefaultVerify(context, checkResult.substring(checkResult.indexOf(":") + 1));
   if (checkResult.charAt(0) == '0') {
     String VERIFY_KEY = verResult.getCookie("VERIFY_KEY").getValue();
     saveUserKey(context, VERIFY_KEY);
     return 0;
   }
   return 1;
 }
Example #3
0
 public static Bitmap getVerify(Context context) {
   String url = "http://verify.xunlei.com/image?cachetime=" + System.currentTimeMillis();
   System.out.println("获取验证码===>>>" + url);
   HttpResult result = HttpClientHelper.get(url);
   byte[] data = null;
   if (result != null && result.getStatuCode() == HttpStatus.SC_OK) {
     Cookie cookie = result.getCookie("VERIFY_KEY");
     data = result.getResponse();
     if (cookie == null) {
       return null;
     }
     String value = cookie.getValue();
     System.out.println(value);
     saveUserKey(context, value);
   }
   Bitmap bm = null;
   if (data != null) {
     ByteArrayInputStream is = new ByteArrayInputStream(data);
     bm = BitmapFactory.decodeStream(is);
   }
   return bm;
 }
Example #4
0
 /**
  * 新用户登陆
  *
  * @param user
  * @param pwd
  * @return CookieStore cookie 信息
  */
 public static int Login(Context context, String user, String pwd, String verifycode) {
   saveUserUID(context, "-");
   saveUsrname(context, user);
   saveUserPWD(context, pwd);
   HttpResult loginResult = null;
   if (verifycode == null || verifycode.isEmpty()) {
     verifycode = getDefaultVerify(context);
   }
   Header[] headers =
       new Header[] {new BasicHeader(XLLXBiz.COOKIE, "VERIFY_KEY=" + getUserKey(context))};
   BasicNameValuePair pwdvaluePair;
   if (pwd.length() == 32) {
     pwdvaluePair =
         new BasicNameValuePair(
             "p", MD5Util.getMD5String(MD5Util.getMD5String(pwd)) + verifycode.toUpperCase());
   } else {
     pwdvaluePair =
         new BasicNameValuePair(
             "p",
             MD5Util.getMD5String(
                 MD5Util.getMD5String(MD5Util.getMD5String(pwd)) + verifycode.toUpperCase()));
   }
   loginResult =
       HttpClientHelper.post(
           LOGIN_URL,
           headers,
           new NameValuePair[] {
             new BasicNameValuePair("u", user),
             new BasicNameValuePair("login_enable", "1"),
             new BasicNameValuePair("login_hour", "720"),
             pwdvaluePair,
             new BasicNameValuePair("verifycode", verifycode)
           },
           null);
   return getLoginFlag(context, loginResult.getCookies());
 }