You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.2 KiB
31 lines
1.2 KiB
// com.example.demo.config.KaptchaConfig.java
|
|
package com.example.demo.config;
|
|
|
|
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
|
import com.google.code.kaptcha.util.Config;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
import java.util.Properties;
|
|
|
|
@Configuration
|
|
public class KaptchaConfig {
|
|
|
|
@Bean
|
|
public DefaultKaptcha defaultKaptcha() {
|
|
DefaultKaptcha kaptcha = new DefaultKaptcha();
|
|
Properties properties = new Properties();
|
|
properties.setProperty("kaptcha.image.width", "130");
|
|
properties.setProperty("kaptcha.image.height", "45");
|
|
properties.setProperty("kaptcha.textproducer.char.length", "4");
|
|
properties.setProperty("kaptcha.textproducer.font.size", "35");
|
|
properties.setProperty("kaptcha.textproducer.font.color", "black");
|
|
properties.setProperty("kaptcha.textproducer.char.space", "5");
|
|
properties.setProperty("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.WaterRipple");
|
|
properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.DefaultNoise");
|
|
|
|
kaptcha.setConfig(new Config(properties));
|
|
return kaptcha;
|
|
}
|
|
}
|