From 052b65d45d4df89d7d0c33e7b4d81f25b23dd11c Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Fri, 9 Jun 2023 15:12:37 +0900 Subject: [PATCH] no message --- .../biz/cmm/web/XitLoginController.java | 420 ------------------ src/main/webapp/WEB-INF/web.xml | 2 +- 2 files changed, 1 insertion(+), 421 deletions(-) delete mode 100644 src/main/java/cokr/xit/fims/framework/biz/cmm/web/XitLoginController.java diff --git a/src/main/java/cokr/xit/fims/framework/biz/cmm/web/XitLoginController.java b/src/main/java/cokr/xit/fims/framework/biz/cmm/web/XitLoginController.java deleted file mode 100644 index 055c0149..00000000 --- a/src/main/java/cokr/xit/fims/framework/biz/cmm/web/XitLoginController.java +++ /dev/null @@ -1,420 +0,0 @@ -package cokr.xit.fims.framework.biz.cmm.web; - -import cokr.xit.foundation.web.AbstractController; -import cokr.xit.fims.framework.biz.cmm.XitLoginVO; -import cokr.xit.fims.framework.biz.cmm.service.XitFrameCrudService; -import cokr.xit.fims.framework.biz.cmm.service.XitLoginService; -import cokr.xit.fims.framework.biz.mng.user.XitUserInfoVO; -import cokr.xit.fims.framework.core.constants.FrameworkConstants; - -import cokr.xit.fims.framework.core.constants.FrameworkConstants.USER_SE; -import org.springframework.context.support.ReloadableResourceBundleMessageSource; -import cokr.xit.fims.framework.core.utils.XitCmmnUtil; -import cokr.xit.fims.framework.support.util.AjaxUtils; -import lombok.extern.slf4j.Slf4j; -import org.egovframe.rte.fdl.security.config.SecurityConfig; -import org.egovframe.rte.fdl.security.userdetails.util.EgovUserDetailsHelper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.security.core.context.SecurityContext; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; -import org.springframework.security.web.util.matcher.AntPathRequestMatcher; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.support.WebApplicationContextUtils; -import org.springframework.web.servlet.ModelAndView; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import java.io.IOException; -import java.io.PrintWriter; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -@Slf4j -@Controller -@RequestMapping(name = "", value = "/login/") -public class XitLoginController extends AbstractController { - - @Autowired - private XitLoginService xitLoginService; - @Autowired - private XitFrameCrudService xitFrameCrudService; - - - private String LOGIN_PAGE = "fimslogin"; - - private String ACCESS_DENIED_PAGE = "login/XitAccessDenied"; - - private String MAIN_PAGE = "/framework/biz/cmm/mainPage.do"; - - - /** - * 로그인 후 메인화면으로 들어간다 - * - * @param - * @return 로그인 페이지 - * @throws Exception - */ - @RequestMapping(name = "", value = "/actionMain") - public String actionMain() - throws Exception { - - // 1. Spring Security 사용자권한 처리 - Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated(); - if (!isAuthenticated) { - - return LOGIN_PAGE; - } - - return "forward:" + "/framework/biz/cmm/mainPage.do"; - } - - /** - *
-	 * 메소드 설명: 일반(스프링 시큐리티) 로그인을 처리 한다.
-	 * 
- * - * @param loginVO 아이디, 비밀번호가 담긴 LoginVO - * @param response 로그인결과(세션정보) - * @param request 세션처리를 위한 HttpServletRequest - * @param model - * @return - * @throws Exception String 요청처리 후 응답객체 - * @author: 박민규 - * @date: 2020. 3. 23. - */ - @RequestMapping(name = "", value = "/actionSecurityLogin") - public String actionSecurityLogin(@ModelAttribute("loginVO") XitLoginVO loginVO, HttpServletResponse response, - HttpServletRequest request, ModelMap model, @RequestParam Map paraMap) throws Exception { - - String message = null; - - /** - * 유효성 확인 - * -비인증 상태에서 인가되지 않은 URL 호출에 대한 처리 - * :Security에서 비인가 URL 직접 호출 시 "loginUrl"(으)로 redirect를 하므로 - * :해당 요청에 대해 메세지 출력을 하도록 처리 - */ - //비인증 상태에서 인가되지 않은 URL 호출에 대한 처리 - if (XitCmmnUtil.isEmpty(paraMap)) { - - return "forward:/login/accessDenied.do"; - } - - - /** - * 처리 - */ - XitLoginVO xitLoginVO = null; - try { - // 로그인 처리 - xitLoginVO = xitLoginService.actionLogin(loginVO); - - } catch (Exception e) { - log.debug(String.format("로그인 처리 실패 : %s", e.getMessage())); - message = e.getMessage(); - - } - - - /** - * 결과 반환 - */ - // 로그인 정보/정책에 따라 응답페이지 분기 - if (xitLoginVO != null && xitLoginVO.getId() != null && !"".equals(xitLoginVO.getId())) { - - // session Set - request.getSession().setAttribute("XitLoginSession", xitLoginVO); - - // spring security 연동 - UsernamePasswordAuthenticationFilter springSecurity = null; - ApplicationContext act = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getSession().getServletContext()); - Map beans = act.getBeansOfType(UsernamePasswordAuthenticationFilter.class); - if (beans.size() > 0) { - springSecurity = (UsernamePasswordAuthenticationFilter) beans.values().toArray()[0]; - springSecurity.setUsernameParameter("xit_security_username"); - springSecurity.setPasswordParameter("xit_security_password"); - springSecurity.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher( - request.getServletContext().getContextPath() + "/xit_security_login", "POST")); - - } else { - - throw new IllegalStateException("No AuthenticationProcessingFilter"); - } - - - - - xitLoginService.actionLoginSuccess();//로그인 Log 생성 - // 2. 메인 페이지 이동 - - - return "forward:" + "/framework/biz/cmm/mainPage.do"; - - } else { - - model.addAttribute("message", message == null ? "로그인정보가 올바르지 않습니다." : message); - - return LOGIN_PAGE; - } - } - - /** - * 로그아웃한다. - * - * @return String - * @throws Exception - */ - @RequestMapping(name = "", value = "/actionLogout") - public String actionLogout(HttpServletRequest request) { - request.getSession().setAttribute("XitLoginSession", null); - - ApplicationContext act = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getSession().getServletContext()); - SecurityConfig config = (SecurityConfig) act.getBean(SecurityConfig.class); - String logoutSuccessUrl = config.getLogoutSuccessUrl(); - - SecurityContext context = SecurityContextHolder.getContext(); - context.setAuthentication(null); - - //return "redirect:/egov_security_logout.do"; - return "forward:" + logoutSuccessUrl; - } - - /** - * 권한제한 화면 이동 - * - * @return String - * @throws Exception - */ - @RequestMapping(name = "", value = "accessDenied") - public void accessDenied(HttpServletRequest request, HttpServletResponse response) throws Exception { - - /** - * 호출 유형에 따른 분기 - */ - if (AjaxUtils.isAjaxRequest(request)) { //ajax - //Response & Message Set - response.setCharacterEncoding("UTF-8"); - response.setContentType("text/html; charset=UTF-8"); - PrintWriter writer = response.getWriter(); - String msg = "요청에 대한 권한이 없습니다."; - - //응답 - writer.println(msg); - - } else { //submit - Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated(); - - //인증사용자 - if (isAuthenticated) { - //응답 - response.sendRedirect(FrameworkConstants.FRAMEWORK_JSP_BASE_PATH + ACCESS_DENIED_PAGE); - - //미인증사용자 - } else { - //Response & Message Set - response.setCharacterEncoding("UTF-8"); - response.setContentType("text/html; charset=UTF-8"); - PrintWriter writer = response.getWriter(); - String msg = "요청에 대한 권한이 없습니다."; - - //응답 - String contextPath = request.getContextPath(); - boolean isExistsContextPath = "/".equals(contextPath) ? false : true; - if (isExistsContextPath) - writer.println(""); - else - writer.println(""); - } - } - - } - - /** - *
메소드 설명: 아이디 찾기 페이지 요청별  팝업
- * - * @param page - * @param vo - * @return - * @throws Exception - * @author: 김동규 - * @date: 2020. 10. 21. - */ - @RequestMapping(name = "", value = "/findIdPopup/{page}") - public ModelAndView findIdPopup(@PathVariable String page, @ModelAttribute("xitLoginVO") XitLoginVO vo) throws Exception { - ModelAndView mav = new ModelAndView(); - - if (page.endsWith(".do") || page.endsWith(".ajax")) { - page = page.substring(0, page.lastIndexOf(".")); - } - - switch (page) { - case "input": //아이디 찾기 -정보입력 페이지 - mav.setViewName(FrameworkConstants.FRAMEWORK_JSP_BASE_PATH + "login/findIdFormPopup.popup"); - break; - case "inputEvr": //(모든사용자)아이디 찾기 -정보입력 페이지 - mav.setViewName(FrameworkConstants.FRAMEWORK_JSP_BASE_PATH + "login/findIdEvrFormPopup.popup"); - break; - - case "result": //아이디 찾기 -결과 - XitLoginVO loginVO = xitLoginService.findId(vo); - mav.addObject("userAcnt", loginVO.getId()); - mav.setViewName(FrameworkConstants.FRAMEWORK_JSP_BASE_PATH + "login/findIdResultFormPopup.popup"); - break; - - default: - throw new RuntimeException("유효하지 않은 요청 입니다."); - } - return mav; - } - - - /** - *
메소드 설명: 비밀번호 찾기 페이지 요청별 팝업
- * - * @param xitUserInfoVO - * @param page - * @throws IOException - * @throws SQLException - * @throws RuntimeException String 요청처리 후 응답객체 - * @author: 김동규 - * @date: 2020. 10. 21. - */ - @RequestMapping(name = "", value = "findPwdPopup/{page}") - public ModelAndView findPwdPopup(@ModelAttribute("xitUserInfoVO") XitUserInfoVO xitUserInfoVO, @PathVariable String page) throws RuntimeException { - ModelAndView mav = new ModelAndView(); - - if (page.endsWith(".do") || page.endsWith(".ajax")) { - page = page.substring(0, page.lastIndexOf(".")); - } - - switch (page) { - case "input": //비밀번호 찾기 -정보입력 페이지 - mav.setViewName(FrameworkConstants.FRAMEWORK_JSP_BASE_PATH + "login/findPwdFormPopup.popup"); - break; - case "inputEvr": //(모든사용자)비밀번호 찾기 -정보입력 페이지 - mav.setViewName(FrameworkConstants.FRAMEWORK_JSP_BASE_PATH + "login/findPwdEvrFormPopup.popup"); - break; - - case "result": //비밀번호 찾기 -결과 - mav.setViewName(FrameworkConstants.FRAMEWORK_JSP_BASE_PATH + "login/findPwdResultFormPopup.popup"); - break; - - default: - throw new RuntimeException("유효하지 않은 요청 입니다."); - } - return mav; - } - - /** - *
메소드 설명: 비밀번호 찾기 CRUD 처리
- * - * @param res - * @param model - * @param session - * @param vo xitUserInfoVO - * @return - * @throws Exception - * @author: 김동규 - * @date: 2020. 10. 21. - */ - @RequestMapping(name = "", value = "FindPwd_{cmd}_proc", method = RequestMethod.POST) - public void FindPwd_cmd_proc(HttpServletResponse res, Model model - , HttpSession session - , @ModelAttribute("xitLoginVO") XitLoginVO vo - , @PathVariable String cmd - , HttpServletRequest request - , HttpServletResponse response - ) throws Exception { - - - String sLocationUrl = null; - Map resultMap = new HashMap(); - switch (cmd) { - case "select": //조회 - XitLoginVO loginVO = xitLoginService.findPassword(vo); - - resultMap.put("result", XitCmmnUtil.isEmpty(loginVO.getId()) ? "N" : "Y"); - break; - -// case "insert": //등록 -// break; - -// case "inserts": //다건 등록 -// break; - - case "update": //수정 - - boolean result = false; - String message = null; - String failDetail = null; - try { - xitLoginService.modifyPassword(vo); - result = true; - message = "정상적으로 변경 되었습니다."; - } catch (Exception e) { - result = false; - message = "변경에 실패하였습니다."; - failDetail = e.getMessage(); - } - model.addAttribute("result", result ? "Y" : "N"); - model.addAttribute("message", message); - model.addAttribute("failDetail", failDetail); - model.addAttribute("tempPwd", vo.getPasswd()); - - sLocationUrl = "forward:/login/findPwdPopup/result.do"; - break; - -// case "delete": //삭제 -// break; - -// case "deletes": //다건 삭제 -// break; - - default: - new RuntimeException("유효하지 않은 요청 입니다."); - } - - - /** - * 응답 설정 - */ - if (AjaxUtils.isAjaxRequest(request)) { //ajax 요청시 - //반환 데이터 설정 - Iterator keys = resultMap.keySet().iterator(); - while (keys.hasNext()) { - String key = keys.next(); - Object value = resultMap.get(key); - request.setAttribute(key, value); - } - request.getRequestDispatcher("/login/responseJson").forward(request, response); - } else { //submit 요청 시 - XitCmmnUtil.forwardForSubmitRequest(request, response, sLocationUrl, model.asMap()); - } - } - - @RequestMapping(name = "", value = "responseJson", method = {RequestMethod.GET, RequestMethod.POST}) - @ResponseBody - public Map responseJson(HttpServletRequest request - ) { - /** - * 반환 - */ - Map resultMap = new HashMap(); - Object respData = request.getAttribute("result"); - if (XitCmmnUtil.notEmpty(respData)) - resultMap.put("result", respData); - - return resultMap; - } - - -} diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 59b767a8..1446cab8 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -72,7 +72,7 @@ - index.jsp + /index.do