From 1a1c6ec36f418137353917258c0162f6b000c6e8 Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Fri, 31 Mar 2023 18:11:54 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20simplecapcha=20remark=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=20=20=20=20=20=20=20=20=20=20JDK=208=20->=2011=20u?= =?UTF-8?q?p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 73 ++- .../cmm/service/impl/XitLoginServiceImpl.java | 18 +- .../cmm/web/XitFrameAnonymousController.java | 4 +- .../biz/cmm/web/XitLoginController.java | 6 +- .../core/utils/captcha/XitCaptchaUtil.java | 188 +++---- .../support/captcha/SimpleCaptchaUtil.java | 458 +++++++++--------- .../jsp/framework/biz/login/XitLoginUsr.jsp | 6 +- 7 files changed, 412 insertions(+), 341 deletions(-) diff --git a/pom.xml b/pom.xml index 85d69a55..d89617f8 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ UTF-8 - 1.8 + 11 4.3.25.RELEASE 3.10.0 3.0.5 @@ -69,6 +69,71 @@ + + + org.thymeleaf + thymeleaf + 3.0.15.RELEASE + + + org.thymeleaf + thymeleaf-spring5 + 3.0.15.RELEASE + + + nz.net.ultraq.thymeleaf + thymeleaf-layout-dialect + 3.1.0 + + + + + + + + egovframework.rte egovframework.rte.fdl.logging @@ -484,13 +549,13 @@ - + @@ -732,6 +797,7 @@ spring/service/cache/*.xml sqlmapper/**/* validator/**/* + templates/**/* true @@ -931,6 +997,7 @@ + diff --git a/src/main/java/kr/xit/framework/biz/cmm/service/impl/XitLoginServiceImpl.java b/src/main/java/kr/xit/framework/biz/cmm/service/impl/XitLoginServiceImpl.java index 6f7370f8..0ee65e5d 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/service/impl/XitLoginServiceImpl.java +++ b/src/main/java/kr/xit/framework/biz/cmm/service/impl/XitLoginServiceImpl.java @@ -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)); + // } diff --git a/src/main/java/kr/xit/framework/biz/cmm/web/XitFrameAnonymousController.java b/src/main/java/kr/xit/framework/biz/cmm/web/XitFrameAnonymousController.java index 5dc31414..419866dd 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/web/XitFrameAnonymousController.java +++ b/src/main/java/kr/xit/framework/biz/cmm/web/XitFrameAnonymousController.java @@ -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); } diff --git a/src/main/java/kr/xit/framework/biz/cmm/web/XitLoginController.java b/src/main/java/kr/xit/framework/biz/cmm/web/XitLoginController.java index ef80f373..7bb90f74 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/web/XitLoginController.java +++ b/src/main/java/kr/xit/framework/biz/cmm/web/XitLoginController.java @@ -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; } } diff --git a/src/main/java/kr/xit/framework/core/utils/captcha/XitCaptchaUtil.java b/src/main/java/kr/xit/framework/core/utils/captcha/XitCaptchaUtil.java index 96d57ebd..748c01fe 100644 --- a/src/main/java/kr/xit/framework/core/utils/captcha/XitCaptchaUtil.java +++ b/src/main/java/kr/xit/framework/core/utils/captcha/XitCaptchaUtil.java @@ -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()); - - /** - *
메소드 설명: 캡차인증 이미지를 생성 한다.
-	 * 	-자동로그인 방지를 위해 특정문구가 입력된 캡차 이미지를 생성 한다.
-	 * 	-캡차 이미지에 입력된 문구는 요청 session의 attribute에 "captcha"란 이름으로 저장 된다.
-	 * 
- * @param request - * @param response void 요청처리 후 응답객체 - * @author: 박민규 - * @date: 2020. 9. 22. - */ - public static void getImage(HttpServletRequest request, HttpServletResponse response) { - - /*폰트 및 컬러 설정*/ - List fontList = new ArrayList(); - fontList.add(new Font("", Font.HANGING_BASELINE, 40)); - fontList.add(new Font("Courier", Font.ITALIC, 40)); - fontList.add(new Font("", Font.PLAIN, 40)); - List colorList = new ArrayList(); - 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()); +// +// /** +// *
메소드 설명: 캡차인증 이미지를 생성 한다.
+// 	 * 	-자동로그인 방지를 위해 특정문구가 입력된 캡차 이미지를 생성 한다.
+// 	 * 	-캡차 이미지에 입력된 문구는 요청 session의 attribute에 "captcha"란 이름으로 저장 된다.
+// 	 * 
+// * @param request +// * @param response void 요청처리 후 응답객체 +// * @author: 박민규 +// * @date: 2020. 9. 22. +// */ +// public static void getImage(HttpServletRequest request, HttpServletResponse response) { +// +// /*폰트 및 컬러 설정*/ +// List fontList = new ArrayList(); +// fontList.add(new Font("", Font.HANGING_BASELINE, 40)); +// fontList.add(new Font("Courier", Font.ITALIC, 40)); +// fontList.add(new Font("", Font.PLAIN, 40)); +// List colorList = new ArrayList(); +// 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()); +// } +// +// } diff --git a/src/main/java/kr/xit/framework/support/captcha/SimpleCaptchaUtil.java b/src/main/java/kr/xit/framework/support/captcha/SimpleCaptchaUtil.java index 3316d7f7..d79ea1a6 100644 --- a/src/main/java/kr/xit/framework/support/captcha/SimpleCaptchaUtil.java +++ b/src/main/java/kr/xit/framework/support/captcha/SimpleCaptchaUtil.java @@ -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 fonts = Arrays.asList( - new Font("", Font.HANGING_BASELINE, FONT_SIZE), - new Font("Courier", Font.ITALIC, FONT_SIZE), - new Font("", Font.PLAIN, FONT_SIZE) - ); - List 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"))); - } - - - - - 필수입력* - - 보안문자를 입력해 주세요. - - - - - - - - - - - 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 = ''; - - // Chrome - }else if(!!document.createElement('audio').canPlayType){ - try{ - new Audio(url).play() - }catch (e){ - document.querySelector('#ccaudio').innerHTML = ''; - } - }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 fonts = Arrays.asList( +// new Font("", Font.HANGING_BASELINE, FONT_SIZE), +// new Font("Courier", Font.ITALIC, FONT_SIZE), +// new Font("", Font.PLAIN, FONT_SIZE) +// ); +// List 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"))); +// } +// +// +// +// +// 필수입력* +// +// 보안문자를 입력해 주세요. +// +// +// +// +// +// +// +// +// +// +// 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 = ''; +// +// // Chrome +// }else if(!!document.createElement('audio').canPlayType){ +// try{ +// new Audio(url).play() +// }catch (e){ +// document.querySelector('#ccaudio').innerHTML = ''; +// } +// }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); +// }); +// +// } +// +// */ diff --git a/src/main/webapp/WEB-INF/jsp/framework/biz/login/XitLoginUsr.jsp b/src/main/webapp/WEB-INF/jsp/framework/biz/login/XitLoginUsr.jsp index 205c3905..8e0f904b 100644 --- a/src/main/webapp/WEB-INF/jsp/framework/biz/login/XitLoginUsr.jsp +++ b/src/main/webapp/WEB-INF/jsp/framework/biz/login/XitLoginUsr.jsp @@ -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; }