按照规范修改代码
This commit is contained in:
+5
@@ -6,5 +6,10 @@ import org.springframework.security.core.userdetails.User;
|
||||
* 用于根据spring security传入的username获取用户的详细信息接口
|
||||
*/
|
||||
public interface UserService {
|
||||
/**
|
||||
*
|
||||
* @param username
|
||||
* @return user
|
||||
*/
|
||||
User getUserByUsername(String username);
|
||||
}
|
||||
|
||||
+3
@@ -5,6 +5,9 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@EnableConfigurationProperties(SecurityProperties.class)
|
||||
|
||||
+1
@@ -6,6 +6,7 @@ import org.hibernate.validator.constraints.NotBlank;
|
||||
/**
|
||||
* 浏览器身份认证配置参数
|
||||
* 配合SecurityProperties中的Valid注解进行参数合法性校验
|
||||
* @author lsy
|
||||
*/
|
||||
public class BrowserProperties {
|
||||
|
||||
|
||||
+1
@@ -2,6 +2,7 @@ package com.micro.fast.security.core.browser.constant;
|
||||
|
||||
/**
|
||||
* 用户进行身份认证后返回的类型
|
||||
* @author lsy
|
||||
*/
|
||||
public enum LoginType {
|
||||
/**
|
||||
|
||||
+1
@@ -8,6 +8,7 @@ import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 用于从application.yml配置文件中加载以ms.security为前缀的配置属性, ms spring security 配置参数
|
||||
* @author lsy
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "ms.security")
|
||||
public class SecurityProperties {
|
||||
|
||||
+1
@@ -13,6 +13,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 验证码实现类的配置
|
||||
* @author lsy
|
||||
*/
|
||||
@Configuration
|
||||
public class ValidateCodeBean {
|
||||
|
||||
+1
@@ -2,6 +2,7 @@ package com.micro.fast.security.core.validate.code.config.param;
|
||||
|
||||
/**
|
||||
* 图形验证码默认的配置
|
||||
* @author lsy
|
||||
*/
|
||||
public class ImageCodeProperties extends SmsCodeProperties{
|
||||
/**
|
||||
|
||||
+3
@@ -1,5 +1,8 @@
|
||||
package com.micro.fast.security.core.validate.code.config.param;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
public class SmsCodeProperties {
|
||||
|
||||
/**
|
||||
|
||||
+1
@@ -2,6 +2,7 @@ package com.micro.fast.security.core.validate.code.config.param;
|
||||
|
||||
/**
|
||||
* 验证码配置参数
|
||||
* @author lsy
|
||||
*/
|
||||
public class ValidateCodeProperties {
|
||||
|
||||
|
||||
+1
@@ -2,6 +2,7 @@ package com.micro.fast.security.core.validate.code.constant;
|
||||
|
||||
/**
|
||||
* 验证码校验常量类
|
||||
* @author lsy
|
||||
*/
|
||||
public class ValidateCodeConst {
|
||||
/**
|
||||
|
||||
+1
-10
@@ -1,23 +1,13 @@
|
||||
package com.micro.fast.security.core.validate.code.controller;
|
||||
|
||||
import com.micro.fast.security.core.master.SecurityProperties;
|
||||
import com.micro.fast.security.core.validate.code.constant.ValidateCodeConst;
|
||||
import com.micro.fast.security.core.validate.code.pojo.ImageCode;
|
||||
import com.micro.fast.security.core.validate.code.pojo.ValidateCode;
|
||||
import com.micro.fast.security.core.validate.code.processor.ValidateCodeProcessor;
|
||||
import com.micro.fast.security.core.validate.code.service.SendSmsCode;
|
||||
import com.micro.fast.security.core.validate.code.util.ValidateCodeUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.social.connect.web.HttpSessionSessionStrategy;
|
||||
import org.springframework.social.connect.web.SessionStrategy;
|
||||
import org.springframework.web.bind.ServletRequestBindingException;
|
||||
import org.springframework.web.bind.ServletRequestUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -25,6 +15,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* 图片验证码控制层
|
||||
* @author lsy
|
||||
*/
|
||||
@RestController
|
||||
public class ValidateCodeController {
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 图片验证码
|
||||
* @author lsy
|
||||
*/
|
||||
public class ImageCode extends ValidateCode implements Serializable{
|
||||
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
* @author lsy
|
||||
*/
|
||||
public class ValidateCode implements Serializable{
|
||||
|
||||
|
||||
+3
@@ -2,6 +2,9 @@ package com.micro.fast.security.core.validate.code.service.impl;
|
||||
|
||||
import com.micro.fast.security.core.validate.code.service.SendSmsCode;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
public class DefaultSendSmsCodeImpl implements SendSmsCode {
|
||||
|
||||
@Override
|
||||
|
||||
+7
-5
@@ -36,7 +36,8 @@ public class ImageCodeUtil implements ValidateCodeUtil{
|
||||
g.fillRect(0, 0, width, height);
|
||||
g.setFont(new Font("Times New Roman", Font.ITALIC, 20));
|
||||
g.setColor(getRandColor(160, 200));
|
||||
for (int i = 0; i < 155; i++) {
|
||||
int i1 = 155;
|
||||
for (int i = 0; i < i1; i++) {
|
||||
int x = random.nextInt(width);
|
||||
int y = random.nextInt(height);
|
||||
int xl = random.nextInt(12);
|
||||
@@ -65,11 +66,12 @@ public class ImageCodeUtil implements ValidateCodeUtil{
|
||||
*/
|
||||
private Color getRandColor(int fc, int bc) {
|
||||
Random random = new Random();
|
||||
if (fc > 255) {
|
||||
fc = 255;
|
||||
int i = 255;
|
||||
if (fc > i) {
|
||||
fc = i;
|
||||
}
|
||||
if (bc > 255) {
|
||||
bc = 255;
|
||||
if (bc > i) {
|
||||
bc = i;
|
||||
}
|
||||
int r = fc + random.nextInt(bc - fc);
|
||||
int g = fc + random.nextInt(bc - fc);
|
||||
|
||||
+3
@@ -5,6 +5,9 @@ import com.micro.fast.security.core.validate.code.pojo.ValidateCode;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
*/
|
||||
public class SmsCodeUtil implements ValidateCodeUtil {
|
||||
|
||||
private SecurityProperties securityProperties;
|
||||
|
||||
+1
-3
@@ -13,8 +13,6 @@ import javax.validation.ConstraintValidatorContext;
|
||||
@Component
|
||||
public class MyConstrainValidator implements ConstraintValidator<MyContraint,String> {
|
||||
|
||||
//@Autowired 注入Service
|
||||
//private String name;
|
||||
@Override
|
||||
public void initialize(MyContraint myContraint) {
|
||||
System.out.println("初始化校验器");
|
||||
@@ -22,7 +20,7 @@ public class MyConstrainValidator implements ConstraintValidator<MyContraint,Str
|
||||
|
||||
@Override
|
||||
public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
|
||||
//校验的逻辑
|
||||
//校验的逻辑
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user