Authored by zhengwen.ge

适配IOS

... ... @@ -2,7 +2,7 @@ package com.yoho.unions.common.enums;
public enum ClientTypeEnum {
IOS("ios"),
IPHONE("iphone"),
ANDROID("android");
... ...
... ... @@ -46,7 +46,7 @@ public class ActivateUnionRest {
ActivateUnionRequestBO bo = new ActivateUnionRequestBO();
BeanUtils.copyProperties(vo, bo);
String clientType = vo.getClient_type();
if (!ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(clientType) && !ClientTypeEnum.IOS.getName().equalsIgnoreCase(clientType)) {
if (!ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(clientType) && !ClientTypeEnum.IPHONE.getName().equalsIgnoreCase(clientType)) {
log.warn("activateUnion error with param is {}", vo);
return new ActiveUnionResponseBO(600, "error");
}
... ... @@ -67,7 +67,7 @@ public class ActivateUnionRest {
log.warn("addUnion error with param is {}", vo);
}
}
} else if (ClientTypeEnum.IOS.getName().equalsIgnoreCase(clientType)) {
} else if (ClientTypeEnum.IPHONE.getName().equalsIgnoreCase(clientType)) {
//处理iOS的服务
for (String str : UnionConstant.iOSServiceList) {
//捕获异常,不影响后面的联盟
... ...
... ... @@ -55,7 +55,7 @@ public class GDTServiceImpl implements MainUnionService {
log.warn("activateUnionCheck error because appid is null with param is {}", request);
return new UnionResponseBO(false, "appid is null");
}
if (StringUtils.isEmpty(request.getClient_type()) || (!request.getClient_type().equalsIgnoreCase(ClientTypeEnum.ANDROID.getName()) && !request.getClient_type().equalsIgnoreCase(ClientTypeEnum.IOS.getName()))) {
if (StringUtils.isEmpty(request.getClient_type()) || (!request.getClient_type().equalsIgnoreCase(ClientTypeEnum.ANDROID.getName()) && !request.getClient_type().equalsIgnoreCase(ClientTypeEnum.IPHONE.getName()))) {
log.warn("activateUnionCheck error with param is {}", request);
return new UnionResponseBO(false, "app_type is error");
}
... ... @@ -63,7 +63,7 @@ public class GDTServiceImpl implements MainUnionService {
log.warn("activateUnionCheck error because imei is null with client_type is andriod with param is {}", request);
return new UnionResponseBO(false, "imei is error");
}
if (request.getClient_type().equalsIgnoreCase(ClientTypeEnum.IOS.getName()) && StringUtils.isEmpty(request.getIdfa())) {
if (request.getClient_type().equalsIgnoreCase(ClientTypeEnum.IPHONE.getName()) && StringUtils.isEmpty(request.getIdfa())) {
log.warn("activateUnionCheck error because idfa is null with client_type is ios with param is {}", request);
return new UnionResponseBO(false, "idfa is error");
}
... ... @@ -89,7 +89,7 @@ public class GDTServiceImpl implements MainUnionService {
UnionLogs unionLogs = new UnionLogs();
unionLogs.setAppId(String.valueOf(request.getAppid()));
unionLogs.setUdid("");
if (ClientTypeEnum.IOS.getName().equalsIgnoreCase(request.getClient_type())){
if (ClientTypeEnum.IPHONE.getName().equalsIgnoreCase(request.getClient_type())){
unionLogs.setIdfa(request.getIdfa());
}else{
unionLogs.setImei(request.getImei());
... ... @@ -135,13 +135,13 @@ public class GDTServiceImpl implements MainUnionService {
* @param requestBO
* @return
*/
private static String urlEode(ActivateUnionRequestBO requestBO) {
private String urlEode(ActivateUnionRequestBO requestBO) {
log.info("enter GDTServiceImpl.urlEode param{} is ", requestBO);
// 根据不同的应用类型,获取不同的加密密钥和签名密钥
String encryptKey = null;
String signKey = null;
String muid4MD5 = "";
if (ClientTypeEnum.IOS.getName().equalsIgnoreCase(requestBO.getClient_type())) {
if (ClientTypeEnum.IPHONE.getName().equalsIgnoreCase(requestBO.getClient_type())) {
DynamicStringProperty ios_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("ios_encrypt_key", "");
encryptKey = ios_encrypt_key.get();
DynamicStringProperty ios_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("ios_sign_key", "");
... ... @@ -216,11 +216,23 @@ public class GDTServiceImpl implements MainUnionService {
// conv_type,,现在只有移动应用激活类型(MOBILEAPP_ACTIVITE);
String convType = "MOBILEAPP_ACTIVITE";
String uid = "1261905";
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(requestBO.getClient_type()).append("&advertiser_id=").append(uid).toString();
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();
log.info("activateUnion url is {}", url);
return url;
}
private String clientTypeConver(String clientType) {
if (StringUtils.isEmpty(clientType)) {
return null;
}
if (ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(clientType)) {
return clientType.toUpperCase();
} else {
return "IOS";
}
}
/**
* 简单异或
*
... ... @@ -228,7 +240,7 @@ public class GDTServiceImpl implements MainUnionService {
* @param key
* @return
*/
private static String simpleXorByGdt(String source, String key) {
private String simpleXorByGdt(String source, String key) {
String result = "";
int j = 0;
for (int i = 0; i < source.length(); i++) {
... ...