fix
This commit is contained in:
parent
90750ac3b9
commit
d003b1d971
@ -5,7 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.sunyard.chsm.utils.JsonUtils;
|
||||
import com.sunyard.ssp.common.Result;
|
||||
import com.sunyard.ssp.constv.Alg;
|
||||
import com.sunyard.ssp.modules.monitor.log.entity.AuditLog;
|
||||
@ -19,7 +19,6 @@ import com.sunyard.ssp.modules.user.entity.UkeyLoginParm;
|
||||
import com.sunyard.ssp.modules.user.service.IScUserRoleService;
|
||||
import com.sunyard.ssp.modules.user.service.IScUserService;
|
||||
import com.sunyard.ssp.util.BytesUtil;
|
||||
import com.sunyard.ssp.utils.FileUtil;
|
||||
import com.sunyard.ssp.utils.IpUtil;
|
||||
import com.sunyard.ssp.utils.ResultUtil;
|
||||
import com.sunyard.ssp.utils.SecurityUtil;
|
||||
@ -31,8 +30,14 @@ import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@ -41,12 +46,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
@ -81,17 +82,10 @@ public class ScUShieldController {
|
||||
@Autowired
|
||||
private SecurityUtil securityUtil;
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;
|
||||
|
||||
@Autowired
|
||||
private FileUtil fileUtil;
|
||||
|
||||
@Autowired
|
||||
private IParamConfService iParamConfService;
|
||||
@Autowired
|
||||
private SdkApiService sdkApiService;
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@Autowired
|
||||
private IAuditLogService auditLogService;
|
||||
|
||||
@ -118,7 +112,7 @@ public class ScUShieldController {
|
||||
UkeyLoginParm ukeyLoginParm = new UkeyLoginParm(loginDto.getRa(), loginDto.getRb(), loginDto.getSignInfo(), loginDto.getUserId(), loginDto.getSignData(), loginDto.getRa() + loginDto.getRb() + loginDto.getSignData());
|
||||
list.add(ukeyLoginParm);
|
||||
}
|
||||
auditLog.setRequestParam(mapper.writeValueAsString(list));
|
||||
auditLog.setRequestParam(JsonUtils.toJsonString(list));
|
||||
//Ip信息
|
||||
auditLog.setIpAddress(IpUtil.getIpAddress(request));
|
||||
auditLog.setIpInfo("未知");
|
||||
@ -394,38 +388,24 @@ public class ScUShieldController {
|
||||
|
||||
@RequestMapping(value = "/dowloadFile", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "下载U盾插件接口")
|
||||
public void dowloadFile(@RequestParam("fileName") @ApiParam(value = "文件名") String fileName,
|
||||
HttpServletResponse response) {
|
||||
String url = filePath + "/" + fileName;
|
||||
File file = new File(url);
|
||||
FileInputStream i = null;
|
||||
OutputStream o = null;
|
||||
try {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (file.exists()) {
|
||||
try {
|
||||
i = new FileInputStream(file);
|
||||
o = response.getOutputStream();
|
||||
public ResponseEntity<Resource> dowloadFile(@RequestParam("fileName") @ApiParam(value = "文件名") String fileName) {
|
||||
try (InputStream is = getClass().getResourceAsStream("/files/" + fileName)) {
|
||||
Assert.notNull(is, "文件不存在");
|
||||
byte[] bytes = FileCopyUtils.copyToByteArray(is);
|
||||
// 设置下载响应的 headers
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + URLEncoder.encode(fileName, "UTF-8") + "\"");
|
||||
|
||||
byte[] buf = new byte[1024];
|
||||
int bytesRead;
|
||||
|
||||
while ((bytesRead = i.read(buf)) > 0) {
|
||||
o.write(buf, 0, bytesRead);
|
||||
o.flush();
|
||||
}
|
||||
|
||||
i.close();
|
||||
o.close();
|
||||
// 返回带文件内容的响应
|
||||
return ResponseEntity.ok()
|
||||
.headers(headers)
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.body(new ByteArrayResource(bytes));
|
||||
} catch (IOException e) {
|
||||
log.error(e.toString());
|
||||
throw new RuntimeException("读取文件出错");
|
||||
}
|
||||
}
|
||||
log.error("", e);
|
||||
throw new IllegalArgumentException("读取文件出错");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public class SM2Util {
|
||||
ECPublicKeyParameters pubKey = BCECUtils.createECPublicKeyParameters(xHex, yHex, SM2Util.CURVE, SM2Util.DOMAIN_PARAMS);
|
||||
|
||||
|
||||
byte[] s = com.sunyard.ssp.util.BytesUtil.decodeBase64( sign );
|
||||
byte[] s = Base64.getDecoder().decode( sign );
|
||||
log.info( com.sunyard.ssp.util.BytesUtil.bytes2HexString( s ) );
|
||||
|
||||
|
||||
|
@ -109,7 +109,6 @@ captcha:
|
||||
# 忽略鉴权url
|
||||
ignored:
|
||||
urls:
|
||||
- /**
|
||||
- /common/captcha/**
|
||||
- /swagger/**
|
||||
- /**/v2/api-docs
|
||||
|
BIN
chsm-web-manage/src/main/resources/files/Setup_V1.0.1.exe
Normal file
BIN
chsm-web-manage/src/main/resources/files/Setup_V1.0.1.exe
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user