IP 인증 패키지

This commit is contained in:
hehihoho3@gmail.com 2024-11-20 10:02:16 +09:00
parent ed11fae311
commit 78475e2b45
9 changed files with 507 additions and 16 deletions

View File

@ -0,0 +1,34 @@
package itn.let.cert.ip.service;
import java.util.List;
import itn.let.lett.service.LetterVO;
import itn.let.mail.service.StatusResponse;
import itn.let.mjo.addr.service.AddrVO;
import itn.let.mjo.msg.service.MjonMsgVO;
import itn.let.sym.site.service.JoinSettingVO;
import itn.let.uat.uia.service.MberCertPhoneVO;
import itn.let.uat.uia.web.SendLogVO;
import itn.let.uss.umt.service.MberManageVO;
public interface CertIpService {
// public List<MberCertPhoneVO> selectMberCertPhoneList(String userId);
//
// public StatusResponse insertMberCertPhoneInfo(MberCertPhoneVO mberCertPhoneVO);
//
// public StatusResponse deleteCertPhoneInfo(MberCertPhoneVO mberCertPhoneVO);
//
// public List<MberCertPhoneVO> selectMberCertPhoneListVO(MberCertPhoneVO mberCertPhoneVO);
//
// public StatusResponse findByCertPhoneInfo(MberCertPhoneVO mberCertPhoneVO);
//
// public StatusResponse updateMberCertPhoneInfo(MberCertPhoneVO mberCertPhoneVO);
public StatusResponse selectMberCertIpList(MberCertIpVO mberCertPhoneVO);
public StatusResponse insertCertIp(MberCertIpVO mberCertIpVO);
}

View File

@ -0,0 +1,71 @@
package itn.let.cert.ip.service;
import itn.let.uss.umt.service.UserDefaultVO;
/**
*
* @author : 이호영
* @fileName : MberCertPhoneVO.java
* @date : 2024.11.18
* @description : 발신번호 lettngnrlmber_cert_ip 관련 vo
* ===========================================================
* DATE AUTHOR NOTE
* ----------------------------------------------------------- *
* 2024.11.18 이호영 최초 생성
*
*
*
*/
public class MberCertIpVO extends UserDefaultVO{
/**
* @description :
*/
private static final long serialVersionUID = 1L;
private String mberId;
private String certIp;
private String certMemo;
private String certUseYn;
private String certMbtlnum;
public String getMberId() {
return mberId;
}
public void setMberId(String mberId) {
this.mberId = mberId;
}
public String getCertIp() {
return certIp;
}
public void setCertIp(String certIp) {
this.certIp = certIp;
}
public String getCertMemo() {
return certMemo;
}
public void setCertMemo(String certMemo) {
this.certMemo = certMemo;
}
public String getCertUseYn() {
return certUseYn;
}
public void setCertUseYn(String certUseYn) {
this.certUseYn = certUseYn;
}
public String getCertMbtlnum() {
return certMbtlnum;
}
public void setCertMbtlnum(String certMbtlnum) {
this.certMbtlnum = certMbtlnum;
}
}

View File

@ -0,0 +1,32 @@
package itn.let.cert.ip.service.impl;
import java.util.List;
import org.springframework.stereotype.Repository;
import egovframework.rte.psl.dataaccess.EgovAbstractDAO;
import itn.let.cert.ip.service.MberCertIpVO;
import itn.let.lett.service.LetterVO;
import itn.let.mail.service.StatusResponse;
import itn.let.mjo.addr.service.AddrVO;
import itn.let.mjo.msg.service.MjonMsgVO;
import itn.let.mjo.msgdata.service.MjonMsgDataVO;
import itn.let.sym.site.service.JoinSettingVO;
import itn.let.uat.uia.service.MberCertPhoneVO;
import itn.let.uat.uia.web.SendLogVO;
import itn.let.uss.umt.service.MberManageVO;
@Repository("CertIpDAO")
public class CertIpDAO extends EgovAbstractDAO {
public List<MberCertIpVO> selectMberCertIpList(MberCertIpVO mberCertPhoneVO) {
return (List<MberCertIpVO>) list("MberCertIpVO.selectMberCertIpList", mberCertPhoneVO);
}
public void insertCertIp(MberCertIpVO mberCertIpVO) {
insert("MberCertIpVO.insertCertIp", mberCertIpVO);
}
}

View File

@ -0,0 +1,36 @@
package itn.let.cert.ip.service.impl;
import java.time.LocalDateTime;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import egovframework.rte.fdl.cmmn.EgovAbstractServiceImpl;
import itn.let.cert.ip.service.CertIpService;
import itn.let.cert.ip.service.MberCertIpVO;
import itn.let.mail.service.StatusResponse;
@Service("CertIpService")
public class CertIpServiceImpl extends EgovAbstractServiceImpl implements CertIpService {
@Resource(name = "CertIpDAO")
private CertIpDAO certIpDAO;
@Override
public StatusResponse selectMberCertIpList(MberCertIpVO mberCertPhoneVO) {
List<MberCertIpVO> mberCertIpListVO = certIpDAO.selectMberCertIpList(mberCertPhoneVO);
return new StatusResponse(HttpStatus.OK, mberCertIpListVO, LocalDateTime.now());
}
@Override
public StatusResponse insertCertIp(MberCertIpVO mberCertIpVO) {
certIpDAO.insertCertIp(mberCertIpVO);
return new StatusResponse(HttpStatus.OK, "등록 하였습니다.", LocalDateTime.now());
}
}

View File

@ -0,0 +1,140 @@
package itn.let.cert.ip.web;
import java.time.LocalDateTime;
import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import egovframework.rte.fdl.security.userdetails.util.EgovUserDetailsHelper;
import itn.com.cmm.LoginVO;
import itn.com.utl.fcc.service.EgovStringUtil;
import itn.let.cert.ip.service.CertIpService;
import itn.let.cert.ip.service.MberCertIpVO;
import itn.let.mail.service.StatusResponse;
/**
*
* @author : 이호영
* @fileName : CertIpController.java
* @date : 2024.11.19
* @description : 허용 IP 관련 컨트롤러
* ===========================================================
* DATE AUTHOR NOTE
* ----------------------------------------------------------- *
* 2024.11.19 이호영 최초 생성
*
*
*
*/
@Controller
public class CertIpController {
/* certIpService */
@Resource(name = "CertIpService")
private CertIpService certIpService;
@RequestMapping(value = {"/cert/ip/selectMberCertIpList.do"})
public ResponseEntity<StatusResponse> selectMberCertIpList(MberCertIpVO mberCertPhoneVO) throws Exception {
System.out.println("????????????????????????????");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("jsonView");
//로그인 권한정보 불러오기
LoginVO loginVO = EgovUserDetailsHelper.isAuthenticated()? (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser():null;
String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
if(userId == null) {
if(StringUtils.isEmpty(userId)) return ResponseEntity.ok().body(new StatusResponse(HttpStatus.BAD_REQUEST, "로그인 후 이용해 주세요", LocalDateTime.now()));
}
mberCertPhoneVO.setMberId(userId);
return ResponseEntity.ok().body(certIpService.selectMberCertIpList(mberCertPhoneVO));
}
@RequestMapping(value = {"/cert/ip/insertCertIp.do"})
public ResponseEntity<StatusResponse> insertCertIp(MberCertIpVO mberCertIpVO) throws Exception {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("jsonView");
//로그인 권한정보 불러오기
LoginVO loginVO = EgovUserDetailsHelper.isAuthenticated()? (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser():null;
String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
if(userId == null) {
if(StringUtils.isEmpty(userId)) return ResponseEntity.ok().body(new StatusResponse(HttpStatus.BAD_REQUEST, "로그인 후 이용해 주세요", LocalDateTime.now()));
}
mberCertIpVO.setFrstRegisterId(userId);
mberCertIpVO.setMberId(userId);
return ResponseEntity.ok().body(certIpService.insertCertIp(mberCertIpVO));
}
/*
@RequestMapping(value = {"/cert/ip/findByCertIp.do"})
public ResponseEntity<StatusResponse> findByCertIp(MberCertIpVO mberCertPhoneVO) throws Exception {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("jsonView");
//로그인 권한정보 불러오기
LoginVO loginVO = EgovUserDetailsHelper.isAuthenticated()? (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser():null;
String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
if(userId == null) {
if(StringUtils.isEmpty(userId)) return ResponseEntity.ok().body(new StatusResponse(HttpStatus.BAD_REQUEST, "로그인 후 이용해 주세요", LocalDateTime.now()));
}
return ResponseEntity.ok().body(certIpService.findByCertPhoneInfo(mberCertPhoneVO));
}
@RequestMapping(value = {"/uss/umt/user/updateCertPhone.do"})
public ResponseEntity<StatusResponse> updateCertPhone(MberCertPhoneVO mberCertPhoneVO) throws Exception {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("jsonView");
//로그인 권한정보 불러오기
LoginVO loginVO = EgovUserDetailsHelper.isAuthenticated()? (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser():null;
String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
if(userId == null) {
if(StringUtils.isEmpty(userId)) return ResponseEntity.ok().body(new StatusResponse(HttpStatus.BAD_REQUEST, "로그인 후 이용해 주세요", LocalDateTime.now()));
}
mberCertPhoneVO.setFrstRegisterId(userId);
return ResponseEntity.ok().body(certIpService.updateMberCertPhoneInfo(mberCertPhoneVO));
}
@RequestMapping(value = {"/uss/umt/user/deleteCertPhone.do"})
public ResponseEntity<StatusResponse> deleteCertPhone(MberCertPhoneVO mberCertPhoneVO) throws Exception {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("jsonView");
//로그인 권한정보 불러오기
LoginVO loginVO = EgovUserDetailsHelper.isAuthenticated()? (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser():null;
String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
if(userId == null) {
if(StringUtils.isEmpty(userId)) return ResponseEntity.ok().body(new StatusResponse(HttpStatus.BAD_REQUEST, "로그인 후 이용해 주세요", LocalDateTime.now()));
}
mberCertPhoneVO.setLastUpdusrId(userId);
return ResponseEntity.ok().body(certIpService.deleteCertPhoneInfo(mberCertPhoneVO));
}
*/
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings cacheModelsEnabled="true" useStatementNamespaces="true" />
<sqlMap resource="egovframework/sqlmap/let/cert/MjonCertIp_SQL_mysql.xml"/> <!-- 문자메세지 -->
</sqlMapConfig>

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?><!--
수정일 수정자 수정내용
========= ======= =================================================
2021.03.01 신명섭
-->
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="MjonCert">
<typeAlias alias="mberCertIpVO" type="itn.let.cert.ip.service.MberCertIpVO"/>
<select id="MberCertIpVO.selectMberCertIpList" parameterClass="mberCertIpVO" resultClass="mberCertIpVO">
SELECT
MBER_ID as mberId
, CERT_IP as certIp
, CERT_MEMO as certMemo
, CERT_USE_YN as certUseYn
, FRST_REGIST_PNTTM as frstRegistPnttm
, FRST_REGISTER_ID as frstRegisterId
, LAST_UPDT_PNTTM as lastUpdtPnttm
, LAST_UPDUSR_ID as lastUpdusrId
FROM
LETTNGNRLMBER_CERT_IP
where
MBER_ID = #mberId#
</select>
<insert id="MberCertIpVO.insertCertIp">
INSERT INTO LETTNGNRLMBER_CERT_IP
(
MBER_ID
, CERT_IP
, CERT_MEMO
, LAST_UPDT_PNTTM
, FRST_REGISTER_ID
)
VALUES
(
#mberId#
, #certIp#
, #certMemo#
, now()
, #frstRegisterId#
)
</insert>
</sqlMap>

View File

@ -28,7 +28,7 @@
WHERE 1=1
<isNotEmpty property="searchKeyword">
<isEqual property="searchCondition" compareValue="" >
AND ( A.USER_ID LIKE CONCAT('%', #searchKeyword#, '%')
AND ( A.USER_ID LIKE CONCAT('%', #searchKeyword#, '%')MjonMsgCustom_SQL_mysql.xmlMjonMsgCustom_SQL_mysql.xmlMjonMsgCustom_SQL_mysql.xmlMjonMsgCustom_SQL_mysql.xml
OR CUSTOM_PHONE_NO LIKE CONCAT ('%', #searchKeyword#,'%') )
</isEqual>
<isEqual property="searchCondition" compareValue="1">

View File

@ -51,9 +51,6 @@ $(document).ready(function(){
$('#showLoginBtn').on('click', function() {
$('.security_login').fadeIn(); // 서서히 나타나도록 설정
});
});
@ -64,17 +61,148 @@ $(document).ready(function(){
$('#showLoginBtn').on('click', function() {
if ($('#securityLogin').is(':visible')) {
$('#securityLogin').fadeOut(); // 서서히 사라짐
$(this).text('보안 로그인 표시'); // 버튼 텍스트 변경
$('#securityLogin').hide();
} else {
$('#securityLogin').fadeIn(); // 서서히 나타남
$(this).text('보안 로그인 숨기기'); // 버튼 텍스트 변경
$('#securityLogin').show();
}
});
// IP 추가 버튼 클릭 시 tr 추가
$(".btn_ip_plus").click(function () {
// 추가할 HTML 구조
const ipTr = `
<tr class="ip-new">
<td><input type="text" class="input_text"></td>
<td><input type="text" class="input_text"></td>
<td>-</td>
<td>
<button type="button" class="btnType btnType5" id="ipRegBtn">등록</button>
</td>
</tr>
`;
// 이미 추가된 `.ip-row`가 있는지 확인
if ($(".ip_table tbody .ip-new").length === 0) {
$(".ip_table tbody").prepend(ipTr); // 중복되지 않으면 추가
} else {
alert("이미 추가된 항목이 있습니다.");
}
});
$(document).on('click', '#ipRegBtn', function () {
// 현재 클릭된 버튼의 부모 tr 요소
const $currentRow = $(this).closest('tr');
// 입력값 가져오기
const ipValue = $currentRow.find('td:eq(0) input').val(); // 첫 번째 열 (IP)
const memoValue = $currentRow.find('td:eq(1) input').val(); // 두 번째 열 (메모)
// 예외 처리
if (!ipValue) {
alert("등록할 IP를 입력해주세요.");
$currentRow.find('td:eq(0) input').focus();
return;
}
// 추가 동작 (예: 서버 전송)
// alert(`입력된 IP: ${ipValue}, 메모: ${memoValue}`);
var params = {
"certIp" : ipValue
, "certMemo" : memoValue
}
console.log('params : ', params);
if(!confirm("IP를 등록 하시겠습니까?")){
return false;
}
$.ajax({
type: "POST",
url: "/cert/ip/insertCertIp.do",
data: params,
dataType:'json',
async: false,
success: function (returnData) {
if(returnData.status == 'OK'){
const objects = returnData.object; // 배열 데이터
let rows = ""; // 추가할 행들
// 배열 데이터를 순회하며 각 행 생성
objects.forEach((obj) => {
rows += `
<tr>
<td>${obj.certIp || "-"}</td>
<td>${obj.certMemo || "-"}</td>
<td>${obj.lastUpdtPnttm || "-"}</td>
<td>
<button type="button" class="btnType btn_text btn_lightgray fill btn_28">삭제</button>
</td>
</tr>
`;
});
// 기존 tbody 비우고 새 행 추가
$(".ip_table tbody").html(rows);
}
else
{
alert("오류가 발생하였습니다.");
}
},
error: function (e) { alert("오류가 발생하였습니다."); console.log("ERROR : ", e); }
});
});
findAllCertIp();
});
function findAllCertIp(){
console.log('findAllCertIp : ', findAllCertIp);
$.ajax({
type: "POST",
url: "/cert/ip/selectMberCertIpList.do",
data: null,
dataType:'json',
async: false,
success: function (returnData) {
if (returnData.status === "OK") {
const objects = returnData.object; // 배열 데이터
let rows = ""; // 추가할 행들
objects.forEach((obj) => {
rows += `
<tr>
<td>${obj.certIp || "-"}</td> <!-- 허용 IP -->
<td>${obj.certMemo || "-"}</td> <!-- 메모 -->
<td>${obj.lastUpdtPnttm || "-"}</td> <!-- 등록일시 -->
<td>
<button type="button" class="btnType btn_text btn_lightgray fill btn_28" onclick="deleteRow(this)">삭제</button>
</td>
</tr>
`;
});
// 생성된 rows를 tbody에 삽입
$(".ip_table tbody").html(rows);
} else {
alert("데이터를 불러오는 데 실패했습니다.");
}
},
error: function (e) { alert("오류가 발생하였습니다."); console.log("ERROR : ", e); }
});
}
//기간 요일 지정
function setCalVal(val,targetObj){
$('input[name='+targetObj+']').val(val) ;
@ -511,8 +639,8 @@ function getMberGrdChk() {
<!-- 보안로그인 -->
<!-- 보안로그인 -->
<!-- 보안로그인 -->
<!-- <div class="security_login" id="showLoginBtn" style="display: none;"> -->
<div class="security_login" id="securityLogin" style="display: none;">
<!-- <div class="security_login" id="securityLogin" style="display: none;"> -->
<div class="security_login" id="securityLogin">
<ul class="explanation_wrap box info">
<li>· 사이트 부정로그인으로 인한 피해를 방지할 수 있는 2차 로그인 인증 서비스입니다. </li>
@ -564,12 +692,6 @@ function getMberGrdChk() {
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" class="input_text"></td>
<td><input type="text" class="input_text"></td>
<td>-</td>
<td><button type="button" class="btnType btnType5">등록</button></td>
</tr>
<tr>
<td>192.168.0.0</td>
<td>dadfadfjadkfjalkdjfajflajdlfjaldjflajd</td>