private boolean isSignOK(UChannel channel, LehaihaiPayResult rsp) {
    StringBuilder sb = new StringBuilder();
    sb.append("amount=")
        .append(rsp.getAmount())
        .append("gameid=")
        .append(rsp.getGameid())
        .append("orderid=")
        .append(rsp.getOrderid())
        .append("serverid=")
        .append(rsp.getServerid())
        .append("time=")
        .append(rsp.getTime())
        .append("uid=")
        .append(rsp.getUid())
        .append(channel.getCpAppSecret());

    Log.d("sign txt:" + sb.toString());

    String md5 = EncryptUtils.md5(sb.toString()).toLowerCase();

    Log.d("md5:" + md5);

    return md5.equals(rsp.getSign());
  }
示例#2
0
  @Override
  public void verify(final UChannel channel, String extension, final ISDKVerifyListener callback) {

    try {

      JSONObject json = JSONObject.fromObject(extension);
      final String uid = json.getString("uid");
      final String username = json.getString("nickname");

      Map<String, String> params = new HashMap<String, String>();
      params.put("appid", channel.getCpAppID());
      params.put("uid", uid);

      StringBuilder sb = new StringBuilder();
      sb.append(channel.getCpAppID()).append(channel.getCpAppKey()).append(uid);
      String sign = EncryptUtils.sha1(sb.toString());

      params.put("sign", sign.toUpperCase());

      String url = channel.getChannelAuthUrl();

      UHttpAgent.getInstance()
          .get(
              url,
              params,
              new UHttpFutureCallback() {
                @Override
                public void completed(String result) {

                  try {

                    Log.e("The auth result is " + result);

                    if ("SUCCESS".equals(result)) {

                      callback.onSuccess(new SDKVerifyResult(true, uid, username, ""));
                      return;
                    }

                  } catch (Exception e) {
                    e.printStackTrace();
                  }

                  callback.onFailed(
                      channel.getMaster().getSdkName()
                          + " verify failed. the post result is "
                          + result);
                }

                @Override
                public void failed(String e) {

                  callback.onFailed(channel.getMaster().getSdkName() + " verify failed. " + e);
                }
              });

    } catch (Exception e) {
      e.printStackTrace();
      callback.onFailed(
          channel.getMaster().getSdkName()
              + " verify execute failed. the exception is "
              + e.getMessage());
    }
  }