|
@@ -13,6 +13,7 @@ import javax.imageio.ImageIO;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.util.FileCopyUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -21,7 +22,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import com.xt.js.gkaq.common.BaseCtl;
|
|
|
-import com.xt.js.gkaq.common.GlobalData;
|
|
|
+import com.xt.js.gkaq.frame.system.CaptchaValidateFilter;
|
|
|
|
|
|
/**
|
|
|
* 控制器
|
|
@@ -38,8 +39,7 @@ public class AuthenticateController extends BaseCtl {
|
|
|
|
|
|
@RequestMapping(value = "checkcode")
|
|
|
@ResponseBody
|
|
|
- public void checkcode(@RequestParam(value = "checkcode", required = false) String checkcode,
|
|
|
- HttpServletResponse response, HttpServletRequest request) {
|
|
|
+ public void checkcode(HttpServletResponse response, HttpServletRequest request) {
|
|
|
try {
|
|
|
response.reset();
|
|
|
// 响应类型,即MIME类型
|
|
@@ -70,18 +70,18 @@ public class AuthenticateController extends BaseCtl {
|
|
|
// + ")");
|
|
|
}
|
|
|
// 生成随机字符
|
|
|
- String sRand = "";
|
|
|
+ String captcha = "";
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
String rand = String.valueOf(random.nextInt(10));
|
|
|
- sRand += rand;
|
|
|
+ captcha += rand;
|
|
|
}
|
|
|
- for (int i = 0; i < sRand.length(); i++) {
|
|
|
- String rand = sRand.substring(i, i + 1);
|
|
|
+ for (int i = 0; i < captcha.length(); i++) {
|
|
|
+ String rand = captcha.substring(i, i + 1);
|
|
|
g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));
|
|
|
g.drawString(rand, 13 * i + 6, 16);
|
|
|
}
|
|
|
// 将随机验证码放入session
|
|
|
- request.getSession().setAttribute(GlobalData.USER_SESSION_CHECK_CODE, checkcode);
|
|
|
+ SecurityUtils.getSubject().getSession().setAttribute(CaptchaValidateFilter.SESSION_CAPTCHA_PARAM, captcha);
|
|
|
// 关闭画笔
|
|
|
g.dispose();
|
|
|
// 写出
|