refactor: simplecapcha remark 처리

JDK 8 -> 11 up
main
Jonguk. Lim 2 years ago
parent 8cd542cfaa
commit 1a1c6ec36f

@ -19,7 +19,7 @@
<properties>
<encoding>UTF-8</encoding>
<java-version>1.8</java-version>
<java-version>11</java-version>
<spring.maven.artifact.version>4.3.25.RELEASE</spring.maven.artifact.version>
<egovframework.rte.version>3.10.0</egovframework.rte.version>
<org.apache.tiles.version>3.0.5</org.apache.tiles.version>
@ -69,6 +69,71 @@
</repositories>
<dependencies>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.15.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
<version>3.0.15.RELEASE</version>
</dependency>
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
<version>3.1.0</version>
</dependency>
<!--
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
-->
<!--
<dependency>
<groupId>com.github.spullara.mustache.java</groupId>
<artifactId>compiler</artifactId>
<version>0.9.4</version>
</dependency>
<dependency>
<groupId>com.samskivert</groupId>
<artifactId>jmustache</artifactId>
<version>1.15</version>
</dependency>
-->
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mustache</artifactId>
<version>2.1.18.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
-->
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.fdl.logging</artifactId>
@ -484,13 +549,13 @@
</dependency>
<!--
<dependency>
<groupId>nl.captcha</groupId>
<artifactId>simplecaptcha</artifactId>
<version>1.2.1</version>
</dependency>
-->
<!-- Apache Commons Configurations -->
<dependency>
@ -732,6 +797,7 @@
<include>spring/service/cache/*.xml</include>
<include>sqlmapper/**/*</include>
<include>validator/**/*</include>
<include>templates/**/*</include>
</includes>
<filtering>true</filtering>
</resource>
@ -931,6 +997,7 @@
</executions>
</plugin>
<!-- Rest Doc 생성 -->
</plugins>
</build>
<reporting>

@ -7,7 +7,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import nl.captcha.Captcha;
//import nl.captcha.Captcha;
import kr.xit.framework.biz.cmm.dto.XitLoginPolicyVO;
import kr.xit.framework.biz.cmm.dto.XitUserAbsnceVO;
import kr.xit.framework.biz.cmm.service.XitFrameCrudService;
@ -92,13 +92,15 @@ public class XitLoginServiceImpl implements XitLoginService{
//캡차인증 확인
HttpServletRequest req = XitHttpRequestHelper.getCurrentRequest();
boolean isUseCaptcha = XitCmmnUtil.notEmpty(req.getSession().getAttribute("captcha"));
if(isUseCaptcha) {
Captcha captcha = (Captcha) req.getSession().getAttribute("captcha");
String captchStr = captcha.getAnswer();
String userInputStr = (String) req.getParameter("captcha");
if(!captchStr.equals(userInputStr))
throw new RuntimeException(String.format("자동로그인 방지 문구와 입력하신 값이 일치하지 않습니다.(생성:%s/입력:%s)", captchStr, userInputStr));
}
// FIXME :: Simple captcha
// if(isUseCaptcha) {
// Captcha captcha = (Captcha) req.getSession().getAttribute("captcha");
// String captchStr = captcha.getAnswer();
// String userInputStr = (String) req.getParameter("captcha");
// if(!captchStr.equals(userInputStr))
// throw new RuntimeException(String.format("자동로그인 방지 문구와 입력하신 값이 일치하지 않습니다.(생성:%s/입력:%s)", captchStr, userInputStr));
// }

@ -38,7 +38,7 @@ import kr.xit.framework.core.constants.FrameworkConstants.USER_SE;
import kr.xit.framework.core.message.XitMessageSource;
import kr.xit.framework.core.utils.XitCmmnUtil;
//import kr.xit.framework.core.utils.XitProperties;
import kr.xit.framework.core.utils.captcha.XitCaptchaUtil;
//import kr.xit.framework.core.utils.captcha.XitCaptchaUtil;
import kr.xit.framework.core.validation.XitBeanValidator;
import kr.xit.framework.support.util.AjaxUtils;
@ -453,7 +453,7 @@ public class XitFrameAnonymousController {
*/
@RequestMapping(value = "captcha", method={RequestMethod.GET, RequestMethod.POST})
public void captcha(HttpServletRequest request, HttpServletResponse response) {
XitCaptchaUtil.getImage(request, response);
//XitCaptchaUtil.getImage(request, response);
}

@ -84,7 +84,8 @@ public class XitLoginController {
// 1. Spring Security 사용자권한 처리
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if (!isAuthenticated) {
return LOGIN_PAGE+TILES_TYPE.NONE.getVal();
//return LOGIN_PAGE+TILES_TYPE.NONE.getVal();
return LOGIN_PAGE;
}
// 2. 메인 페이지 이동
@ -189,7 +190,8 @@ public class XitLoginController {
} else {
model.addAttribute("message", message==null?xitMessageSource.getMessage("fail.common.login"):message);
//return XitProperties.getProperty("Globals.Xit.LoginPage")+TILES_TYPE.NONE.getVal();
return LOGIN_PAGE+TILES_TYPE.NONE.getVal();
//return LOGIN_PAGE+TILES_TYPE.NONE.getVal();
return LOGIN_PAGE;
}
}

@ -1,94 +1,94 @@
package kr.xit.framework.core.utils.captcha;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import kr.xit.framework.support.captcha.SimpleCaptchaUtil;
import nl.captcha.Captcha;
import nl.captcha.audio.AudioCaptcha;
import nl.captcha.backgrounds.GradiatedBackgroundProducer;
import nl.captcha.servlet.CaptchaServletUtil;
import nl.captcha.text.producer.NumbersAnswerProducer;
import nl.captcha.text.renderer.DefaultWordRenderer;
@Controller
public class XitCaptchaUtil {
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* <pre> : .
* - .
* - session attribute "captcha" .
* </pre>
* @param request
* @param response void
* @author:
* @date: 2020. 9. 22.
*/
public static void getImage(HttpServletRequest request, HttpServletResponse response) {
/*폰트 및 컬러 설정*/
List<Font> fontList = new ArrayList<Font>();
fontList.add(new Font("", Font.HANGING_BASELINE, 40));
fontList.add(new Font("Courier", Font.ITALIC, 40));
fontList.add(new Font("", Font.PLAIN, 40));
List<Color> colorList = new ArrayList<Color>();
colorList.add(Color.BLACK);
//Captcha captcha = new Captcha.Builder(250, 50) //캡차 이미지 크기(가로,세로)
Captcha captcha = new Captcha.Builder(250, 50) //캡차 이미지 크기(가로,세로)
.addText(new NumbersAnswerProducer(6), new DefaultWordRenderer(colorList, fontList)) //이미지문구 생성(default: 5자리의 랜덤한 알파벳과 숫자 생성)
// .addText(new NumbersAnswerProducer()) //이미지문구 생성(5자리의 랜덤한 숫자 생성)
.addBackground(new GradiatedBackgroundProducer()) //바탕색 흰색 - Default
.addNoise() //한번 호출할 떄마다 하나의 라인이 추가된다.
.gimp() //Gradiated 백그라운드
// .gimp(new DropShadowGimpyRenderer()) //그림자 효과 추가
.addBorder() //검정 테두리 선 생성
.build(); //필수 호출 함수
/*
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache"); //브라우저 캐시 설정
response.setDateHeader("Expires", 0);
response.setContentType("image/jpeg"); //리턴 컨텐츠타입 설정
Capchas.net
JCAPCHA
*/
//image 생성
CaptchaServletUtil.writeImage(response, captcha.getImage());
//image 문자
// String captchaImgStr = captcha.getAnswer();
//요청세션에 저장
request.getSession().setAttribute("captcha", captcha);
}
public void getAudioCaptCha(HttpServletRequest req, HttpServletResponse res, String answer) throws IOException {
HttpSession session = req.getSession();
Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);
String getAnswer = answer;
if(getAnswer == null || getAnswer.equals("")) getAnswer = captcha.getAnswer();
AudioCaptcha audiocaptcha = new AudioCaptcha.Builder()
.addAnswer(new SimpleCaptchaUtil.SetTextProducer(getAnswer))
.addNoise() /*잡음 추가*/
.build();
CaptchaServletUtil.writeAudio(res, audiocaptcha.getChallenge());
}
}
// package kr.xit.framework.core.utils.captcha;
//
// import java.awt.*;
// import java.io.IOException;
// import java.util.ArrayList;
// import java.util.List;
//
// import javax.servlet.http.HttpServletRequest;
// import javax.servlet.http.HttpServletResponse;
// import javax.servlet.http.HttpSession;
//
// import org.slf4j.Logger;
// import org.slf4j.LoggerFactory;
// import org.springframework.stereotype.Controller;
//
// import kr.xit.framework.support.captcha.SimpleCaptchaUtil;
// import nl.captcha.Captcha;
// import nl.captcha.audio.AudioCaptcha;
// import nl.captcha.backgrounds.GradiatedBackgroundProducer;
// import nl.captcha.servlet.CaptchaServletUtil;
// import nl.captcha.text.producer.NumbersAnswerProducer;
// import nl.captcha.text.renderer.DefaultWordRenderer;
//
// @Controller
// public class XitCaptchaUtil {
// private Logger logger = LoggerFactory.getLogger(getClass());
//
// /**
// * <pre>메소드 설명: 캡차인증 이미지를 생성 한다.
// * -자동로그인 방지를 위해 특정문구가 입력된 캡차 이미지를 생성 한다.
// * -캡차 이미지에 입력된 문구는 요청 session의 attribute에 "captcha"란 이름으로 저장 된다.
// * </pre>
// * @param request
// * @param response void 요청처리 후 응답객체
// * @author: 박민규
// * @date: 2020. 9. 22.
// */
// public static void getImage(HttpServletRequest request, HttpServletResponse response) {
//
// /*폰트 및 컬러 설정*/
// List<Font> fontList = new ArrayList<Font>();
// fontList.add(new Font("", Font.HANGING_BASELINE, 40));
// fontList.add(new Font("Courier", Font.ITALIC, 40));
// fontList.add(new Font("", Font.PLAIN, 40));
// List<Color> colorList = new ArrayList<Color>();
// colorList.add(Color.BLACK);
//
// //Captcha captcha = new Captcha.Builder(250, 50) //캡차 이미지 크기(가로,세로)
// Captcha captcha = new Captcha.Builder(250, 50) //캡차 이미지 크기(가로,세로)
// .addText(new NumbersAnswerProducer(6), new DefaultWordRenderer(colorList, fontList)) //이미지문구 생성(default: 5자리의 랜덤한 알파벳과 숫자 생성)
// // .addText(new NumbersAnswerProducer()) //이미지문구 생성(5자리의 랜덤한 숫자 생성)
// .addBackground(new GradiatedBackgroundProducer()) //바탕색 흰색 - Default
// .addNoise() //한번 호출할 떄마다 하나의 라인이 추가된다.
// .gimp() //Gradiated 백그라운드
// // .gimp(new DropShadowGimpyRenderer()) //그림자 효과 추가
// .addBorder() //검정 테두리 선 생성
// .build(); //필수 호출 함수
// /*
//
// response.setHeader("Cache-Control", "no-store");
// response.setHeader("Pragma", "no-cache"); //브라우저 캐시 설정
// response.setDateHeader("Expires", 0);
// response.setContentType("image/jpeg"); //리턴 컨텐츠타입 설정
//
// Capchas.net
// JCAPCHA
// */
//
// //image 생성
// CaptchaServletUtil.writeImage(response, captcha.getImage());
// //image 문자
// // String captchaImgStr = captcha.getAnswer();
//
// //요청세션에 저장
// request.getSession().setAttribute("captcha", captcha);
// }
//
// public void getAudioCaptCha(HttpServletRequest req, HttpServletResponse res, String answer) throws IOException {
// HttpSession session = req.getSession();
//
// Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);
// String getAnswer = answer;
//
// if(getAnswer == null || getAnswer.equals("")) getAnswer = captcha.getAnswer();
//
// AudioCaptcha audiocaptcha = new AudioCaptcha.Builder()
// .addAnswer(new SimpleCaptchaUtil.SetTextProducer(getAnswer))
// .addNoise() /*잡음 추가*/
// .build();
//
// CaptchaServletUtil.writeAudio(res, audiocaptcha.getChallenge());
// }
//
// }

@ -1,229 +1,229 @@
package kr.xit.framework.support.captcha;
import kr.xit.framework.support.util.Checks;
import nl.captcha.Captcha;
import nl.captcha.audio.AudioCaptcha;
import nl.captcha.backgrounds.GradiatedBackgroundProducer;
import nl.captcha.servlet.CaptchaServletUtil;
import nl.captcha.text.producer.TextProducer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* @author Lim, Jong Uk (minuk926)
* @since 2021-11-30
*/
public class SimpleCaptchaUtil {
private static final int WIDTH = 100;
private static final int HEIGHT = 30;
private static final int FONT_SIZE = 20;
/**
*
* @param req
* @param res
*/
public static void getImgCaptcha(final HttpServletRequest req, final HttpServletResponse res) {
int width = Objects.isNull(req.getParameter("width"))? WIDTH : Integer.parseInt(req.getParameter("width"));
int height = Objects.isNull(req.getParameter("height"))? HEIGHT : Integer.parseInt(req.getParameter("height"));
List<Font> fonts = Arrays.asList(
new Font("", Font.HANGING_BASELINE, FONT_SIZE),
new Font("Courier", Font.ITALIC, FONT_SIZE),
new Font("", Font.PLAIN, FONT_SIZE)
);
List<Color> colors = Collections.singletonList(Color.BLACK);
Captcha captcha =
new Captcha.Builder(150, 50)
.addText()
//new Captcha.Builder(width, height)
//.addText(new NumbersAnswerProducer(5), new DefaultWordRenderer(colors, fonts))
// 호출될때마다 라인 추가
.addNoise()
.gimp()
// black border 생성
.addBorder()
.addBackground(new GradiatedBackgroundProducer())
.build();
/*
res.setHeader("Cache-Control", "no-cache");
res.setDateHeader("Expires", 0);
res.setHeader("Pragma", "no-cache");
res.setDateHeader("Max-Age", 0);
res.setContentType("image/png");
*/
CaptchaServletUtil.writeImage(res, captcha.getImage());
req.getSession().setAttribute(Captcha.NAME, captcha);
//req.getSession().setAttribute("captcha", captcha.getAnswer());// 값 저장
}
/**
*
* @param req
* @param res
* @param answer
*/
public static void getAudioCaptcha(final HttpServletRequest req, final HttpServletResponse res, String answer) {
if(Checks.isEmpty(answer)){
Captcha captcha = (Captcha) req.getSession().getAttribute(Captcha.NAME);
answer = captcha.getAnswer();
}
AudioCaptcha audioCaptcha = new AudioCaptcha.Builder()
.addAnswer(new SetTextProducer(answer))
.addNoise()
.build();
CaptchaServletUtil.writeAudio(res, audioCaptcha.getChallenge());
}
/**
*
* @param req
* @param res
* @param ans
* @return
*/
public static boolean isCorrect(final HttpServletRequest req, final HttpServletResponse res, String ans) {
if(Checks.isEmpty(ans)) return false;
Captcha captcha = (Captcha) req.getSession().getAttribute(Captcha.NAME);
if(captcha != null && captcha.isCorrect(ans)){
req.getSession().removeAttribute(Captcha.NAME);
return true;
}
return false;
/*
String answer = (String)req.getSession().getAttribute("captcha");
if(Objects.equals(ans, answer)) {
req.getSession().removeAttribute("captcha");
return true;
}
return false;
*/
}
public static class SetTextProducer implements TextProducer {
private final String str;
public SetTextProducer(String answer){
this.str = answer;
}
@Override
public String getText(){
return this.str;
}
}
}
/*
@RequestMapping(method = RequestMethod.GET, value = "/captcha/image")
public void getCaptchaImage(final HttpServletRequest req, final HttpServletResponse res) {
SimpleCaptchaUtil
.getImgCaptcha(req, res);
}
@RequestMapping(method = RequestMethod.GET, value = "/captcha/audio")
public void getCaptchaAudio(final HttpServletRequest req, final HttpServletResponse res) {
SimpleCaptchaUtil.getAudioCaptcha(req, res, null);
}
@RequestMapping(method = RequestMethod.POST, value = "/captcha/check")
@ResponseBody
public String isCorrect(final HttpServletRequest req, final HttpServletResponse res, String answer) {
//modelMap.addAttribute("OK", new SimpleCaptchaUtil().isCorrect(req, res, req.getParameter("answer")));
Gson gson = new GsonBuilder().create();
return gson.toJson(SimpleCaptchaUtil.isCorrect(req, res, req.getParameter("answer")));
}
<tr>
<th scope="row"><span class="ico_point"><span class="hide"></span>*</span><label for="captcha"></label></th>
<td>
<img id="captchaImg" src="${wwwHost}/support/captcha/image" alt="보안문자를 입력해 주세요.">
<div id="ccaudio" style="display:none"></div>
<input type="button" ng-click="mainCtrl.captchaReload()" id="reLoad" value="새로고침">
<input type="button" ng-click="mainCtrl.audio()" id="soundOn" value="음성듣기">
<input type="text" name="" id="captchaAns" class="" placeholder="보안문자 입력">
<input type="button" ng-click="mainCtrl.captchaConfirm()" id="captchaConfirm" value="확인">
</td>
</tr>
this.captchaReload = function(){
const rand = Math.random();
const url = '${wwwHost}/support/captcha/image?rand='+rand;
document.querySelector('#captchaImg').setAttribute('src', url);
}
this.audio = function(){
const rand = Math.random();
const uAgent = navigator.userAgent;
const url = '${wwwHost}/support/captcha/audio?rand='+rand;
// IE
if(uAgent.indexOf('Trident') > -1 || uAgent.indexOf('MISE') > -1){
document.querySelector('#ccaudio').innerHTML = '<bgsoun src="' + url + '">';
// Chrome
}else if(!!document.createElement('audio').canPlayType){
try{
new Audio(url).play()
}catch (e){
document.querySelector('#ccaudio').innerHTML = '<bgsoun src="' + url + '">';
}
}else{
window.open(url, '', 'width=1,height=1');
}
}
this.captchaConfirm = function(){
const ans = document.querySelector('#captchaAns').value;
if(!ans){
alert("보안문자를 입력해 주세요.");
return true;
}
$http({
method: 'POST',
url: '${wwwHost}/support/captcha/check',
data: {answer: ans}
}).success(function (data, status, headers, config) {
if(data){
}else{
alert(' .\n ');
captchaReload();
}
}).error(function (data, status, headers, config) {
alert(data.message);
});
}
*/
// package kr.xit.framework.support.captcha;
//
// import kr.xit.framework.support.util.Checks;
// import nl.captcha.Captcha;
// import nl.captcha.audio.AudioCaptcha;
// import nl.captcha.backgrounds.GradiatedBackgroundProducer;
// import nl.captcha.servlet.CaptchaServletUtil;
// import nl.captcha.text.producer.TextProducer;
//
// import javax.servlet.http.HttpServletRequest;
// import javax.servlet.http.HttpServletResponse;
// import java.awt.*;
// import java.util.Arrays;
// import java.util.Collections;
// import java.util.List;
// import java.util.Objects;
//
// /**
// * @author Lim, Jong Uk (minuk926)
// * @since 2021-11-30
// */
// public class SimpleCaptchaUtil {
//
// private static final int WIDTH = 100;
// private static final int HEIGHT = 30;
// private static final int FONT_SIZE = 20;
//
//
// /**
// *
// * @param req
// * @param res
// */
// public static void getImgCaptcha(final HttpServletRequest req, final HttpServletResponse res) {
// int width = Objects.isNull(req.getParameter("width"))? WIDTH : Integer.parseInt(req.getParameter("width"));
// int height = Objects.isNull(req.getParameter("height"))? HEIGHT : Integer.parseInt(req.getParameter("height"));
//
// List<Font> fonts = Arrays.asList(
// new Font("", Font.HANGING_BASELINE, FONT_SIZE),
// new Font("Courier", Font.ITALIC, FONT_SIZE),
// new Font("", Font.PLAIN, FONT_SIZE)
// );
// List<Color> colors = Collections.singletonList(Color.BLACK);
//
// Captcha captcha =
// new Captcha.Builder(150, 50)
// .addText()
// //new Captcha.Builder(width, height)
// //.addText(new NumbersAnswerProducer(5), new DefaultWordRenderer(colors, fonts))
// // 호출될때마다 라인 추가
// .addNoise()
// .gimp()
// // black border 생성
// .addBorder()
// .addBackground(new GradiatedBackgroundProducer())
// .build();
// /*
// res.setHeader("Cache-Control", "no-cache");
// res.setDateHeader("Expires", 0);
// res.setHeader("Pragma", "no-cache");
// res.setDateHeader("Max-Age", 0);
// res.setContentType("image/png");
// */
// CaptchaServletUtil.writeImage(res, captcha.getImage());
// req.getSession().setAttribute(Captcha.NAME, captcha);
// //req.getSession().setAttribute("captcha", captcha.getAnswer());// 값 저장
// }
//
// /**
// *
// * @param req
// * @param res
// * @param answer
// */
// public static void getAudioCaptcha(final HttpServletRequest req, final HttpServletResponse res, String answer) {
//
// if(Checks.isEmpty(answer)){
// Captcha captcha = (Captcha) req.getSession().getAttribute(Captcha.NAME);
// answer = captcha.getAnswer();
// }
//
// AudioCaptcha audioCaptcha = new AudioCaptcha.Builder()
// .addAnswer(new SetTextProducer(answer))
// .addNoise()
// .build();
//
// CaptchaServletUtil.writeAudio(res, audioCaptcha.getChallenge());
// }
//
// /**
// *
// * @param req
// * @param res
// * @param ans
// * @return
// */
// public static boolean isCorrect(final HttpServletRequest req, final HttpServletResponse res, String ans) {
//
// if(Checks.isEmpty(ans)) return false;
//
// Captcha captcha = (Captcha) req.getSession().getAttribute(Captcha.NAME);
// if(captcha != null && captcha.isCorrect(ans)){
// req.getSession().removeAttribute(Captcha.NAME);
// return true;
// }
// return false;
// /*
// String answer = (String)req.getSession().getAttribute("captcha");
// if(Objects.equals(ans, answer)) {
// req.getSession().removeAttribute("captcha");
// return true;
// }
// return false;
// */
//
// }
//
// public static class SetTextProducer implements TextProducer {
// private final String str;
//
// public SetTextProducer(String answer){
// this.str = answer;
// }
//
// @Override
// public String getText(){
// return this.str;
// }
// }
// }
//
//
// /*
//
//
// @RequestMapping(method = RequestMethod.GET, value = "/captcha/image")
// public void getCaptchaImage(final HttpServletRequest req, final HttpServletResponse res) {
// SimpleCaptchaUtil
// .getImgCaptcha(req, res);
//
//
// }
//
// @RequestMapping(method = RequestMethod.GET, value = "/captcha/audio")
// public void getCaptchaAudio(final HttpServletRequest req, final HttpServletResponse res) {
// SimpleCaptchaUtil.getAudioCaptcha(req, res, null);
//
//
// }
//
// @RequestMapping(method = RequestMethod.POST, value = "/captcha/check")
// @ResponseBody
// public String isCorrect(final HttpServletRequest req, final HttpServletResponse res, String answer) {
// //modelMap.addAttribute("OK", new SimpleCaptchaUtil().isCorrect(req, res, req.getParameter("answer")));
//
// Gson gson = new GsonBuilder().create();
// return gson.toJson(SimpleCaptchaUtil.isCorrect(req, res, req.getParameter("answer")));
// }
//
//
//
// <tr>
// <th scope="row"><span class="ico_point"><span class="hide">필수입력</span>*</span><label for="captcha">자동입력방지</label></th>
// <td>
// <img id="captchaImg" src="${wwwHost}/support/captcha/image" alt="보안문자를 입력해 주세요.">
// <div id="ccaudio" style="display:none"></div>
// <input type="button" ng-click="mainCtrl.captchaReload()" id="reLoad" value="새로고침">
// <input type="button" ng-click="mainCtrl.audio()" id="soundOn" value="음성듣기">
// <input type="text" name="" id="captchaAns" class="" placeholder="보안문자 입력">
// <input type="button" ng-click="mainCtrl.captchaConfirm()" id="captchaConfirm" value="확인">
// </td>
// </tr>
//
//
//
// this.captchaReload = function(){
// const rand = Math.random();
// const url = '${wwwHost}/support/captcha/image?rand='+rand;
// document.querySelector('#captchaImg').setAttribute('src', url);
//
// }
//
// this.audio = function(){
// const rand = Math.random();
// const uAgent = navigator.userAgent;
//
// const url = '${wwwHost}/support/captcha/audio?rand='+rand;
//
// // IE
// if(uAgent.indexOf('Trident') > -1 || uAgent.indexOf('MISE') > -1){
// document.querySelector('#ccaudio').innerHTML = '<bgsoun src="' + url + '">';
//
// // Chrome
// }else if(!!document.createElement('audio').canPlayType){
// try{
// new Audio(url).play()
// }catch (e){
// document.querySelector('#ccaudio').innerHTML = '<bgsoun src="' + url + '">';
// }
// }else{
// window.open(url, '', 'width=1,height=1');
// }
// }
// this.captchaConfirm = function(){
// const ans = document.querySelector('#captchaAns').value;
// if(!ans){
// alert("보안문자를 입력해 주세요.");
// return true;
// }
//
// $http({
// method: 'POST',
// url: '${wwwHost}/support/captcha/check',
// data: {answer: ans}
// }).success(function (data, status, headers, config) {
// if(data){
//
// }else{
// alert('보안문자가 일치하지 않습니다.\n다시 입력해 주세요');
// captchaReload();
// }
//
// }).error(function (data, status, headers, config) {
// alert(data.message);
// });
//
// }
//
// */

@ -160,7 +160,7 @@
$('#id').focus();
CaptchaUtil.init();
//CaptchaUtil.init();
}
@ -193,13 +193,13 @@
var CaptchaUtil = {
init: function(){
//캡차인증 이미지 출력
CaptchaUtil.refresh();
//CaptchaUtil.refresh();
//새로고침 버튼 EventListener 설정
$('#btn_captchaRefresh').on({
click: function(){
CaptchaUtil.refresh();
//CaptchaUtil.refresh();
return false;
}

Loading…
Cancel
Save