Commit 66a4fb32 authored by shangying's avatar shangying

sonar问题修改2

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