|
@@ -7,6 +7,7 @@ import com.zanxiang.game.module.manage.pojo.params.OpenGameServerParam;
|
|
import com.zanxiang.game.module.manage.service.IGameServerService;
|
|
import com.zanxiang.game.module.manage.service.IGameServerService;
|
|
import com.zanxiang.game.module.manage.service.IGameSupperService;
|
|
import com.zanxiang.game.module.manage.service.IGameSupperService;
|
|
import com.zanxiang.game.module.manage.service.IListenCallService;
|
|
import com.zanxiang.game.module.manage.service.IListenCallService;
|
|
|
|
+import com.zanxiang.game.module.manage.utils.SignUtil;
|
|
import com.zanxiang.game.module.mybatis.entity.GameServer;
|
|
import com.zanxiang.game.module.mybatis.entity.GameServer;
|
|
import com.zanxiang.game.module.mybatis.entity.GameSupper;
|
|
import com.zanxiang.game.module.mybatis.entity.GameSupper;
|
|
import com.zanxiang.module.util.JsonUtil;
|
|
import com.zanxiang.module.util.JsonUtil;
|
|
@@ -17,8 +18,6 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
|
-import java.security.MessageDigest;
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -127,26 +126,10 @@ public class CpServerApiService {
|
|
private void signCheck(String cpServerKey, Long gameId, String serverId, Long signTime, String sign) {
|
|
private void signCheck(String cpServerKey, Long gameId, String serverId, Long signTime, String sign) {
|
|
String signStr = "cpServerKey=" + cpServerKey + "gameId=" + gameId
|
|
String signStr = "cpServerKey=" + cpServerKey + "gameId=" + gameId
|
|
+ "serverId=" + serverId + "signTime=" + signTime;
|
|
+ "serverId=" + serverId + "signTime=" + signTime;
|
|
- log.error("请求加密字符串 signStr : {}", signStr);
|
|
|
|
- String mySign = this.md5(signStr);
|
|
|
|
|
|
+ String mySign = SignUtil.md5(signStr, Boolean.TRUE);
|
|
if (Objects.equals(mySign, sign)) {
|
|
if (Objects.equals(mySign, sign)) {
|
|
log.error("加密验证失败, sign : {}, mySign : {}", sign, mySign);
|
|
log.error("加密验证失败, sign : {}, mySign : {}", sign, mySign);
|
|
throw new BaseException("加密标识错误");
|
|
throw new BaseException("加密标识错误");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- private String md5(String data) {
|
|
|
|
- try {
|
|
|
|
- java.security.MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
|
- byte[] array = md.digest(data.getBytes(StandardCharsets.UTF_8));
|
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
|
- for (byte item : array) {
|
|
|
|
- sb.append(Integer.toHexString((item & 0xFF) | 0x100), 1, 3);
|
|
|
|
- }
|
|
|
|
- return sb.toString().toUpperCase();
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("MD5加密异常, data : {}", data);
|
|
|
|
- throw new BaseException("MD5加密异常");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|