This commit is contained in:
2023-06-08 11:50:06 +08:00
parent 7091a8ce23
commit 06cb41fff7
5 changed files with 18 additions and 21 deletions

View File

@@ -8,25 +8,19 @@ import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.DockingPlatformConfig;
import com.jsowell.pile.dto.*;
import com.jsowell.pile.service.IDockingPlatformConfigService;
import com.jsowell.thirdparty.lianlian.common.CommonResult;
import com.jsowell.thirdparty.lianlian.domain.StationStatsInfo;
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
import com.jsowell.thirdparty.lianlian.service.LianLianService;
import com.jsowell.thirdparty.lianlian.util.Cryptos;
import com.jsowell.thirdparty.lianlian.util.Encodes;
import com.jsowell.thirdparty.lianlian.util.SignUtils;
import com.jsowell.thirdparty.lianlian.vo.*;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
@@ -281,7 +275,7 @@ public class LianLianController extends BaseController {
String dataString = resultMap.get("Data");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
String dataStr = new String(plainText, "UTF-8");
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成相应对象
QueryEquipmentDTO queryEquipmentDTO = JSONObject.parseObject(dataStr, QueryEquipmentDTO.class);
queryEquipmentDTO.setOperatorID(dto.getOperatorID());
@@ -345,7 +339,7 @@ public class LianLianController extends BaseController {
String dataString = resultMap.get("Data");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
String dataStr = new String(plainText, "UTF-8");
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成相应对象
QueryStartChargeDTO queryStartChargeDTO = JSONObject.parseObject(dataStr, QueryStartChargeDTO.class);
queryStartChargeDTO.setOperatorID(dto.getOperatorID());
@@ -408,7 +402,7 @@ public class LianLianController extends BaseController {
String dataString = resultMap.get("Data");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
String dataStr = new String(plainText, "UTF-8");
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成相应对象
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = JSONObject.parseObject(dataStr, QueryEquipChargeStatusDTO.class);
queryEquipChargeStatusDTO.setOperatorID(dto.getOperatorID());
@@ -465,7 +459,7 @@ public class LianLianController extends BaseController {
String dataString = resultMap.get("Data");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
String dataStr = new String(plainText, "UTF-8");
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成相应对象
QueryStartChargeDTO queryStartChargeDTO = JSONObject.parseObject(dataStr, QueryStartChargeDTO.class);
queryStartChargeDTO.setOperatorID(dto.getOperatorID());
@@ -521,7 +515,7 @@ public class LianLianController extends BaseController {
String dataString = resultMap.get("Data");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
String dataStr = new String(plainText, "UTF-8");
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成相应对象
PushOrderSettlementDTO pushOrderSettlementDTO = JSONObject.parseObject(dataStr, PushOrderSettlementDTO.class);
pushOrderSettlementDTO.setOperatorId(dto.getOperatorID());
@@ -561,7 +555,7 @@ public class LianLianController extends BaseController {
String dataString = resultMap.get("Data");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
String dataStr = new String(plainText, "UTF-8");
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成相应对象
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
queryStationInfoDTO.setOperatorId(dto.getOperatorID());
@@ -602,7 +596,7 @@ public class LianLianController extends BaseController {
String dataString = resultMap.get("Data");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
String dataStr = new String(plainText, "UTF-8");
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成相应对象
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
queryStationInfoDTO.setOperatorId(dto.getOperatorID());

View File

@@ -61,6 +61,7 @@ import org.springframework.util.StopWatch;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -237,7 +238,7 @@ public class SpringBootTestController {
String dataJson = JSONUtil.toJsonStr(data);
//加密
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes("UTF-8"),
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes(StandardCharsets.UTF_8),
OperatorSecret.getBytes(), OperatorSecret.getBytes());
String strData = Encodes.encodeBase64(encryptText);
@@ -293,7 +294,7 @@ public class SpringBootTestController {
String dataJson = JSONObject.toJSONString(json);
// 加密
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes("UTF-8"),
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes(StandardCharsets.UTF_8),
operatorSecret.getBytes(), operatorSecret.getBytes());
String strData = Encodes.encodeBase64(encryptText);
String timeStamp = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date());

View File

@@ -12,6 +12,7 @@ import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@@ -308,7 +309,7 @@ public class RedisCache {
.count(10000).build())) {
while (cursor.hasNext()) {
keysTmp.add(new String(cursor.next(), "Utf-8"));
keysTmp.add(new String(cursor.next(), StandardCharsets.UTF_8));
}
} catch (Exception e) {
logger.error(e.getMessage(), e);

View File

@@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* XSS过滤处理
@@ -49,14 +50,14 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
}
// 为空,直接返回
String json = IOUtils.toString(super.getInputStream(), "utf-8");
String json = IOUtils.toString(super.getInputStream(), StandardCharsets.UTF_8);
if (StringUtils.isEmpty(json)) {
return super.getInputStream();
}
// xss过滤
json = EscapeUtil.clean(json).trim();
byte[] jsonBytes = json.getBytes("utf-8");
byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8);
final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes);
return new ServletInputStream() {
@Override

View File

@@ -17,7 +17,6 @@ import com.jsowell.common.enums.ykc.OrderPayModeEnum;
import com.jsowell.common.enums.ykc.OrderStatusEnum;
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
import com.jsowell.common.enums.ykc.PileStatusEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.PageUtils;
@@ -50,6 +49,7 @@ import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
@@ -1058,7 +1058,7 @@ public class LianLianServiceImpl implements LianLianService {
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data),
operatorSecret.getBytes(), operatorSecret.getBytes());
String dataStr = new String(plainText, "UTF-8");
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转成对应的对象
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = JSONObject.parseObject(dataStr, QueryEquipChargeStatusDTO.class);
// 获取令牌