Commit f2e7f330 authored by zhangsen's avatar zhangsen

漏洞文件bug修改

parent dcef3c7c
package com.yeejoin.amos.fas.core.common.request; package com.yeejoin.amos.fas.core.common.request;
import java.security.SecureRandom;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.ParsePosition; import java.text.ParsePosition;
...@@ -1071,8 +1072,10 @@ public class DateUtil { ...@@ -1071,8 +1072,10 @@ public class DateUtil {
{ {
; ;
} }
long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000); if (null != date && null != mydate) {
return day; return (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
}
return 0;
} }
/** /**
...@@ -1115,7 +1118,7 @@ public class DateUtil { ...@@ -1115,7 +1118,7 @@ public class DateUtil {
*/ */
private static String getRandom(int i) private static String getRandom(int i)
{ {
Random jjj = new Random(); SecureRandom jjj = new SecureRandom();
// int suiJiShu = jjj.nextInt(9); // int suiJiShu = jjj.nextInt(9);
if (i == 0) return ""; if (i == 0) return "";
String jj = ""; String jj = "";
......
...@@ -117,9 +117,17 @@ public class FileController extends BaseController { ...@@ -117,9 +117,17 @@ public class FileController extends BaseController {
ResponseUtils.renderText(response, "File not exists!"); ResponseUtils.renderText(response, "File not exists!");
return; return;
} }
FileInputStream fis = new FileInputStream(file); FileInputStream fis = null;
try {
fis = new FileInputStream(file);
ResponseUtils.downFileByInputStream(file.getName(), fis, response, open); ResponseUtils.downFileByInputStream(file.getName(), fis, response, open);
IOUtils.closeQuietly(fis); } catch (IOException e) {
} finally {
if (null != fis) {
fis.close();
}
}
} }
@Permission @Permission
......
...@@ -69,6 +69,8 @@ public class PlanVisual3dController extends BaseController { ...@@ -69,6 +69,8 @@ public class PlanVisual3dController extends BaseController {
if (testPlan != null) { if (testPlan != null) {
String path = testPlan.getFilePath(); String path = testPlan.getFilePath();
if (path != null && !"".equals(path)) { if (path != null && !"".equals(path)) {
FileInputStream inputStream = null;
InputStream fis = null;
try { try {
// path是指欲下载的文件的路径。 // path是指欲下载的文件的路径。
File file = new File(fileUploadDir + path); File file = new File(fileUploadDir + path);
...@@ -79,10 +81,12 @@ public class PlanVisual3dController extends BaseController { ...@@ -79,10 +81,12 @@ public class PlanVisual3dController extends BaseController {
String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase(); String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase();
// 以流的形式下载文件。 // 以流的形式下载文件。
InputStream fis = new BufferedInputStream(new FileInputStream(fileUploadDir + path)); inputStream = new FileInputStream(fileUploadDir + path);
if (null != inputStream) {
fis = new BufferedInputStream(inputStream);
byte[] buffer = new byte[fis.available()]; byte[] buffer = new byte[fis.available()];
fis.read(buffer); fis.read(buffer);
fis.close();
// 清空response // 清空response
// response.reset(); // response.reset();
// 设置response的Header // 设置response的Header
...@@ -94,11 +98,23 @@ public class PlanVisual3dController extends BaseController { ...@@ -94,11 +98,23 @@ public class PlanVisual3dController extends BaseController {
toClient.write(buffer); toClient.write(buffer);
toClient.flush(); toClient.flush();
toClient.close(); toClient.close();
}
} else { } else {
response.setStatus(404); response.setStatus(404);
} }
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
} finally {
try {
if (null != inputStream) {
inputStream.close();
}
if (null != fis) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
} }
} else { } else {
......
...@@ -35,6 +35,8 @@ public class WeatherController extends BaseController { ...@@ -35,6 +35,8 @@ public class WeatherController extends BaseController {
String result = ""; String result = "";
BufferedReader in = null; BufferedReader in = null;
BufferedReader responseReader = null;
InputStreamReader res = null;
try { try {
String urlNameString = weatherUrl + address; String urlNameString = weatherUrl + address;
URL realUrl = new URL(urlNameString); URL realUrl = new URL(urlNameString);
...@@ -55,12 +57,13 @@ public class WeatherController extends BaseController { ...@@ -55,12 +57,13 @@ public class WeatherController extends BaseController {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
String readLine = new String(); String readLine = new String();
GZIPInputStream gZipS=new GZIPInputStream(connection.getInputStream()); GZIPInputStream gZipS=new GZIPInputStream(connection.getInputStream());
InputStreamReader res = new InputStreamReader(gZipS,"UTF-8"); res = new InputStreamReader(gZipS,"UTF-8");
BufferedReader responseReader = new BufferedReader(res); responseReader = new BufferedReader(res);
while ((readLine = responseReader.readLine()) != null) { while ((readLine = responseReader.readLine()) != null) {
sb.append(readLine); sb.append(readLine);
} }
responseReader.close();
result = sb.toString(); result = sb.toString();
System.out.println(result); System.out.println(result);
...@@ -75,6 +78,12 @@ public class WeatherController extends BaseController { ...@@ -75,6 +78,12 @@ public class WeatherController extends BaseController {
if (in != null) { if (in != null) {
in.close(); in.close();
} }
if (null != responseReader) {
responseReader.close();
}
if (null != res) {
res.close();
}
} catch (Exception e2) { } catch (Exception e2) {
e2.printStackTrace(); e2.printStackTrace();
} }
......
...@@ -161,9 +161,9 @@ public class EquipmentFireEquipmentServiceImpl implements IEquipmentFireEquipmen ...@@ -161,9 +161,9 @@ public class EquipmentFireEquipmentServiceImpl implements IEquipmentFireEquipmen
} }
} }
} }
if (!CollectionUtils.isEmpty(map)) { if (null != map &&!CollectionUtils.isEmpty(map)) {
Integer total = Integer.parseInt(map.get("total").toString()); Integer total = Integer.parseInt(map.getOrDefault("total", 0).toString());
Integer count = Integer.parseInt(map.get("count").toString()); Integer count = Integer.parseInt(map.getOrDefault("count", 0).toString());
if (SqlKeyWordEnum.AND.getKey().equalsIgnoreCase(type)) { if (SqlKeyWordEnum.AND.getKey().equalsIgnoreCase(type)) {
return total.equals(count); return total.equals(count);
} else if (SqlKeyWordEnum.OR.getKey().equalsIgnoreCase(type)) { } else if (SqlKeyWordEnum.OR.getKey().equalsIgnoreCase(type)) {
......
...@@ -325,7 +325,7 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -325,7 +325,7 @@ public class EquipmentServiceImpl implements IEquipmentService {
if(date.isPresent()){ if(date.isPresent()){
equipment2=date.get(); equipment2=date.get();
} }
equipment.setCreateDate(equipment2.getCreateDate()); equipment.setCreateDate(null != equipment2 ? equipment2.getCreateDate() : new Date());
} }
preplanPictureDao.saveAndFlush(pp); preplanPictureDao.saveAndFlush(pp);
...@@ -369,8 +369,7 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -369,8 +369,7 @@ public class EquipmentServiceImpl implements IEquipmentService {
if(date.isPresent()){ if(date.isPresent()){
equipment2=date.get(); equipment2=date.get();
} }
equipment.setCreateDate(null != equipment2 && null != equipment2.getCreateDate() ? equipment2.getCreateDate() : new Date());
equipment.setCreateDate(equipment2.getCreateDate() == null ? new Date() : equipment2.getCreateDate());
} }
} else { } else {
equipment = save(equipment); equipment = save(equipment);
...@@ -382,7 +381,7 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -382,7 +381,7 @@ public class EquipmentServiceImpl implements IEquipmentService {
equipment2=date.get(); equipment2=date.get();
} }
equipment.setCreateDate(equipment2.getCreateDate() == null ? new Date() : equipment2.getCreateDate()); equipment.setCreateDate(null != equipment2 && null != equipment2.getCreateDate() ? equipment2.getCreateDate() : new Date());
} }
Long equipmentId = Long.valueOf(equipment.getId()); Long equipmentId = Long.valueOf(equipment.getId());
for (int i = 0; i < imgs.length; i++) { for (int i = 0; i < imgs.length; i++) {
......
...@@ -210,6 +210,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -210,6 +210,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource.setStatus(FasConstant.RISK_SOURCE_STATUS_NORMAL); riskSource.setStatus(FasConstant.RISK_SOURCE_STATUS_NORMAL);
riskSource.setCreateDate(new Date()); riskSource.setCreateDate(new Date());
} else {// 更新 } else {// 更新
if (null != oldRiskSource) {
riskSource.setCreateDate(oldRiskSource.getCreateDate()); riskSource.setCreateDate(oldRiskSource.getCreateDate());
riskSource.setFmeaList(oldRiskSource.getFmeaList()); riskSource.setFmeaList(oldRiskSource.getFmeaList());
riskSource.setIncrement(oldRiskSource.getIncrement()); riskSource.setIncrement(oldRiskSource.getIncrement());
...@@ -218,6 +219,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -218,6 +219,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource.setRpni(oldRiskSource.getRpni()); riskSource.setRpni(oldRiskSource.getRpni());
riskSource.setStatus(oldRiskSource.getStatus()); riskSource.setStatus(oldRiskSource.getStatus());
} }
}
iRiskSourceDao.saveAndFlush(riskSource); iRiskSourceDao.saveAndFlush(riskSource);
return riskSource; return riskSource;
} }
......
...@@ -97,36 +97,48 @@ public class DesUtil { ...@@ -97,36 +97,48 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = bt; tempBt = bt;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) { for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
} }
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) { for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
} }
}
if (null != thirdKeyBt) {
for (z = 0; z < thirdLength; z++) { for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z)); tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
} }
}
encByte = tempBt; encByte = tempBt;
} else { } else {
if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") { if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") {
int[] tempBt; int[] tempBt;
int x, y; int x, y;
tempBt = bt; tempBt = bt;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) { for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
} }
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) { for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
} }
}
encByte = tempBt; encByte = tempBt;
} else { } else {
if (firstKey != null && firstKey != "") { if (firstKey != null && firstKey != "") {
int[] tempBt; int[] tempBt;
int x = 0; int x = 0;
tempBt = bt; tempBt = bt;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) { for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
} }
}
encByte = tempBt; encByte = tempBt;
} }
} }
...@@ -144,36 +156,48 @@ public class DesUtil { ...@@ -144,36 +156,48 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = tempByte; tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) { for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
} }
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) { for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
} }
}
if (null != thirdKeyBt) {
for (z = 0; z < thirdLength; z++) { for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z)); tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
} }
}
encByte = tempBt; encByte = tempBt;
} else { } else {
if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") { if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") {
int[] tempBt; int[] tempBt;
int x, y; int x, y;
tempBt = tempByte; tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) { for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
} }
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) { for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
} }
}
encByte = tempBt; encByte = tempBt;
} else { } else {
if (firstKey != null && firstKey != "") { if (firstKey != null && firstKey != "") {
int[] tempBt; int[] tempBt;
int x; int x;
tempBt = tempByte; tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) { for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
} }
}
encByte = tempBt; encByte = tempBt;
} }
} }
...@@ -188,36 +212,48 @@ public class DesUtil { ...@@ -188,36 +212,48 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = tempByte; tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) { for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
} }
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) { for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
} }
}
if (null != thirdKeyBt) {
for (z = 0; z < thirdLength; z++) { for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z)); tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
} }
}
encByte = tempBt; encByte = tempBt;
} else { } else {
if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") { if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") {
int[] tempBt; int[] tempBt;
int x, y; int x, y;
tempBt = tempByte; tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) { for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
} }
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) { for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
} }
}
encByte = tempBt; encByte = tempBt;
} else { } else {
if (firstKey != null && firstKey != "") { if (firstKey != null && firstKey != "") {
int[] tempBt; int[] tempBt;
int x; int x;
tempBt = tempByte; tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) { for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
} }
}
encByte = tempBt; encByte = tempBt;
} }
} }
...@@ -267,36 +303,48 @@ public class DesUtil { ...@@ -267,36 +303,48 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = intByte; tempBt = intByte;
if (null != thirdKeyBt) {
for (x = thirdLength - 1; x >= 0; x--) { for (x = thirdLength - 1; x >= 0; x--) {
tempBt = dec(tempBt, (int[]) thirdKeyBt.get(x)); tempBt = dec(tempBt, (int[]) thirdKeyBt.get(x));
} }
}
if (null != secondKeyBt) {
for (y = secondLength - 1; y >= 0; y--) { for (y = secondLength - 1; y >= 0; y--) {
tempBt = dec(tempBt, (int[]) secondKeyBt.get(y)); tempBt = dec(tempBt, (int[]) secondKeyBt.get(y));
} }
}
if (null != firstKeyBt) {
for (z = firstLength - 1; z >= 0; z--) { for (z = firstLength - 1; z >= 0; z--) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(z)); tempBt = dec(tempBt, (int[]) firstKeyBt.get(z));
} }
}
decByte = tempBt; decByte = tempBt;
} else { } else {
if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") { if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = intByte; tempBt = intByte;
if (null != secondKeyBt) {
for (x = secondLength - 1; x >= 0; x--) { for (x = secondLength - 1; x >= 0; x--) {
tempBt = dec(tempBt, (int[]) secondKeyBt.get(x)); tempBt = dec(tempBt, (int[]) secondKeyBt.get(x));
} }
}
if (null != firstKeyBt) {
for (y = firstLength - 1; y >= 0; y--) { for (y = firstLength - 1; y >= 0; y--) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(y)); tempBt = dec(tempBt, (int[]) firstKeyBt.get(y));
} }
}
decByte = tempBt; decByte = tempBt;
} else { } else {
if (firstKey != null && firstKey != "") { if (firstKey != null && firstKey != "") {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = intByte; tempBt = intByte;
if (null != firstKeyBt) {
for (x = firstLength - 1; x >= 0; x--) { for (x = firstLength - 1; x >= 0; x--) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(x)); tempBt = dec(tempBt, (int[]) firstKeyBt.get(x));
} }
}
decByte = tempBt; decByte = tempBt;
} }
} }
......
...@@ -62,10 +62,14 @@ public class FileUtils { ...@@ -62,10 +62,14 @@ public class FileUtils {
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} finally { } finally {
if (null != br) {
br.close(); br.close();
}
if (null != out) {
out.close(); out.close();
} }
} }
}
/** /**
* 通过文件服务器——>获取流——>输出——>压缩 * 通过文件服务器——>获取流——>输出——>压缩
......
package com.yeejoin.amos.fas.business.util; package com.yeejoin.amos.fas.business.util;
import java.security.SecureRandom;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Random; import java.util.Random;
...@@ -12,7 +13,7 @@ public class RandomUtil { ...@@ -12,7 +13,7 @@ public class RandomUtil {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String newDate = sdf.format(new Date()); String newDate = sdf.format(new Date());
String result = ""; String result = "";
Random random = new Random(); SecureRandom random = new SecureRandom();
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
result += random.nextInt(10); result += random.nextInt(10);
} }
......
...@@ -402,8 +402,10 @@ public static Time formatStrToTime(String strDate){ ...@@ -402,8 +402,10 @@ public static Time formatStrToTime(String strDate){
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
Time date = new Time(d.getTime()); if (null != d) {
return date; return new Time(d.getTime());
}
return null;
} }
/** /**
......
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