mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
add:新增webdav相关功能,修复安全隐患
This commit is contained in:
@@ -33,6 +33,7 @@ public class ShiroConfig {
|
||||
filterMap.put("/verifyCodeForRetrieve","anon");
|
||||
filterMap.put("/verifyCodeFortowSendEmail","anon");
|
||||
filterMap.put("/api/**","anon");
|
||||
filterMap.put("/w/**","anon");
|
||||
filterMap.put("/user/**","anon");
|
||||
filterMap.put("/ota/**","anon");
|
||||
filterMap.put("/admin/root/**","roles[admin]");
|
||||
|
||||
@@ -47,7 +47,7 @@ public class IndexController {
|
||||
@Autowired private IRedisService iRedisService;
|
||||
@Autowired private AppClientService appClientService;
|
||||
@Autowired private WebDAVImageupload webDAVImageupload;
|
||||
public static String version = "20240111";
|
||||
public static String version = "20240124";
|
||||
@RequestMapping(value = "/")
|
||||
public String Welcome(Model model, HttpServletRequest httpServletRequest) {
|
||||
model.addAttribute("name", "服务端程序(开源版)");
|
||||
|
||||
@@ -30,22 +30,22 @@ private static final int VALICATE_CODE_LENGTH = 4;
|
||||
* @param height
|
||||
*/
|
||||
private static void fillBackground(Graphics graphics, int width, int height) {
|
||||
// 填充背景
|
||||
graphics.setColor(Color.WHITE);
|
||||
//设置矩形坐标x y 为0
|
||||
graphics.fillRect(0, 0, width, height);
|
||||
// 填充背景
|
||||
graphics.setColor(Color.WHITE);
|
||||
//设置矩形坐标x y 为0
|
||||
graphics.fillRect(0, 0, width, height);
|
||||
|
||||
// 加入干扰线条
|
||||
for (int i = 0; i < 8; i++) {
|
||||
//设置随机颜色算法参数
|
||||
graphics.setColor(RandomUtils.randomColor(40, 150));
|
||||
Random random = new Random();
|
||||
int x = random.nextInt(width);
|
||||
int y = random.nextInt(height);
|
||||
int x1 = random.nextInt(width);
|
||||
int y1 = random.nextInt(height);
|
||||
graphics.drawLine(x, y, x1, y1);
|
||||
}
|
||||
// 加入干扰线条
|
||||
for (int i = 0; i < 8; i++) {
|
||||
//设置随机颜色算法参数
|
||||
graphics.setColor(RandomUtils.randomColor(40, 150));
|
||||
Random random = new Random();
|
||||
int x = random.nextInt(width);
|
||||
int y = random.nextInt(height);
|
||||
int x1 = random.nextInt(width);
|
||||
int y1 = random.nextInt(height);
|
||||
graphics.drawLine(x, y, x1, y1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,15 +59,15 @@ graphics.drawLine(x, y, x1, y1);
|
||||
*/
|
||||
@Override
|
||||
public String generate(int width, int height, OutputStream os) throws IOException {
|
||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics graphics = image.getGraphics();
|
||||
fillBackground(graphics, width, height);
|
||||
String randomStr = RandomUtils.randomString(VALICATE_CODE_LENGTH);
|
||||
createCharacter(graphics, randomStr);
|
||||
graphics.dispose();
|
||||
//设置JPEG格式
|
||||
ImageIO.write(image, "JPEG", os);
|
||||
return randomStr;
|
||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics graphics = image.getGraphics();
|
||||
fillBackground(graphics, width, height);
|
||||
String randomStr = RandomUtils.randomString(VALICATE_CODE_LENGTH);
|
||||
createCharacter(graphics, randomStr);
|
||||
graphics.dispose();
|
||||
//设置JPEG格式
|
||||
ImageIO.write(image, "JPEG", os);
|
||||
return randomStr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,20 +79,20 @@ return randomStr;
|
||||
*/
|
||||
@Override
|
||||
public VerifyCode generate(int width, int height) {
|
||||
VerifyCode verifyCode = null;
|
||||
try (
|
||||
//将流的初始化放到这里就不需要手动关闭流
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
) {
|
||||
String code = generate(width, height, baos);
|
||||
verifyCode = new VerifyCode();
|
||||
verifyCode.setCode(code);
|
||||
verifyCode.setImgBytes(baos.toByteArray());
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
verifyCode = null;
|
||||
}
|
||||
return verifyCode;
|
||||
VerifyCode verifyCode = null;
|
||||
try (
|
||||
//将流的初始化放到这里就不需要手动关闭流
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
) {
|
||||
String code = generate(width, height, baos);
|
||||
verifyCode = new VerifyCode();
|
||||
verifyCode.setCode(code);
|
||||
verifyCode.setImgBytes(baos.toByteArray());
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
verifyCode = null;
|
||||
}
|
||||
return verifyCode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,15 +102,15 @@ return verifyCode;
|
||||
* @param randomStr
|
||||
*/
|
||||
private void createCharacter(Graphics g, String randomStr) {
|
||||
char[] charArray = randomStr.toCharArray();
|
||||
for (int i = 0; i < charArray.length; i++) {
|
||||
//设置RGB颜色算法参数
|
||||
g.setColor(new Color(50 + RandomUtils.nextInt(100),
|
||||
50 + RandomUtils.nextInt(100), 50 + RandomUtils.nextInt(100)));
|
||||
//设置字体大小,类型
|
||||
g.setFont(new Font(FONT_TYPES[RandomUtils.nextInt(FONT_TYPES.length)], Font.BOLD, 26));
|
||||
//设置x y 坐标
|
||||
g.drawString(String.valueOf(charArray[i]), 15 * i + 5, 19 + RandomUtils.nextInt(8));
|
||||
}
|
||||
}
|
||||
char[] charArray = randomStr.toCharArray();
|
||||
for (int i = 0; i < charArray.length; i++) {
|
||||
//设置RGB颜色算法参数
|
||||
g.setColor(new Color(50 + RandomUtils.nextInt(100),
|
||||
50 + RandomUtils.nextInt(100), 50 + RandomUtils.nextInt(100)));
|
||||
//设置字体大小,类型
|
||||
g.setFont(new Font(FONT_TYPES[RandomUtils.nextInt(FONT_TYPES.length)], Font.BOLD, 26));
|
||||
//设置x y 坐标
|
||||
g.drawString(String.valueOf(charArray[i]), 15 * i + 5, 19 + RandomUtils.nextInt(8));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user