414 lines
15 KiB
Java
414 lines
15 KiB
Java
package seed.utils;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Random;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.ibm.icu.text.SimpleDateFormat;
|
|
import com.sci.v2.ipin.secu.SciSecuManager;
|
|
import com.sci.v2.ipin.secu.hmac.SciHmac;
|
|
|
|
import kcc.com.utl.fcc.service.EgovNumberUtil;
|
|
import kcc.com.utl.fcc.service.EgovStringUtil;
|
|
|
|
public class FairnetUtils {
|
|
|
|
public static boolean hasAuth(
|
|
int p_memberIdx
|
|
, String p_memberGrant
|
|
, boolean p_memberAuth
|
|
, HttpSession p_session
|
|
, Map<String, Object> p_map
|
|
) {
|
|
boolean b_ret = true;
|
|
|
|
//기존 권한 관리 부분을 주석 처리함 - 필요시 사용할것
|
|
//egov 권한으로 대체 예정
|
|
/*
|
|
try {
|
|
if(p_memberIdx == 0 || (!p_memberGrant.equals("S") && !p_memberAuth)){
|
|
setSessionRemove(p_session);
|
|
p_map.put("url", "/gtm/login.do");
|
|
p_map.put("url", "/uat/uia/EgovLoginUsr.do");
|
|
p_map.put("message", "common.message.no.grant");
|
|
//return new ModelAndView("/_common/jsp/message");
|
|
b_ret = false;
|
|
}
|
|
}catch(Exception ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
*/
|
|
|
|
return b_ret;
|
|
}
|
|
|
|
public static boolean hasUserAuth(
|
|
int p_memberIdx
|
|
, String p_memberGrant
|
|
, boolean p_memberAuth
|
|
, HttpSession p_session
|
|
, Map<String, Object> p_map
|
|
) {
|
|
boolean b_ret = true;
|
|
|
|
//기존 권한 관리 부분을 주석 처리함 - 필요시 사용할것
|
|
//egov 권한으로 대체 예정
|
|
/*
|
|
try {
|
|
if(!memberGrant.equals("S") && !memberAuthM && !memberAuth && !managerSiteMenuAuthService.getSiteMenuAuthChk(siteMenuIdx, memberIdx)){
|
|
|
|
map.put("message", "common.message.no.grant");
|
|
|
|
if(memberIdx.equals(0)){
|
|
map.put("url", "/"+siteIdx+"/index.do");
|
|
}else{
|
|
map.put("self", "history");
|
|
}
|
|
|
|
//return new ModelAndView("/_common/jsp/umessage");
|
|
b_ret = false;
|
|
}
|
|
}catch(Exception ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
*/
|
|
|
|
return b_ret;
|
|
}
|
|
|
|
public static ModelMap myCheck(
|
|
ModelMap p_map
|
|
, HttpSession p_session
|
|
) {
|
|
boolean b_ret = true;
|
|
|
|
//인증여부 체크용
|
|
/*
|
|
try {
|
|
if(SeedUtils.setReplaceNull(p_session.getAttribute("hpName")).equals("")){
|
|
p_map.put("siteIdx", "case");
|
|
p_map.put("url", "/web/user/mypage/case/01/168/myCheck.do");
|
|
p_map.put("message", "common.message.my.check");
|
|
p_map.put("opener", "");
|
|
p_map.put("append", "");
|
|
p_map.put("self", "");
|
|
|
|
b_ret = false;
|
|
}
|
|
|
|
}catch(Exception ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
*/
|
|
|
|
p_map.put("b_ret", b_ret);
|
|
|
|
return p_map;
|
|
}
|
|
|
|
|
|
public static void certSet(ModelMap map, HttpServletRequest req, HttpSession session,String commandCode ) {
|
|
|
|
String nextUrl = req.getParameter("nextUrl");
|
|
// String commandCode = req.getParameter("commandCode");
|
|
|
|
String srvNo = "";
|
|
String hpSrvNo = "";
|
|
String agreeCheck = "";
|
|
String personalCheck = "";
|
|
String mediType = "";
|
|
String retUrl = "";//아이핀 인증후 리턴 페이지
|
|
String hpRetUrl = "";//모바일 인증후 리턴 페이지
|
|
|
|
String sServerName = req.getServerName();
|
|
|
|
if(commandCode.equals("medi")){//분쟁조정신청 본인인증
|
|
|
|
//개발서버
|
|
// srvNo = "007001";// 아이핀 코드
|
|
// hpSrvNo = "008001";//휴대폰 코드
|
|
|
|
//실서버
|
|
srvNo = "009001";// 아이핀 코드
|
|
hpSrvNo = "012001";//휴대폰 코드
|
|
|
|
agreeCheck = req.getParameter("agreeCheck");
|
|
personalCheck = req.getParameter("personalCheck");
|
|
mediType = req.getParameter("mediType");
|
|
|
|
// retUrl = "23http://fairnet.kofair.or.kr/user/extra/case/siren/ipin_popup_seed/jsp/Page.do";
|
|
retUrl = CertGlobalSet.getRetUrl() + "/user/extra/case/siren/ipin_popup_seed/jsp/Page.do";
|
|
|
|
// hpRetUrl = "32http://fairnet.kofair.or.kr/user/extra/case/siren/hpParamPop/jsp/Page.do";
|
|
hpRetUrl = CertGlobalSet.getHpRetUrl() + "/user/extra/case/siren/hpParamPop/jsp/Page.do";
|
|
|
|
session.setAttribute("agreeCheck", agreeCheck);
|
|
session.setAttribute("personalCheck", personalCheck);
|
|
session.setAttribute("mediType", mediType);
|
|
//hpName존재하면 이미 본인인증을 거쳤기 때문에 다음으로 바로 넘어간다.
|
|
if(!SeedUtils.setReplaceNull(session.getAttribute("hpName")).equals("")){
|
|
// nextUrl = "/user/mediation/case/05/154/mediationStep04Ftc.do";
|
|
nextUrl = "/user/mediation/case/05/154/mediationStep04.do";
|
|
}
|
|
}else if(commandCode.equals("my")){//마이페이지 본인인증
|
|
//개발서버
|
|
// srvNo = "007002";
|
|
// hpSrvNo = "008002";
|
|
|
|
//실서버
|
|
srvNo = "009002";
|
|
// hpSrvNo = "012002";
|
|
hpSrvNo = CertGlobalSet.getHpSrvNo();
|
|
|
|
// retUrl = "23http://fairnet.kofair.or.kr/user/extra/case/siren/myPage_ipin_popup_seed/jsp/Page.do";
|
|
retUrl = CertGlobalSet.getRetUrl() + "/web/user/extra/case/siren/myPage_ipin_popup_seed/jsp/Page.do";
|
|
|
|
// hpRetUrl = "32http://fairnet.kofair.or.kr/user/extra/case/siren/myPage_hpParamPop/jsp/Page.do";
|
|
// hpRetUrl = CertGlobalSet.getHpRetUrl() + "/web/user/extra/case/siren/myPage_hpParamPop/jsp/Page.do";
|
|
hpRetUrl = CertGlobalSet.getHpRetUrl() + "/web/user/siren/case/04/154/check.do";
|
|
|
|
}else if(commandCode.equals("online")){//온라인 분쟁조정 상담 본인인증
|
|
//개발서버
|
|
srvNo = "007003";
|
|
hpSrvNo = "008003";
|
|
|
|
//실서버
|
|
// srvNo = "009003";
|
|
// hpSrvNo = "012003";
|
|
|
|
personalCheck = req.getParameter("personalCheck");
|
|
session.setAttribute("personalCheck", personalCheck);
|
|
|
|
// retUrl = "23http://fairnet.kofair.or.kr/user/extra/case/siren/onlineCounsel_ipin_popup_seed/jsp/Page.do";
|
|
retUrl = CertGlobalSet.getRetUrl() + "/user/extra/case/siren/onlineCounsel_ipin_popup_seed/jsp/Page.do";
|
|
|
|
// hpRetUrl = "32http://fairnet.kofair.or.kr/user/extra/case/siren/onlineCounsel_hpParamPop/jsp/Page.do";
|
|
hpRetUrl = CertGlobalSet.getHpRetUrl() + "/user/extra/case/siren/onlineCounsel_hpParamPop/jsp/Page.do";
|
|
|
|
//hpName존재하면 이미 본인인증을 거쳤기 때문에 다음으로 바로 넘어간다.
|
|
if(!SeedUtils.setReplaceNull(session.getAttribute("hpName")).equals("")){
|
|
nextUrl = "/user/onlineCounsel/case/01/158/write.do";
|
|
}
|
|
}else if(commandCode.equals("law")){
|
|
//개발서버
|
|
// srvNo = "007004";
|
|
// hpSrvNo = "008005";
|
|
|
|
//실서버
|
|
srvNo = "009004";
|
|
hpSrvNo = "012004";
|
|
|
|
personalCheck = req.getParameter("personalCheck");
|
|
session.setAttribute("personalCheck", personalCheck);
|
|
|
|
// retUrl = "23http://fairnet.kofair.or.kr/user/extra/case/siren/lawCounsel_ipin_popup_seed/jsp/Page.do";
|
|
retUrl = CertGlobalSet.getRetUrl() + "/user/extra/case/siren/lawCounsel_ipin_popup_seed/jsp/Page.do";
|
|
|
|
// hpRetUrl = "32http://fairnet.kofair.or.kr/user/extra/case/siren/lawCounsel_hpParamPop/jsp/Page.do";
|
|
hpRetUrl = CertGlobalSet.getHpRetUrl() + "/user/extra/case/siren/lawCounsel_hpParamPop/jsp/Page.do";
|
|
|
|
//hpName존재하면 이미 본인인증을 거쳤기 때문에 다음으로 바로 넘어간다.
|
|
if(!SeedUtils.setReplaceNull(session.getAttribute("hpName")).equals("")){
|
|
nextUrl = "/user/lawCounsel/case/02/159/lawWrite.do";
|
|
}
|
|
}else if(commandCode.equals("medi_check")){
|
|
//개발서버
|
|
// srvNo = "007005";
|
|
// hpSrvNo = "008006";
|
|
|
|
//실서버
|
|
srvNo = "009005";
|
|
hpSrvNo = "012005";
|
|
|
|
String caseNo = req.getParameter("caseNo");
|
|
String checkPass = req.getParameter("checkPass");
|
|
|
|
session.setAttribute("caseNo", caseNo);
|
|
session.setAttribute("checkPass", checkPass);
|
|
|
|
// retUrl = "23http://fairnet.kofair.or.kr/user/extra/case/siren/checkMedi_ipin_popup_seed/jsp/Page.do";
|
|
retUrl = CertGlobalSet.getRetUrl() + "/user/extra/case/siren/checkMedi_ipin_popup_seed/jsp/Page.do";
|
|
|
|
// hpRetUrl = "32http://fairnet.kofair.or.kr/user/extra/case/siren/checkMedi_hpParamPop/jsp/Page.do";
|
|
hpRetUrl = CertGlobalSet.getHpRetUrl() + "/user/extra/case/siren/checkMedi_hpParamPop/jsp/Page.do";
|
|
|
|
//hpName존재하면 이미 본인인증을 거쳤기 때문에 다음으로 바로 넘어간다.
|
|
/* if(!SeedUtils.setReplaceNull(session.getAttribute("hpName")).equals("")){
|
|
nextUrl = "/user/mediation/case/03/155/checkMediationStep03.do";
|
|
}*/
|
|
}
|
|
|
|
//나중에 메인 페이지 나오면 튕겨내기
|
|
// if(nextUrl == null || agreeCheck == null){
|
|
// map.put("siteIdx", "case");
|
|
// map.put("url", "/case/index.do");
|
|
// map.put("message", "잘못된 접근 입니다.");
|
|
// map.put("opener", "");
|
|
// map.put("append", "");
|
|
// map.put("self", "");
|
|
//
|
|
// return "/_commccon/jsp/umessage";
|
|
// throw new RuntimeException("강제 예외 발생!");
|
|
// }
|
|
|
|
|
|
/**
|
|
* 아이핀 인증 시작 */
|
|
|
|
//String sServerName = req.getServerName();
|
|
|
|
//회원사 ID : KFA001
|
|
String id = "KFA001";
|
|
//회원가입화면용 결과 수신 URL : 23http:/211.43.219.170/hp/meb/pinSignupView.do
|
|
//String retUrl = "23http://ServerName/user/extra/case/siren/ipin_popup_seed/jsp/Page.do";
|
|
//retUrl = retUrl.replaceAll("ServerName", sServerName);
|
|
//분쟁조정신청 서비스 번호 : 006001
|
|
// String srvNo = "006001";
|
|
//요청번호(유닉크한 랜덤값) : 40 byte까지
|
|
String reqNum = "kofair" + EgovStringUtil.getTimeStamp() + EgovNumberUtil.getRandomNum(1000, 9999);
|
|
|
|
session.setAttribute("id", id);
|
|
session.setAttribute("retUrl", retUrl);
|
|
session.setAttribute("srvNo", srvNo);
|
|
session.setAttribute("reqNum", reqNum);
|
|
//복호화용 임시필드
|
|
|
|
String exVar = "0000000000000000";
|
|
|
|
/**
|
|
*
|
|
* reqNum 값은 최종 결과값 복호화를 위한 SecuKey로 활용 되므로 중요합니다.
|
|
* reqNum 은 아이핀 서비스 요청시 항상 새로운 값으로 중복 되지 않게 생성 해야 합니다.
|
|
* 쿠키 또는 Session및 기타 방법을 사용해서 reqNum 값을
|
|
* ipin_result_seed.jsp에서 가져 올 수 있도록 해야 함.
|
|
* 샘플을 위해서 쿠키를 사용한 것이므로 참고 하시길 바랍니다.
|
|
*
|
|
*/
|
|
/* Cookie c = new Cookie("reqNum", reqNum);
|
|
//c.setMaxAge(1800); // <== 필요시 설정(초단위로 설정됩니다)
|
|
response.addCookie(c);*/
|
|
|
|
session.setAttribute("reqNumKey", reqNum);
|
|
|
|
// 암호화 모듈 선언
|
|
SciSecuManager seed = new SciSecuManager();
|
|
// 1차 암호화
|
|
String encStr = "";
|
|
String reqInfo = reqNum + "/" + id + "/" + srvNo + "/" + exVar;
|
|
encStr = seed.getEncPublic(reqInfo);
|
|
// 위변조 검증 값 등록
|
|
SciHmac hmac = new SciHmac();
|
|
String hmacMsg = SciHmac.HMacEncriptPublic(encStr);
|
|
// 2차 암호화
|
|
reqInfo = seed.getEncPublic(encStr + "/" + hmacMsg + "/" + "00000000");
|
|
session.setAttribute("reqInfo", reqInfo);
|
|
|
|
/**
|
|
* 아이핀 인증 끝 */
|
|
|
|
|
|
/**
|
|
* 핸드폰 인증 시작 */
|
|
|
|
//날짜 생성
|
|
Calendar today = Calendar.getInstance();
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
String day = sdf.format(today.getTime());
|
|
|
|
java.util.Random ran = new Random();
|
|
//랜덤 문자 길이
|
|
int numLength = 6;
|
|
String randomStr = "";
|
|
|
|
for (int i = 0; i < numLength; i++) {
|
|
//0 ~ 9 랜덤 숫자 생성
|
|
randomStr += ran.nextInt(10);
|
|
}
|
|
|
|
//reqNum은 최대 40byte 까지 사용 가능
|
|
|
|
String hpId = "SKFA001"; // 본인실명확인 회원사 아이디
|
|
//String hpSrvNo = "005001"; // 본인실명확인 서비스번호
|
|
String hpReqNum = day + randomStr; // 본인실명확인 요청번호
|
|
String hpExVar = "0000000000000000"; // 복호화용 임시필드
|
|
String hpCertDate = day; // 본인실명확인 요청시간
|
|
String hpCertGb = "H"; // 본인실명확인 본인확인 인증수단
|
|
String hpAddVar = ""; // 본인실명확인 추가 파라메터
|
|
|
|
//String hpRetUrl = "32http://ServerName/kmcis/kmcisIdSearch.jsp"; // 본인인증서비스 결과수신 POPUP URL
|
|
//String hpRetUrl = "32http://ServerName/user/extra/case/siren/hpParamPop/jsp/Page.do";
|
|
|
|
//hpRetUrl = "32http://kofair2.global-it.co.kr/kmcis/kmcisIdSearch.jsp";
|
|
//hpRetUrl = hpRetUrl.replaceAll("ServerName", sServerName); //오픈할 때 주석으로 교체해줘야함
|
|
|
|
|
|
/**
|
|
*
|
|
* reqNum 값은 최종 결과값 복호화를 위한 SecuKey로 활용 되므로 중요합니다.
|
|
* reqNum 은 본인 확인 요청시 항상 새로운 값으로 중복 되지 않게 생성 해야 합니다.
|
|
* 쿠키 또는 Session및 기타 방법을 사용해서 reqNum 값을
|
|
* pcc_V3_result_seed.jsp에서 가져 올 수 있도록 해야 함.
|
|
* 샘플을 위해서 쿠키를 사용한 것이므로 참고 하시길 바랍니다.
|
|
*
|
|
*/
|
|
/*Cookie hpC = new Cookie("hpReqNum", hpReqNum);
|
|
//c.setMaxAge(1800); // <== 필요시 설정(초단위로 설정됩니다)
|
|
response.addCookie(hpC);*/
|
|
|
|
// session.setAttribute("hpReqNumKey", hpReqNum);
|
|
req.getSession().setAttribute("hpReqNumKey", hpReqNum); // 결과값 복호화시 필요
|
|
|
|
//01. 암호화 모듈 선언
|
|
com.sci.v2.pcc.secu.SciSecuManager hpSeed = new com.sci.v2.pcc.secu.SciSecuManager();
|
|
|
|
//02. 1차 암호화
|
|
String hpEncStr = "";
|
|
String hpReqInfo = hpId+"^"+hpSrvNo+"^"+hpReqNum+"^"+hpCertDate+"^"+hpCertGb+"^"+hpAddVar+"^"+hpExVar; // 데이터 암호화
|
|
hpEncStr = hpSeed.getEncPublic(hpReqInfo);
|
|
|
|
//03. 위변조 검증 값 생성
|
|
com.sci.v2.pcc.secu.hmac.SciHmac hpHmac = new com.sci.v2.pcc.secu.hmac.SciHmac();
|
|
String hpHmacMsg = hpHmac.HMacEncriptPublic(hpEncStr);
|
|
|
|
//03. 2차 암호화
|
|
hpReqInfo = hpSeed.getEncPublic(hpEncStr + "^" + hpHmacMsg + "^" + "0000000000000000"); //2차암호화
|
|
|
|
// session.setAttribute("hpRetUrl", hpRetUrl);
|
|
// session.setAttribute("hpReqInfo", hpReqInfo);
|
|
req.getSession().setAttribute("hpRetUrl", hpRetUrl);
|
|
req.getSession().setAttribute("hpReqInfo", hpReqInfo);
|
|
|
|
/**
|
|
* 핸드폰 인증 끝 */
|
|
|
|
}
|
|
|
|
/*첨부파일 목록의 정보를 이노릭스 화면에서 사용하기 위한 정보로 리턴*/
|
|
public static String innorixFileListInfo(List<Map<String, Object>> fileList) throws Exception {
|
|
|
|
List<Map<String, Object>> innorixFileListInfo = new ArrayList<>();
|
|
for (Map<String, Object> file : fileList) {
|
|
Map<String, Object> innorixFileInfo = new HashMap<>();
|
|
innorixFileInfo.put("printFileName", file.get("EXTRA_FILE_NAME"));
|
|
innorixFileInfo.put("fileSize", file.get("EXTRA_FILE_SIZE"));
|
|
innorixFileInfo.put("dataIdx", file.get("EXTRA_FILE_IDX"));
|
|
innorixFileInfo.put("downloadUrl", "notUse"); //해당 값 없으면 목록이 안나와 임시로 사용
|
|
innorixFileListInfo.add(innorixFileInfo);
|
|
}
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
String innorixFileListInfoStr = objectMapper.writeValueAsString(innorixFileListInfo);
|
|
|
|
return innorixFileListInfoStr;
|
|
|
|
}
|
|
} |