...
|
...
|
@@ -7,6 +7,8 @@ import com.yoho.service.model.union.request.ActivateUnionRequestBO; |
|
|
import com.yoho.service.model.union.request.ClickUnionRequestBO;
|
|
|
import com.yoho.unions.common.enums.ClientTypeEnum;
|
|
|
import com.yoho.unions.common.utils.DateUtil;
|
|
|
import com.yoho.unions.dal.IUnionConfigDAO;
|
|
|
import com.yoho.unions.dal.model.UnionConfig;
|
|
|
import com.yoho.unions.server.service.IUnionService;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
...
|
...
|
@@ -66,7 +68,7 @@ public class ZhihuituiServiceImpl extends UnionServiceImpl implements IUnionServ |
|
|
bo.setUnion_type(request.getParameter("union_type"));
|
|
|
bo.setClickTime(Integer.valueOf(request.getParameter("click_time")));
|
|
|
bo.setTd(request.getParameter("td"));
|
|
|
//广告主在广点通的账户id
|
|
|
//广告主在智慧推的账户id
|
|
|
// bo.setJson(JSONObject.parseObject(request.getParameter("advertiser_id")));
|
|
|
bo.setCommonUse(String.valueOf(request.getParameter("advertiser_id")));
|
|
|
return bo;
|
...
|
...
|
@@ -81,103 +83,68 @@ public class ZhihuituiServiceImpl extends UnionServiceImpl implements IUnionServ |
|
|
public String urlEode(ActivateUnionRequestBO requestBO) {
|
|
|
log.info("enter GDTServiceImpl.urlEode param{} is ", requestBO);
|
|
|
// 根据不同的应用类型,获取不同的加密密钥和签名密钥
|
|
|
String encryptKey = null;
|
|
|
String signKey = null;
|
|
|
String encryptKey = "b4e4b76af6626299";
|
|
|
String signKey = "04ddd32894b3c683";
|
|
|
String muid4MD5 = "";
|
|
|
//有货在广点通的账号id
|
|
|
String uid = requestBO.getCommonUse();
|
|
|
String url = "http://jump.t.l.qq.com/conv/app/";
|
|
|
//有货在智慧推的账号id
|
|
|
String uid = "18261";
|
|
|
if(StringUtils.isNotEmpty(requestBO.getCommonUse())){
|
|
|
uid = requestBO.getCommonUse();
|
|
|
}
|
|
|
String clientType = ClientTypeEnum.IOS.getName();
|
|
|
if(StringUtils.isNotEmpty(requestBO.getClient_type())){
|
|
|
clientType = requestBO.getClient_type().toLowerCase();
|
|
|
}
|
|
|
UnionConfig unionConfig = unionConfigDAO.selectByUidAndClientType(Integer.valueOf(uid),clientType);
|
|
|
if(null!=unionConfig){
|
|
|
encryptKey = unionConfig.getEncryptKey();
|
|
|
signKey = unionConfig.getSignKey();
|
|
|
url = unionConfig.getUrl();
|
|
|
}
|
|
|
|
|
|
if (ClientTypeEnum.IOS.getName().equalsIgnoreCase(requestBO.getClient_type())) {
|
|
|
//由于有两个广点通账号,根据不同的账号取不同的加密密钥和签名密钥
|
|
|
if(StringUtils.isNotEmpty(uid)&&uid.equals("365136")){
|
|
|
DynamicStringProperty ios_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("ios1_encrypt_key", "");
|
|
|
encryptKey = ios_encrypt_key.get();
|
|
|
DynamicStringProperty ios_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("ios1_sign_key", "");
|
|
|
signKey = ios_sign_key.get();
|
|
|
}else{
|
|
|
DynamicStringProperty ios2_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("ios2_encrypt_key", "");
|
|
|
encryptKey = ios2_encrypt_key.get();
|
|
|
DynamicStringProperty ios2_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("ios2_sign_key", "");
|
|
|
signKey = ios2_sign_key.get();
|
|
|
}
|
|
|
|
|
|
//IDFA 码(需转大写),进行 md5 以后得到的 32位全小写 md5 表现字符串。
|
|
|
muid4MD5 = requestBO.getIdfa().toUpperCase();
|
|
|
//IDFA 码
|
|
|
muid4MD5 = requestBO.getIdfa();
|
|
|
} else {
|
|
|
if(StringUtils.isNotEmpty(uid)&&uid.equals("365136")){
|
|
|
DynamicStringProperty android_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("android1_encrypt_key", "");
|
|
|
encryptKey = android_encrypt_key.get();
|
|
|
DynamicStringProperty android_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("android1_sign_key", "");
|
|
|
signKey = android_sign_key.get();
|
|
|
}else{
|
|
|
DynamicStringProperty android2_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("android2_encrypt_key", "");
|
|
|
encryptKey = android2_encrypt_key.get();
|
|
|
DynamicStringProperty android2_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("android2_sign_key", "");
|
|
|
signKey = android2_sign_key.get();
|
|
|
}
|
|
|
|
|
|
//IMEI 号(需转小写),进行 md5 以后得到的 32位全小写 md5 表现字符串。
|
|
|
muid4MD5 = requestBO.getImei().toLowerCase();
|
|
|
//IMEI 号
|
|
|
muid4MD5 = requestBO.getImei();
|
|
|
}
|
|
|
/**
|
|
|
* 对设备id进行MD5加密,获取32位小写加密串
|
|
|
*/
|
|
|
String muid = MD5.md5(muid4MD5);
|
|
|
log.info("activateUnion muid is{} ", muid);
|
|
|
|
|
|
/**
|
|
|
* 对url进行拼接,并进行加密-----http://t.gdt.qq.com/conv/app/
|
|
|
*/
|
|
|
String url = DynamicPropertyFactory.getInstance().getStringProperty("guangdiantong.url", "").get();
|
|
|
int conv_time = DateUtil.getCurrentTimeSecond();
|
|
|
|
|
|
String client_ip = requestBO.getClientIp();
|
|
|
String clickId = requestBO.getUdid();
|
|
|
String appId = requestBO.getAppid();
|
|
|
int conv_time = DateUtil.getCurrentTimeSecond();
|
|
|
String page = null;
|
|
|
String query_string = null;
|
|
|
StringBuffer bf = new StringBuffer();
|
|
|
StringBuffer sf = new StringBuffer();
|
|
|
String query_string = null;
|
|
|
String url4Encoude = null;
|
|
|
if (StringUtils.isEmpty(client_ip)) {
|
|
|
url4Encoude = bf.append(url).append(appId).append("/conv?click_id=").append(clickId).append("&muid=").append(muid).append("&conv_time=").append(conv_time).toString();
|
|
|
query_string = sf.append("click_id=").append(clickId).append("&muid=").append(muid).append("&conv_time=").append(conv_time).toString();
|
|
|
} else {
|
|
|
url4Encoude = bf.append(url).append(appId).append("/conv?click_id=").append(clickId).append("&muid=").append(muid).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString();
|
|
|
query_string = sf.append("click_id=").append(clickId).append("&muid=").append(muid).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString();
|
|
|
if (StringUtils.isEmpty(client_ip)){
|
|
|
page = bf.append(url).append(appId).append("/conv?muid=").append(muid4MD5).append("&conv_time=").append(conv_time).toString();
|
|
|
query_string = sf.append("muid=").append(muid4MD5).append("&conv_time=").append(conv_time).toString();
|
|
|
}else{
|
|
|
page = bf.append(url).append(appId).append("/conv?muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString();
|
|
|
query_string = sf.append("muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString();
|
|
|
}
|
|
|
log.info("activateUnion url is{} ", url4Encoude);
|
|
|
//参数加密
|
|
|
// sf = sf.append(url).append(requestBO.getAppid()).append("/conv?").append(query_string);
|
|
|
|
|
|
// 对url进行加密
|
|
|
String urlEncoder = null;
|
|
|
String encode_page = null;
|
|
|
try {
|
|
|
urlEncoder = URLEncoder.encode(url4Encoude, "UTF-8");
|
|
|
log.info("activateUnion urlEncoder is{} ", urlEncoder);
|
|
|
encode_page = URLEncoder.encode(page, "UTF-8");
|
|
|
log.info("activateZhiHuitui urlEncoder is{} ", encode_page);
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
log.error("encode exception.", e);
|
|
|
}
|
|
|
// 将签名密钥和提交方式与加密后的url进行拼接
|
|
|
StringBuffer urlBuffer = new StringBuffer();
|
|
|
url = urlBuffer.append(signKey).append("&GET&").append(urlEncoder).toString();
|
|
|
log.info("signkey url is {}",url);
|
|
|
// 对url进行MD5加密,获取32位小写加密串
|
|
|
String md5 = MD5.md5(url);
|
|
|
log.info("activateUnion md5 is{} ", md5);
|
|
|
// 参数组合,并进行加密
|
|
|
|
|
|
String property = urlBuffer.append(signKey).append("&GET&").append(encode_page).toString();
|
|
|
String signature = MD5.md5(property);
|
|
|
StringBuffer base = new StringBuffer();
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
String md5UrlEncoude = null;
|
|
|
try{
|
|
|
md5UrlEncoude = URLEncoder.encode(md5,"UTF-8");
|
|
|
}catch (UnsupportedEncodingException e) {
|
|
|
log.error("encode exception.", e);
|
|
|
}
|
|
|
String baseData = base.append(query_string).append("&sign=").append(md5UrlEncoude).toString();
|
|
|
log.info("activateUnion baseDate is {} ", baseData);
|
|
|
String base_data = base.append(query_string).append("&sign=").append(signature).toString();
|
|
|
|
|
|
// 简单异或处理
|
|
|
String base64 = simpleXorByGdt(baseData, encryptKey);
|
|
|
String data = simpleXorByGdt(base_data, encryptKey);
|
|
|
// base64编码
|
|
|
String ret = Base64.encodeBase64String(base64.getBytes());
|
|
|
String ret = Base64.encodeBase64String(data.getBytes());
|
|
|
// 64位处理之后,防止里面有换行符
|
|
|
String retRep = ret.replaceAll("\n", "");
|
|
|
// 将64位处理之后的值,按照url加密的方式进行加密
|
...
|
...
|
@@ -188,9 +155,9 @@ public class ZhihuituiServiceImpl extends UnionServiceImpl implements IUnionServ |
|
|
log.error("encode exception.", e);
|
|
|
}
|
|
|
// conv_type,,现在只有移动应用激活类型(MOBILEAPP_ACTIVITE);
|
|
|
String convType = "MOBILEAPP_ACTIVITE";
|
|
|
|
|
|
url = sb.append(DynamicPropertyFactory.getInstance().getStringProperty("guangdiantong.url", "").get()).append(requestBO.getAppid()).append("/conv?v=").append(retRep).append("&conv_type=").append(convType).append("&app_type=").append(clientTypeConver(requestBO.getClient_type())).append("&advertiser_id=").append(uid).toString();
|
|
|
String convType = "MOBILE_APP_ACTIVITE";
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
url = sb.append(url).append(requestBO.getAppid()).append("/conv?v=").append(retRep).append("&conv_type=").append(convType).append("&app_type=").append(clientTypeConver(requestBO.getClient_type())).append("&advertiser_id=").append(uid).toString();
|
|
|
log.info("zhihuitui url is {}", url);
|
|
|
return url;
|
|
|
}
|
...
|
...
|
|