swagger and encrypt
This commit is contained in:
parent
0022bd1b3a
commit
e5e6235bae
|
|
@ -115,11 +115,13 @@ public class SecurityUtils
|
||||||
return passwordEncoder.matches(rawPassword, encodedPassword);
|
return passwordEncoder.matches(rawPassword, encodedPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
//$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2
|
||||||
String msg= encryptPassword("Admin@1234");
|
//$2a$10$zvlw3Mu8M.j.MhAChrYwluj88ziX6lVD3AoRrBQpwKMcdIZvKMoR2
|
||||||
|
// String msg= encryptPassword("Admin@1234");
|
||||||
|
String msg= encryptPassword("admin123");
|
||||||
|
boolean rest = matchesPassword("admin123","$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2");
|
||||||
System.err.println(msg);
|
System.err.println(msg);
|
||||||
|
System.err.println(rest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
||||||
{
|
{
|
||||||
private final static String[] VALIDATE_URL = new String[] { "/auth/login", "/auth/register" };
|
private final static String[] VALIDATE_URL = new String[] { "/auth/login", "/auth/register" };
|
||||||
|
|
||||||
@Value("${system.decryptEnabled}")
|
@Value("${system.encryptEnabled}")
|
||||||
public boolean jaData;
|
public boolean encryptEnabled;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ValidateCodeService validateCodeService;
|
private ValidateCodeService validateCodeService;
|
||||||
|
|
@ -72,7 +72,7 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), e.getMessage(),jaData);
|
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), e.getMessage(),encryptEnabled);
|
||||||
}
|
}
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,8 @@ import reactor.core.publisher.Mono;
|
||||||
@Configuration
|
@Configuration
|
||||||
public class GatewayExceptionHandler implements ErrorWebExceptionHandler
|
public class GatewayExceptionHandler implements ErrorWebExceptionHandler
|
||||||
{
|
{
|
||||||
@Value("${system.decryptEnabled}")
|
@Value("${system.encryptEnabled}")
|
||||||
public boolean jaData;
|
public boolean encryptEnabled;
|
||||||
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(GatewayExceptionHandler.class);
|
private static final Logger log = LoggerFactory.getLogger(GatewayExceptionHandler.class);
|
||||||
|
|
||||||
|
|
@ -56,6 +55,6 @@ public class GatewayExceptionHandler implements ErrorWebExceptionHandler
|
||||||
|
|
||||||
log.error("[网关异常处理]请求路径:{},异常信息:{}", exchange.getRequest().getPath(), ex.getMessage());
|
log.error("[网关异常处理]请求路径:{},异常信息:{}", exchange.getRequest().getPath(), ex.getMessage());
|
||||||
|
|
||||||
return ServletUtils.webFluxResponseWriter(response, msg,jaData);
|
return ServletUtils.webFluxResponseWriter(response, msg, encryptEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -16,12 +16,12 @@ import reactor.core.publisher.Mono;
|
||||||
*/
|
*/
|
||||||
public class SentinelFallbackHandler implements WebExceptionHandler
|
public class SentinelFallbackHandler implements WebExceptionHandler
|
||||||
{
|
{
|
||||||
@Value("${system.decryptEnabled}")
|
@Value("${system.encryptEnabled}")
|
||||||
public boolean jaData;
|
public boolean encryptEnabled;
|
||||||
|
|
||||||
private Mono<Void> writeResponse(ServerResponse response, ServerWebExchange exchange)
|
private Mono<Void> writeResponse(ServerResponse response, ServerWebExchange exchange)
|
||||||
{
|
{
|
||||||
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), "请求超过最大数,请稍候再试",jaData);
|
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), "请求超过最大数,请稍候再试",encryptEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
package com.bonus.file.controller;
|
package com.bonus.file.controller;
|
||||||
|
|
||||||
import com.bonus.common.core.utils.Base64Utils;
|
import com.bonus.common.core.utils.Base64Utils;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -22,6 +26,7 @@ import java.io.IOException;
|
||||||
* @author bonus
|
* @author bonus
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
@Api("服务文件存储")
|
||||||
public class SysFileController
|
public class SysFileController
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
|
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
|
||||||
|
|
@ -33,6 +38,7 @@ public class SysFileController
|
||||||
* 文件上传请求
|
* 文件上传请求
|
||||||
*/
|
*/
|
||||||
@PostMapping("upload")
|
@PostMapping("upload")
|
||||||
|
@ApiOperation("上传本地文件到服务器")
|
||||||
public R<SysFile> upload(MultipartFile file)
|
public R<SysFile> upload(MultipartFile file)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -51,7 +57,13 @@ public class SysFileController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/download")
|
@GetMapping("/download")
|
||||||
|
@ApiOperation("从服务器下载文件")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "url", value = "文件网络地址", required = true),
|
||||||
|
@ApiImplicitParam(name = "destination", value = "下载的本地路径", required = true),
|
||||||
|
})
|
||||||
public R<Boolean> downloadFile(String url, String destination) {
|
public R<Boolean> downloadFile(String url, String destination) {
|
||||||
try {
|
try {
|
||||||
String fileUrl = Base64Utils.decodeUrl(url);
|
String fileUrl = Base64Utils.decodeUrl(url);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue