Commit 66a4fb32 authored by shangying's avatar shangying

sonar问题修改2

parent c0183624
package cn.quantgroup.cashloanflowboss.api.oneclickdata.service.Impl;
import bsh.StringUtil;
import cn.quantgroup.cashloanflowboss.api.oneclickdata.entity.OneClickData;
import cn.quantgroup.cashloanflowboss.api.oneclickdata.model.*;
import cn.quantgroup.cashloanflowboss.api.oneclickdata.repository.OneClickDataRespository;
......@@ -18,14 +17,11 @@ import cn.quantgroup.cashloanflowboss.utils.http.HttpRequest;
import cn.quantgroup.user.retbean.XUser;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
......@@ -53,7 +49,7 @@ public class ApplyLoanServiceImpl implements ApplyLoanService {
private ClfChannelConfiguration clfChannelConfiguration;
private String md5Keywy = "qEAxMJBv";
private String aesKeywy = "sxD8KO79EDK0N0AJ";
Result oneClickReslut=null;
private Result oneClickReslut=new Result();
@Override
public Result applyLoan(OneClickModel oneClickModel){
......@@ -141,7 +137,24 @@ public class ApplyLoanServiceImpl implements ApplyLoanService {
String name = "简介";
String channelUserId = "ZZ_"+ oneClickModel.getPhone();
Map<String, Object> paras =getParas(oneClickModel,name,channelUserId);
String encryptContent = GetEncryptContentAndMd5.getEncryptContent(paras, aesKeywy, md5Keywy);
Map<String,String> content_map = new HashMap<String, String>();
content_map.put("content", encryptContent);
log.info("查看结果content={}", content_map);
JSONObject result = HttpRequest.doPostReturnResponseJson(url, content_map);
return result;
}
public Map<String, Object> getParas ( OneClickModel oneClickModel,String name,String channelUserId){
Map<String, Object> paras =new HashMap<String, Object>();
paras.put("address", "湖北省恩施州利川团堡");
paras.put("applyAmount", oneClickModel.getAmount());
paras.put("applyTerm", oneClickModel.getTermNo());
......@@ -203,22 +216,15 @@ public class ApplyLoanServiceImpl implements ApplyLoanService {
paras.put("channelUserId",channelUserId);
Map<String,String> para7= new HashMap<String,String>();
para7.put("name", "OCR");
para7.put( "organization","1");
para7.put("organization", "1");
ArrayList listPara1 = new ArrayList();
listPara1.add(0,para7);
listPara1.add(0, para7);
paras.put("creditList", listPara1);
String encryptContent = GetEncryptContentAndMd5.getEncryptContent(paras, aesKeywy, md5Keywy);
Map<String,String> content_map = new HashMap<String, String>();
content_map.put("content", encryptContent);
log.info("查看结果content={}", content_map);
JSONObject result = HttpRequest.doPostReturnResponseJson(url, content_map);
return result;
return paras;
}
@Override
public JSONObject shiGuangFenQiApply() {
return null;
......
......@@ -11,7 +11,6 @@ import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus;
import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfChannelConfiguration;
import cn.quantgroup.cashloanflowboss.spi.clf.service.CLFCenterServiceImpl;
import cn.quantgroup.cashloanflowboss.spi.xyqb.entity.LoanApplicationHistory;
import cn.quantgroup.cashloanflowboss.spi.xyqb.entity.QuotaCredit;
import cn.quantgroup.cashloanflowboss.utils.*;
import cn.quantgroup.cashloanflowboss.utils.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
......@@ -73,8 +72,8 @@ public class CashWithdrawalServiceImpl implements CashWithdrawalService{
}else{
result= null;
}
String getDecryption = AESUtil.decryptAfterBase64Decode(result.get("context").toString(), aesKeywy);
String context=result.get("context").toString().trim();
String getDecryption = AESUtil.decryptAfterBase64Decode(context, aesKeywy);
log.info("解密的getDecryption的结果={}" + getDecryption);
JSONObject getDecryptionResult = (JSONObject) JSONObject.parse(getDecryption);
......
......@@ -20,7 +20,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.ArrayList;
import java.util.HashMap;
......
package cn.quantgroup.cashloanflowboss.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.util.Objects;
/**
* AES编码器工具
* 使用AES加密解密 AES-128-ECB加密
* @version 1.0
*/
@Slf4j
public class AESUtil {
/**
......@@ -38,7 +41,8 @@ public class AESUtil {
try {
return encryptAndBase64Encode(data.getBytes(data_encoding), key);
} catch (Exception e) {
e.printStackTrace();
log.info("={}", e);
return null;
}
}
......@@ -51,7 +55,7 @@ public class AESUtil {
*/
public static String encryptAndBase64Encode(byte[] data, String key) {
try {
if (key == null || "".equals(key.trim().length())) {
if (Objects.isNull(key)) {
return null;
}
byte[] raw = key.getBytes(data_encoding);
......@@ -61,7 +65,7 @@ public class AESUtil {
byte[] encrypted = cipher.doFinal(data);
return new Base64().encodeToString(encrypted);
} catch (Exception e) {
e.printStackTrace();
log.info("={}", e);
return null;
}
}
......@@ -79,7 +83,8 @@ public class AESUtil {
return new String(bytes, data_encoding);
}
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
log.info("={}",e);
}
return null;
}
......@@ -104,6 +109,7 @@ public class AESUtil {
return original;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
......
......@@ -94,10 +94,13 @@ public class EnvUtil {
public static String getDsfPath(){
String dsfConfigTmpPath="";
if(DSF_CONFIG_TMP==null){
Assert.fail("����dsf��ʱ�����ļ�ʧ�ܣ�");
}else {
dsfConfigTmpPath =DSF_CONFIG_TMP.getAbsolutePath();
}
return DSF_CONFIG_TMP.getAbsolutePath();
return dsfConfigTmpPath;
}
//
public static String getDubboEnvBySite(String siteName){
......@@ -110,7 +113,8 @@ public class EnvUtil {
Set<Map.Entry<Object, Object>> propertySet = propertys.entrySet();
for (Map.Entry<Object, Object> property : propertySet) {
String propertyKey = property.getKey().toString();
if (propertyKey.toLowerCase().contains(String.format("dubbo.%s.%s.",siteName.toLowerCase(),ciEnv.toLowerCase()))) {
String lowerCase=ciEnv.toLowerCase();
if (propertyKey.toLowerCase().contains(String.format("dubbo.%s.%s.",siteName.toLowerCase(),lowerCase))) {
// �������÷���
env = propertyKey.split("\\.")[2];
break;
......@@ -130,7 +134,8 @@ public class EnvUtil {
Set<Map.Entry<Object, Object>> propertySet = propertys.entrySet();
for (Map.Entry<Object, Object> property : propertySet) {
String propertyKey = property.getKey().toString();
if (propertyKey.toLowerCase().contains(String.format("http.%s.%s.",siteName.toLowerCase(),ciEnv.toLowerCase()))) {
String lowerCase=ciEnv.toLowerCase();
if (propertyKey.toLowerCase().contains(String.format("http.%s.%s.",siteName.toLowerCase(),lowerCase))) {
// �������÷���,�����ַ�������Сд
env = propertyKey.split("\\.")[2];
break;
......
......@@ -135,7 +135,7 @@ public class HttpService {
String result = "";
if (null == urlString || urlString.isEmpty()
|| !urlString.startsWith("http")) {// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
return null;
return resultEntity;
}
CloseableHttpResponse response = null;
......@@ -152,9 +152,9 @@ public class HttpService {
URI uri = new URI(url.getProtocol(), url.getAuthority(), url.getPath(),
url.getQuery(), null);
httpGet = new HttpGet(uri);
System.out.println("请求的uri是:"+uri);
System.out.println("请求的uri是:" + uri);
if(headerInfo!=null)
if(headerInfo!=null && !Objects.isNull(httpGet))
setHttpHeaderInfo(httpGet, headerInfo);
CookieStore cookieStore=new BasicCookieStore();
......@@ -176,7 +176,9 @@ public class HttpService {
} catch (Exception e) {
e.printStackTrace();
}
if(Objects.isNull(response)){
log.info("当前的response对象是空:{}",response);
}else {
result = doResponse(response, urlString);
// 得到响应状态码
int statuCode = response.getStatusLine().getStatusCode();
......@@ -184,6 +186,8 @@ public class HttpService {
resultEntity.setResponseString(result);
resultEntity.setCookies(cookieStore.getCookies());
resultEntity.setStatusCode(response.getStatusLine().getStatusCode());
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
......@@ -209,7 +213,7 @@ public class HttpService {
HttpResultEntity resultEntity=new HttpResultEntity();
String result = "";
if (null == url || url.isEmpty() || !url.startsWith("http")) {// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
return null;
return resultEntity;
}
CloseableHttpResponse response = null;
......@@ -258,13 +262,16 @@ public class HttpService {
}
log.info("进入doResponse方法之前: ");
result = doResponse(response, url);
if(Objects.isNull(response)){
log.info("当前的response对象是空:{}",response);
}else {
result = doResponse(response, url);
resultEntity.setResponseString(result);
resultEntity.setCookies(cookieStore.getCookies());
resultEntity.setStatusCode(response.getStatusLine().getStatusCode());
resultEntity.setResponseString(result);
resultEntity.setCookies(cookieStore.getCookies());
resultEntity.setStatusCode(response.getStatusLine().getStatusCode());
}
} catch (Exception ex) {
ex.printStackTrace();
......@@ -278,7 +285,7 @@ public class HttpService {
HttpResultEntity resultEntity=new HttpResultEntity();
String result = "";
if (null == url || url.isEmpty() || !url.startsWith("http")) {// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
return null;
return resultEntity;
}
CloseableHttpResponse response = null;
......@@ -420,6 +427,8 @@ public class HttpService {
resultEntity.setResponseString(result);
resultEntity.setCookies(cookieStore.getCookies());
resultEntity.setStatusCode(response.getStatusLine().getStatusCode());
} catch (Exception ex) {
ex.printStackTrace();
......@@ -432,7 +441,7 @@ public class HttpService {
HttpResultEntity resultEntity=new HttpResultEntity();
String result = "";
if (null == url || url.isEmpty() || !url.startsWith("http")) {// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
return null;
return resultEntity;
}
CloseableHttpResponse response = null;
......@@ -499,6 +508,7 @@ public class HttpService {
e.printStackTrace();
} finally {
try {
if (!Objects.isNull(instream))
instream.close();
} catch (Exception ignore) {
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment