Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yaru
fgqyxxlr
Commits
fcde7155
Commit
fcde7155
authored
Jul 14, 2019
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
验证码参数调整
parent
08ca506c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
29 deletions
+27
-29
ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java
+25
-28
ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java
+2
-1
No files found.
ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java
View file @
fcde7155
...
...
@@ -5,6 +5,7 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
com.google.code.kaptcha.impl.DefaultKaptcha
;
import
com.google.code.kaptcha.util.Config
;
import
static
com
.
google
.
code
.
kaptcha
.
Constants
.*;
/**
* 验证码配置
...
...
@@ -20,27 +21,23 @@ public class CaptchaConfig
DefaultKaptcha
defaultKaptcha
=
new
DefaultKaptcha
();
Properties
properties
=
new
Properties
();
// 是否有边框 默认为true 我们可以自己设置yes,no
properties
.
setProperty
(
"kaptcha.border"
,
"yes"
);
// 边框颜色 默认为Color.BLACK
properties
.
setProperty
(
"kaptcha.border.color"
,
"105,179,90"
);
properties
.
setProperty
(
KAPTCHA_BORDER
,
"yes"
);
// 验证码文本字符颜色 默认为Color.BLACK
properties
.
setProperty
(
"kaptcha.textproducer.font.color"
,
"blue
"
);
properties
.
setProperty
(
KAPTCHA_TEXTPRODUCER_FONT_COLOR
,
"black
"
);
// 验证码图片宽度 默认为200
properties
.
setProperty
(
"kaptcha.image.width"
,
"160"
);
properties
.
setProperty
(
KAPTCHA_IMAGE_WIDTH
,
"160"
);
// 验证码图片高度 默认为50
properties
.
setProperty
(
"kaptcha.image.height"
,
"60"
);
properties
.
setProperty
(
KAPTCHA_IMAGE_HEIGHT
,
"60"
);
// 验证码文本字符大小 默认为40
properties
.
setProperty
(
"kaptcha.textproducer.font.size"
,
"30
"
);
properties
.
setProperty
(
KAPTCHA_TEXTPRODUCER_FONT_SIZE
,
"38
"
);
// KAPTCHA_SESSION_KEY
properties
.
setProperty
(
"kaptcha.session.key"
,
"kaptchaCode"
);
// 验证码文本字符间距 默认为2
properties
.
setProperty
(
"kaptcha.textproducer.char.space"
,
"3"
);
properties
.
setProperty
(
KAPTCHA_SESSION_CONFIG_KEY
,
"kaptchaCode"
);
// 验证码文本字符长度 默认为5
properties
.
setProperty
(
"kaptcha.textproducer.char.length"
,
"5
"
);
properties
.
setProperty
(
KAPTCHA_TEXTPRODUCER_CHAR_LENGTH
,
"4
"
);
// 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
properties
.
setProperty
(
"kaptcha.textproducer.font.names"
,
"Arial,Courier"
);
//
验证码噪点颜色 默认为Color.BLACK
properties
.
setProperty
(
"kaptcha.noise.color"
,
"white
"
);
properties
.
setProperty
(
KAPTCHA_TEXTPRODUCER_FONT_NAMES
,
"Arial,Courier"
);
//
图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
properties
.
setProperty
(
KAPTCHA_OBSCURIFICATOR_IMPL
,
"com.google.code.kaptcha.impl.ShadowGimpy
"
);
Config
config
=
new
Config
(
properties
);
defaultKaptcha
.
setConfig
(
config
);
return
defaultKaptcha
;
...
...
@@ -52,33 +49,33 @@ public class CaptchaConfig
DefaultKaptcha
defaultKaptcha
=
new
DefaultKaptcha
();
Properties
properties
=
new
Properties
();
// 是否有边框 默认为true 我们可以自己设置yes,no
properties
.
setProperty
(
"kaptcha.border"
,
"yes"
);
properties
.
setProperty
(
KAPTCHA_BORDER
,
"yes"
);
// 边框颜色 默认为Color.BLACK
properties
.
setProperty
(
"kaptcha.border.color"
,
"105,179,90"
);
properties
.
setProperty
(
KAPTCHA_BORDER_COLOR
,
"105,179,90"
);
// 验证码文本字符颜色 默认为Color.BLACK
properties
.
setProperty
(
"kaptcha.textproducer.font.color"
,
"blue"
);
properties
.
setProperty
(
KAPTCHA_TEXTPRODUCER_FONT_COLOR
,
"blue"
);
// 验证码图片宽度 默认为200
properties
.
setProperty
(
"kaptcha.image.width"
,
"160"
);
properties
.
setProperty
(
KAPTCHA_IMAGE_WIDTH
,
"160"
);
// 验证码图片高度 默认为50
properties
.
setProperty
(
"kaptcha.image.height"
,
"60"
);
properties
.
setProperty
(
KAPTCHA_IMAGE_HEIGHT
,
"60"
);
// 验证码文本字符大小 默认为40
properties
.
setProperty
(
"kaptcha.textproducer.font.size"
,
"35"
);
properties
.
setProperty
(
KAPTCHA_TEXTPRODUCER_FONT_SIZE
,
"35"
);
// KAPTCHA_SESSION_KEY
properties
.
setProperty
(
"kaptcha.session.key"
,
"kaptchaCodeMath"
);
properties
.
setProperty
(
KAPTCHA_SESSION_CONFIG_KEY
,
"kaptchaCodeMath"
);
// 验证码文本生成器
properties
.
setProperty
(
"kaptcha.textproducer.impl"
,
"com.ruoyi.framework.config.KaptchaTextCreator"
);
properties
.
setProperty
(
KAPTCHA_TEXTPRODUCER_IMPL
,
"com.ruoyi.framework.config.KaptchaTextCreator"
);
// 验证码文本字符间距 默认为2
properties
.
setProperty
(
"kaptcha.textproducer.char.space"
,
"3"
);
properties
.
setProperty
(
KAPTCHA_TEXTPRODUCER_CHAR_SPACE
,
"3"
);
// 验证码文本字符长度 默认为5
properties
.
setProperty
(
"kaptcha.textproducer.char.length"
,
"6"
);
properties
.
setProperty
(
KAPTCHA_TEXTPRODUCER_CHAR_LENGTH
,
"6"
);
// 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
properties
.
setProperty
(
"kaptcha.textproducer.font.names"
,
"Arial,Courier"
);
properties
.
setProperty
(
KAPTCHA_TEXTPRODUCER_FONT_NAMES
,
"Arial,Courier"
);
// 验证码噪点颜色 默认为Color.BLACK
properties
.
setProperty
(
"kaptcha.noise.color"
,
"white"
);
properties
.
setProperty
(
KAPTCHA_NOISE_COLOR
,
"white"
);
// 干扰实现类
properties
.
setProperty
(
"kaptcha.noise.impl"
,
"com.google.code.kaptcha.impl.NoNoise"
);
properties
.
setProperty
(
KAPTCHA_NOISE_IMPL
,
"com.google.code.kaptcha.impl.NoNoise"
);
// 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
properties
.
setProperty
(
"kaptcha.obscurificator.impl"
,
"com.google.code.kaptcha.impl.ShadowGimpy"
);
properties
.
setProperty
(
KAPTCHA_OBSCURIFICATOR_IMPL
,
"com.google.code.kaptcha.impl.ShadowGimpy"
);
Config
config
=
new
Config
(
properties
);
defaultKaptcha
.
setConfig
(
config
);
return
defaultKaptcha
;
...
...
ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java
View file @
fcde7155
package
com
.
ruoyi
.
framework
.
config
;
import
java.security.SecureRandom
;
import
java.util.Random
;
import
com.google.code.kaptcha.text.impl.DefaultTextCreator
;
...
...
@@ -16,7 +17,7 @@ public class KaptchaTextCreator extends DefaultTextCreator
public
String
getText
()
{
Integer
result
=
0
;
Random
random
=
new
Random
();
Random
random
=
new
Secure
Random
();
int
x
=
random
.
nextInt
(
10
);
int
y
=
random
.
nextInt
(
10
);
StringBuilder
suChinese
=
new
StringBuilder
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment