hubez-admin partner-git master -> hubez-git transfer 202205241800

This commit is contained in:
hyunjin35
2022-05-24 18:12:19 +09:00
parent 013e992bc7
commit ad80b88089
309 changed files with 50355 additions and 91 deletions

View File

@@ -0,0 +1,21 @@
package kr.co.uplus.ez;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class Scheduler {
private static final Logger log = LoggerFactory.getLogger(Scheduler.class);
/**
* 스케줄러 트리거는 해당영역에 선언 / 서비스영역은 별도
*/
@Scheduled(initialDelay = 60000, fixedRateString = "${schedule.sample.init:60000}")
public void init() {
// 스케줄 서비스 정의
log.info("schduler trigger");
}
}

View File

@@ -0,0 +1,73 @@
package kr.co.uplus.ez;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.core.env.AbstractEnvironment;
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
public class WebApplication extends SpringBootServletInitializer {
private static final Logger log = LoggerFactory.getLogger(WebApplication.class);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebApplication.class);
}
public static void main(String[] args) throws Exception {
if (System.getProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME) == null) {
System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "local");
}
SpringApplication.run(WebApplication.class, args);
}
@PostConstruct
public void onStartup() {
Thread checkThread = new Thread(new CheckProcess());
checkThread.setDaemon(true);
checkThread.start();
log.info("################ System-up start ################");
}
@PreDestroy
public void onExit() {
log.info("################ System-down start ################");
}
}
class CheckProcess implements Runnable {
private static final Logger log = LoggerFactory.getLogger(CheckProcess.class);
private static final String PROC_NAME = "mhez-admin";
@Override
public void run() {
while (true) {
try {
process();
Thread.sleep(1000 * 60);
} catch (InterruptedException e) {
}
}
}
private void process() {
Runtime runtime = Runtime.getRuntime();
long totalMemory = runtime.totalMemory() / (1024 * 1024);
long freeMemory = runtime.freeMemory() / (1024 * 1024);
long maxMemory = runtime.maxMemory() / (1024 * 1024);
long usedMemory = totalMemory - freeMemory;
log.info("{} Process Monitoring : maxMemory -> {}MB, totalMemory -> {}MB, usedMemory -> {}MB, freeMemory -> {}MB, ActiveThread -> {}",
PROC_NAME, maxMemory, totalMemory, usedMemory, freeMemory, Thread.activeCount());
}
}

View File

@@ -0,0 +1,80 @@
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 유치 현황 관리
*/
package kr.co.uplus.ez.api.attractMgt;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/attractMgt")
public class AttractMgtController {
@Autowired
AttractMgtService attractService;
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 유치채널 목록조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/channelList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage channelList(@RequestBody Map<String, Object> paramMap) throws Exception{
return attractService.channelList(paramMap);
}
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 유치채널 목록 엑셀 다운로드
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/channelListExcel" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage channelListExcel(@RequestBody Map<String, Object> paramMap) throws Exception{
return attractService.channelListExcel(paramMap);
}
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 유치 채널 상세 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/channelDetail" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage channelDetail(@RequestBody Map<String, Object> paramMap) throws Exception{
return attractService.channelDetail(paramMap);
}
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 발송건수 엑셀 다운로드
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/sendNumberListExcel" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage sendNumberListExcel(@RequestBody Map<String, Object> paramMap) throws Exception{
return attractService.sendNumberListExcel(paramMap);
}
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.api.attractMgt;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public class AttractMgtMapper {
}

View File

@@ -0,0 +1,230 @@
package kr.co.uplus.ez.api.attractMgt;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@Service
public class AttractMgtService {
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 유치채널 목록조회
* @param paramMap
* @return
*/
public ApiResponseMessage channelList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt", "999");
data.put("currentPage", "1");
dataObj.put("paging", data);
for(int i=1; i<10; i++) {
data = new HashMap<>();
data.put("no", ""+i);
data.put("regDt", "2022-03-10");
data.put("channelNm", "업체명");
data.put("adminId", "uplus01");
data.put("custNm", "유플러스");
data.put("bRegNo", "221-81-39938");
data.put("userNm", "유플러스스");
data.put("stat", "사용");
data.put("custType", "법인사용자");
data.put("totalSendingCnt", "1440000");
data.put("serviceId", "serviceId");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 유치채널 목록 엑셀 다운로드
* @param paramMap
* @return
*/
public ApiResponseMessage channelListExcel(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt", "999");
data.put("currentPage", "1");
dataObj.put("paging", data);
for(int i=1; i<50; i++) {
data = new HashMap<>();
data.put("no", ""+i);
data.put("regDt", "2022-03-10");
data.put("channelNm", "업체명");
data.put("adminId", "uplus01");
data.put("custNm", "유플러스");
data.put("bRegNo", "221-81-39938");
data.put("userNm", "유플러스스");
data.put("stat", "사용");
data.put("custType", "법인사용자");
data.put("totalSendingCnt", "1440000");
data.put("serviceId", "serviceId");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 유치 채널 상세 조회
* @param paramMap
* @return
*/
public ApiResponseMessage channelDetail(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
dataObj.put("subsDt", "2022-03-10");
dataObj.put("stat", "사용");
dataObj.put("custNm", "홍길동");
dataObj.put("plan", "요금제1");
dataObj.put("reprNm", "홍길동");
dataObj.put("custType", "법인사업자");
dataObj.put("bRegNo", "1231212345");
dataObj.put("cprRegNo", "1234561234567");
dataObj.put("adr1", "12345");
dataObj.put("adr2", "서울 마포구 월드컵북로 416");
dataObj.put("adr3", "유플러스 상암사옥");
dataObj.put("channelId", "Uplus01");
dataObj.put("channelNm", "홍길동");
dataObj.put("adminId", "uplus02");
dataObj.put("adminNm", "김철수");
data.put("date", "합계");
data.put("sms", "360000");
data.put("lms", "360000");
data.put("mms", "360000");
data.put("totiTalk", "360000");
data.put("allSendingCnt", "1440000");
dataList.add(data);
data = new HashMap<>();
data.put("date", "2022-03");
data.put("sms", "10000");
data.put("lms", "10000");
data.put("mms", "10000");
data.put("totiTalk", "10000");
data.put("allSendingCnt", "40000");
dataList.add(data);
data = new HashMap<>();
data.put("date", "2022-02");
data.put("sms", "10000");
data.put("lms", "10000");
data.put("mms", "10000");
data.put("totiTalk", "10000");
data.put("allSendingCnt", "40000");
dataList.add(data);
data = new HashMap<>();
data.put("date", "2022-01");
data.put("sms", "10000");
data.put("lms", "10000");
data.put("mms", "10000");
data.put("totiTalk", "10000");
data.put("allSendingCnt", "40000");
dataList.add(data);
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발송건수 엑셀 다운로드
* @param paramMap
* @return
*/
public ApiResponseMessage sendNumberListExcel(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
dataObj.put("subsDt", "2022-03-10");
dataObj.put("stat", "사용");
dataObj.put("custNm", "홍길동");
dataObj.put("plan", "요금제1");
dataObj.put("reprNm", "홍길동");
dataObj.put("custType", "법인사업자");
dataObj.put("bRegNo", "1231212345");
dataObj.put("cprRegNo", "1234561234567");
dataObj.put("adr1", "12345");
dataObj.put("adr2", "서울 마포구 월드컵북로 416");
dataObj.put("adr3", "유플러스 상암사옥");
dataObj.put("channelId", "Uplus01");
dataObj.put("channelNm", "홍길동");
dataObj.put("adminId", "uplus02");
dataObj.put("adminNm", "김철수");
data.put("date", "합계");
data.put("sms", "360000");
data.put("lms", "360000");
data.put("mms", "360000");
data.put("totiTalk", "360000");
data.put("allSendingCnt", "1440000");
dataList.add(data);
data = new HashMap<>();
data.put("date", "2022-03");
data.put("sms", "10000");
data.put("lms", "10000");
data.put("mms", "10000");
data.put("totiTalk", "10000");
data.put("allSendingCnt", "40000");
dataList.add(data);
data = new HashMap<>();
data.put("date", "2022-02");
data.put("sms", "10000");
data.put("lms", "10000");
data.put("mms", "10000");
data.put("totiTalk", "10000");
data.put("allSendingCnt", "40000");
dataList.add(data);
data = new HashMap<>();
data.put("date", "2022-01");
data.put("sms", "10000");
data.put("lms", "10000");
data.put("mms", "10000");
data.put("totiTalk", "10000");
data.put("allSendingCnt", "40000");
dataList.add(data);
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
}

View File

@@ -0,0 +1,52 @@
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 정산
*/
package kr.co.uplus.ez.api.calculate;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/calculate")
public class CalculateController {
@Autowired
CalculateService calculateService;
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 정산 이력 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/calcList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage calcList(@RequestBody Map<String, Object> paramMap) throws Exception{
return calculateService.calcList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 정산 이력 목록 엑셀 다운로드
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/calcListExcel" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage calcListExcel(@RequestBody Map<String, Object> paramMap) throws Exception{
return calculateService.calcListExcel(paramMap);
}
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.api.calculate;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public class CalculateMapper {
}

View File

@@ -0,0 +1,96 @@
package kr.co.uplus.ez.api.calculate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@Service
public class CalculateService {
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 정산 이력 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage calcList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt","999");
data.put("currentPage","1");
dataObj.put("paging", data);
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("date", "2022-02");
data.put("custNm", "유플러스"+(i+1));
data.put("bRegNo", "22-81-39937");
data.put("plan", "요금제1(50000)");
data.put("startAmount", "50000");
data.put("useAmount", "100000");
data.put("carryOverAmount", "-");
data.put("unitAmount", "-");
data.put("extshAmount", "-");
data.put("requestAmount", "100000");
data.put("allSendingCnt", "84000000");
data.put("sms", "21000000");
data.put("lms", "21000000");
data.put("mms", "21000000");
data.put("notiTalk", "21000000");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 정산 이력 목록 엑셀 다운로드
* @param paramMap
* @return
*/
public ApiResponseMessage calcListExcel(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt","999");
data.put("currentPage","1");
dataObj.put("paging", data);
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("date", "2022-02");
data.put("custNm", "유플러스"+(i+1));
data.put("bRegNo", "22-81-39937");
data.put("plan", "요금제1(50000)");
data.put("startAmount", "50000");
data.put("useAmount", "100000");
data.put("carryOverAmount", "-");
data.put("unitAmount", "-");
data.put("extshAmount", "-");
data.put("requestAmount", "100000");
data.put("allSendingCnt", "84000000");
data.put("sms", "21000000");
data.put("lms", "21000000");
data.put("mms", "21000000");
data.put("notiTalk", "21000000");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
}

View File

@@ -0,0 +1,38 @@
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 채널관리
*/
package kr.co.uplus.ez.api.channelMgt;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/channelMgt")
public class ChannelMgtController {
@Autowired
ChannelMgtService channelService;
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 알림톡 템플릿 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/tmpltList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage tmpltList(@RequestBody Map<String, Object> paramMap) throws Exception{
return channelService.tmpltList(paramMap);
}
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.api.channelMgt;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public class ChannelMgtMapper {
}

View File

@@ -0,0 +1,51 @@
package kr.co.uplus.ez.api.channelMgt;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@Service
public class ChannelMgtService {
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 알림톡 템플릿 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage tmpltList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt","999");
data.put("currentPage","1");
dataObj.put("paging", data);
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("no", ""+(i+1));
data.put("custNm", "유플러스");
data.put("bRegNo", "229-81-39938");
data.put("tmpltCd", "Abc");
data.put("tmpltNm", "부가정보형");
data.put("stat", "승인");
data.put("returnReason", "");
data.put("sendProfile", "@유플러스");
data.put("lastChgDt", "2022-03-10");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
}

View File

@@ -0,0 +1,78 @@
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 공통
*/
package kr.co.uplus.ez.api.comm;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/comm")
public class CommController {
@Autowired
CommService commService;
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 메뉴 목록 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/getMenu" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage getMenu() throws Exception{
return commService.getMenu();
}
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 공통 코드 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/getCode" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage getCode(@RequestBody Map<String, Object> paramMap) throws Exception{
return commService.getCode(paramMap);
}
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 토큰요청
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/getToken" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage getToken(@RequestBody Map<String, Object> paramMap) throws Exception{
return commService.getToken(paramMap);
}
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 토큰연장
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/refreshToken" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage refreshToken(@RequestBody Map<String, Object> paramMap) throws Exception{
return commService.refreshToken(paramMap);
}
}

View File

@@ -0,0 +1,10 @@
package kr.co.uplus.ez.api.comm;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CommMapper {
public List<Menu> getMenuByRole(String role) throws Exception;
}

View File

@@ -0,0 +1,90 @@
package kr.co.uplus.ez.api.comm;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
import kr.co.uplus.ez.common.utils.SpringUtils;
@Service
public class CommService {
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
CommMapper commMapper;
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 메뉴 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage getMenu() throws Exception{
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
String currUserRole = SpringUtils.getCurrentUserRole();
log.debug("currUserRole : {}", currUserRole);
List<Menu> menuList = commMapper.getMenuByRole(currUserRole);
Menu root = new Menu();
Map<Integer, Menu> map = menuList.stream().collect(
Collectors.toMap(Menu::getMenuNo, Function.identity()));
for (Menu menu : menuList) {
Integer prntId = menu.getPrntsMenuNo();
if (prntId == null || prntId == 0) {
root.addChild(menu);
}
else {
map.get(prntId).addChild(menu);
}
}
result.setData(root);
return result;
}
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 공통 코드 조회
* @param paramMap
* @return
*/
public ApiResponseMessage getCode(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 토큰요청
* @param paramMap
* @return
*/
public ApiResponseMessage getToken(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 토큰연장
* @param paramMap
* @return
*/
public ApiResponseMessage refreshToken(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
}

View File

@@ -0,0 +1,29 @@
package kr.co.uplus.ez.api.comm;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
@Data
public class Menu {
private Integer menuNo; // 메뉴 번호
private Integer prntsMenuNo; // 부모 메뉴 번호
private String menuNm; // 메뉴 명
private Integer menuOdrg; // 메뉴 순서
private String useYn; // 사용 여부
private Integer autchkGrpno; // 권한체크 그룹번호
private Integer menuLvl; // 메뉴 레벨
private String menuUrl; // 메뉴 URL
private String regId; // 등록 ID
private String regDt; // 등록 일시
private String chgId; // 변경 ID
private String chgDt; // 변경 일시
private List<Menu> children = new ArrayList<>();
public void addChild(Menu menu) {
children.add(menu);
}
}

View File

@@ -0,0 +1,238 @@
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 고객 관리
*/
package kr.co.uplus.ez.api.custMgt;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/custMgt")
public class CustMgtController {
@Autowired
CustMgtService custService;
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 청약 고객 정보 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/subsList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage subsList(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.subsList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 청약 고객 정보 목록 엑셀 다운로드
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/subsListExcel" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage subsListExcel(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.subsListExcel(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 청약 정보 상세 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/subsDetail" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage subsDetail(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.subsDetail(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자명 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/adminInfo" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage adminInfo(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.adminInfo(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 이월금액 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/carryOverList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage carryOverList(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.carryOverList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 회원목록조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/memberList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage memberList(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.memberList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 회원 정보 상세 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/memberDetail" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage memberDetail(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.memberDetail(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 테스트ID 등록
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/insertTestId" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage insertTestId(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.insertTestId(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 전체 메모 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/allMemoList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage allMemoList(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.allMemoList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메모 삭제
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/deleteMemo" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage deleteMemo(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.deleteMemo(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사용자 정보 등록
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/insertUser" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage insertUser(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.insertUser(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사용자 정보 수정
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/updateUser" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage updateUser(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.updateUser(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사용자ID 대량등록
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/insertMassUser" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage insertMassUser(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.insertMassUser(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사용자 정보 삭제
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/deleteUser" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage deleteUser(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.deleteUser(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 정보 수정
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/updateMember" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage updateMember(@RequestBody Map<String, Object> paramMap) throws Exception{
return custService.updateMember(paramMap);
}
}

View File

@@ -0,0 +1,5 @@
package kr.co.uplus.ez.api.custMgt;
public class CustMgtMapper {
}

View File

@@ -0,0 +1,422 @@
package kr.co.uplus.ez.api.custMgt;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
import kr.co.uplus.ez.common.data.Const;
import kr.co.uplus.ez.common.utils.DateUtils;
@Service
public class CustMgtService {
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 청약 고객 정보 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage subsList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
List<Map<String, Object>> dataList = new ArrayList<>();
Map<String, Object> dataObj = new HashMap<>();
Map<String, Object> paging = new HashMap<>();
Map<String, Object> data = new HashMap<>();
paging.put(Const.getTotalCnt(), "5");
paging.put(Const.getCurrentPage(), "1");
dataObj.put("paging", paging);
Date now = new Date();
String nowStr = DateUtils.dateToStr(now, "YYYY-MM-dd");
for(int i=1; i<=20; i++) {
data.put("no", ""+i);
data.put("serviceId", "Uplus01");
data.put("custNm", "유플러스");
data.put("regNo", "1234"+i);
data.put("regDt", nowStr);
data.put("stat", "사용중");
data.put("channel", "유플러스");
data.put("plan", "요금제3");
data.put("carryOver", ""+(100000*i));
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 청약 고객 정보 목록 엑셀 다운로드
* @param paramMap
* @return
*/
public ApiResponseMessage subsListExcel(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
List<Map<String, Object>> dataList = new ArrayList<>();
Map<String, Object> dataObj = new HashMap<>();
Map<String, Object> paging = new HashMap<>();
Map<String, Object> data = new HashMap<>();
paging.put(Const.getTotalCnt(), "5");
paging.put(Const.getCurrentPage(), "1");
dataObj.put("paging", paging);
Date now = new Date();
String nowStr = DateUtils.dateToStr(now, "YYYY-MM-dd");
for(int i=1; i<=25; i++) {
data = new HashMap<>();
data.put("no", ""+i);
data.put("serviceId", "Uplus01");
data.put("custNm", "유플러스");
data.put("regNo", "1234"+i);
data.put("regDt", nowStr);
data.put("stat", "사용중");
data.put("channel", "유플러스");
data.put("plan", "요금제3");
data.put("carryOver", ""+(100000*i));
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 청약 정보 상세 조회
* @param paramMap
* @return
*/
public ApiResponseMessage subsDetail(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Date now = new Date();
String nowStr = DateUtils.dateToStr(now, "YYYY-MM-dd");
Map<String, Object> data = new HashMap<>();
data.put("custNm", "유플러스");
data.put("reprNm", "홍길동");
data.put("custType", "법인사업자");
data.put("adr1", "12345");
data.put("adr2", "서울 마포구 월드컵북로 416");
data.put("adr3", "유플러스 상암사옥");
data.put("bRegNo", "1231212345");
data.put("cprRegNo", "1234561234567");
data.put("subsDt", nowStr);
data.put("stat", "사용");
data.put("plan", "요금제1");
data.put("subsNo", "12345");
data.put("adminId", "Uplus02");
data.put("adminNm", "김철수");
data.put("channelId", "Uplus01");
data.put("channelNm", "홍길동");
data.put("serviceId", "uplus01");
data.put("useAuth", "관리자ID");
data.put("userNm", "유플러스");
data.put("mdn", "01012341234");
data.put("carryOver", "100000");
data.put("userCnt", "10");
result.setData(data);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자명 조회
* @param paramMap
* @return
*/
public ApiResponseMessage adminInfo(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> data = new HashMap<>();
data.put("adminId", "uplus01");
data.put("adminCd", "U00001");
data.put("adminNm", "홍길동");
data.put("agencyNm", "lg대리점");
result.setData(data);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 이월금액 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage carryOverList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String, Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("date", "2022-03");
data.put("startAmount", "130000");
data.put("useAmount", "130000");
data.put("krrrAmount", "-");
data.put("extshAmoutn", "-");
dataList.add(data);
data = new HashMap<>();
data.put("date", "2022-02");
data.put("startAmount", "80000");
data.put("useAmount", "-");
data.put("krrrAmount", "80000");
data.put("extshAmoutn", "-");
dataList.add(data);
data = new HashMap<>();
data.put("date", "2022-01");
data.put("startAmount", "50000");
data.put("useAmount", "20000");
data.put("krrrAmount", "30000");
data.put("extshAmoutn", "-");
dataList.add(data);
data = new HashMap<>();
data.put("date", "2021-12");
data.put("startAmount", "50000");
data.put("useAmount", "50000");
data.put("krrrAmount", "-");
data.put("extshAmoutn", "-");
dataList.add(data);
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 회원목록조회
* @param paramMap
* @return
*/
public ApiResponseMessage memberList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String, Object>> dataList = new ArrayList<>();
Map<String, Object> paging = new HashMap<>();
Map<String, Object> data = new HashMap<>();
paging.put(Const.getTotalCnt(), "5");
paging.put(Const.getCurrentPage(), "1");
dataObj.put("paging", paging);
Date now = new Date();
String nowStr = DateUtils.dateToStr(now, "YYYY-MM-dd");
for(int i=1; i<=20; i++) {
data = new HashMap<>();
data.put("no", ""+i);
data.put("userNm", "홍길동"+i);
data.put("userType", "관리자");
data.put("adminId", "Uplus0"+i);
data.put("userId", "Uplus0"+i);
data.put("regDt", nowStr);
data.put("userStat", "사용");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 회원 정보 상세 조회
* @param paramMap
* @return
*/
public ApiResponseMessage memberDetail(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String, Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("userNm", "유플러스");
data.put("regDt", "2022-03-06");
data.put("userType", "관리자ID");
data.put("userId", "Uplus01");
data.put("adminId", "Uplus02");
data.put("adminNm", "김철수");
data.put("sendingLimit", "100000");
data.put("lineType", "일반");
data.put("userStat", "Y");
data.put("lastLoginDt", "2022-03-10 14:15:45");
data.put("memo", "메모 입력 란입니다. \n작성글은 저장 버튼으로 저장퇴고 마지막 저장 내용은 남아 있습니다.");
data.put("mdn", "01012345689");
data.put("email", "lgTester@lgUplus.co.kr");
dataObj.put("data", data);
for(int i=1; i<=5; i++) {
data = new HashMap<>();
data.put("no", ""+i);
data.put("userId", "userId"+i);
data.put("userNm", "홍길동"+i);
data.put("mdn", "010-1234-1234");
data.put("userStat", "Y");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 테스트ID 등록
* @param paramMap
* @return
*/
public ApiResponseMessage insertTestId(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 전체 메모 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage allMemoList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String, Object>> dataList = new ArrayList<>();
Map<String, Object> paging = new HashMap<>();
Map<String, Object> data;
paging.put("totalCnt", "50");
paging.put("currentPage", "1");
dataObj.put("paging", paging);
for(int i=1; i<=5; i++) {
data = new HashMap<>();
data.put("memo", "작성한 메모 내용이 노출됩니다. \r\n"
+ "해당영역은 최대 5줄까지 노출되며 이후 우측 스크롤이 생성됩니다.\r\n"
+ "작성한 메모 내용이 노출됩니다. \r\n"
+ "해당영역은 최대 5줄까지 노출되며 이후 우측 스크롤이 생성됩니다.\r\n"
+ "작성한 메모 내용이 노출됩니다. \r\n"
+ "");
data.put("register", "관리자");
data.put("regDt", "2022-03-10");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메모 삭제
* @param paramMap
* @return
*/
public ApiResponseMessage deleteMemo(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사용자 정보 등록
* @param paramMap
* @return
*/
public ApiResponseMessage insertUser(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사용자 정보 수정
* @param paramMap
* @return
*/
public ApiResponseMessage updateUser(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사용자ID 대량등록
* @param paramMap
* @return
*/
public ApiResponseMessage insertMassUser(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사용자 정보 삭제
* @param paramMap
* @return
*/
public ApiResponseMessage deleteUser(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 정보 수정
* @param paramMap
* @return
*/
public ApiResponseMessage updateMember(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
}

View File

@@ -0,0 +1,118 @@
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 로그인
*/
package kr.co.uplus.ez.api.login;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/login")
public class LoginController {
@Autowired
LoginService2 loginService;
@Autowired
private AuthenticationManager authManager;
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사용자 로그인
* @param paramMap
* @return
* @throws Exception
*/
/*@RequestMapping(value = "/login" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage login(@RequestBody Map<String, Object> paramMap) throws Exception{
return loginService.login(paramMap);
}*/
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 인증번호 요청
* @param paramMap
* @return
* @throws Exception
*/
/* 삭제 예정
@RequestMapping(value = "/authNum" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage authNum(@RequestBody Map<String, Object> paramMap) throws Exception{
return loginService.authNum(paramMap);
}
*/
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 인증번호 확인
* @param paramMap
* @return
* @throws Exception
*/
/*@RequestMapping(value = "/confirmNum" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage confirmNum(@RequestBody Map<String, Object> paramMap) throws Exception{
return loginService.confirmNum(paramMap);
}*/
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 비밀번호 초기화 요청
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/resetPassword" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage resetPassword(@RequestBody Map<String, Object> paramMap) throws Exception{
return loginService.resetPassword(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 비밀번호 변경
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/updatePassword" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage updatePassword(@RequestBody Map<String, Object> paramMap) throws Exception{
return loginService.updatePassword(paramMap);
}
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 로그아웃
* @param paramMap
* @return
* @throws Exception
*/
// @RequestMapping(value = "/logout" , method = {RequestMethod.POST})
// @ResponseBody
// public ApiResponseMessage logout(@RequestBody Map<String, Object> paramMap) throws Exception{
// return loginService.logout(paramMap);
// }
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.api.login;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public class LoginMapper {
}

View File

@@ -0,0 +1,100 @@
package kr.co.uplus.ez.api.login;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@Service
public class LoginService2 {
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사용자 로그인
* @param paramMap
* @return
* @throws Exception
*/
public ApiResponseMessage login(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 인증번호 요청
* @param paramMap
* @return
* @throws Exception
*/
public ApiResponseMessage authNum(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 인증번호 확인
* @param paramMap
* @return
* @throws Exception
*/
public ApiResponseMessage confirmNum(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
// 2차 인증 후 메뉴 URL
dataObj.put("nextUrl", "/custMgt/subsList");
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 비밀번호 초기화 요청
* @param paramMap
* @return
* @throws Exception
*/
public ApiResponseMessage resetPassword(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 비밀번호 변경
* @param paramMap
* @return
* @throws Exception
*/
public ApiResponseMessage updatePassword(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 26.
* auth : ckr
* desc : 로그아웃
* @param paramMap
* @return
*/
public ApiResponseMessage logout(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
}

View File

@@ -0,0 +1,50 @@
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 모니터링
*/
package kr.co.uplus.ez.api.mntrng;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/mntrng")
public class MntrngController {
@Autowired
MntrngService mntrngService;
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발송내역 목록 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/sendList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage sendList(@RequestBody Map<String, Object> paramMap) throws Exception{
return mntrngService.sendList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 실시간 발송 현황 정보 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/liveSendSttus" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage liveSendSttus(@RequestBody Map<String, Object> paramMap) throws Exception{
return mntrngService.liveSendSttus(paramMap);
}
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.api.mntrng;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public class MntrngMapper {
}

View File

@@ -0,0 +1,152 @@
package kr.co.uplus.ez.api.mntrng;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@Service
public class MntrngService {
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발송내역 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage sendList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt","999");
data.put("currentPage","1");
dataObj.put("paging", data);
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("no", ""+(i+1));
data.put("sendingDt", "2022-03-12");
data.put("custNm", "유플러스"+(i+1));
data.put("userId", "Uplus01");
data.put("recvNum", "010-1234-1234");
data.put("sendNum", "010-1234-5678");
data.put("reqChannel", "SMS");
data.put("lastChannel", "SMS");
data.put("mlcmnCmpny", "LGT");
data.put("resultCd", "성공(100)");
data.put("reqDt", "2022-03-12 12:00:56");
data.put("comptDt", "2022-03-12 12:00:56");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 실시간 발송 현황 정보 조회
* @param paramMap
* @return
*/
public ApiResponseMessage liveSendSttus(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
// 최근 10분 발송 현황
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("channel", "SMS");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
dataList.add(data);
data = new HashMap<>();
data.put("channel", "LMS");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
dataList.add(data);
data = new HashMap<>();
data.put("channel", "MMS");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
data = new HashMap<>();
data.put("channel", "알림톡");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
dataList.add(data);
dataObj.put("listM", dataList);
// 최근 1시간 발송 현황
dataList = new ArrayList<>();
data = new HashMap<>();
data.put("channel", "SMS");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
dataList.add(data);
data = new HashMap<>();
data.put("channel", "LMS");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
dataList.add(data);
data = new HashMap<>();
data.put("channel", "MMS");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
data = new HashMap<>();
data.put("channel", "알림톡");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
dataList.add(data);
dataObj.put("listH", dataList);
// 당일 발송 현황
dataList = new ArrayList<>();
data = new HashMap<>();
data.put("channel", "SMS");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
dataList.add(data);
data = new HashMap<>();
data.put("channel", "LMS");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
dataList.add(data);
data = new HashMap<>();
data.put("channel", "MMS");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
data = new HashMap<>();
data.put("channel", "알림톡");
data.put("sendingCnt", "100");
data.put("succesCnt", "100");
data.put("succesRatio", "100%");
dataList.add(data);
dataObj.put("listD", dataList);
result.setData(dataObj);
return result;
}
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.api.riskMgt;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public class RiskMgtMapper {
}

View File

@@ -0,0 +1,278 @@
package kr.co.uplus.ez.api.riskMgt;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@Service
public class RiskMgtService {
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 차단 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage sendNumIntrcpList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt","999");
data.put("currentPage","1");
dataObj.put("paging", data);
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("no", ""+(i+1));
data.put("sendNum", "0212345678");
data.put("intrcpYn", "미차단");
data.put("sendType", "문자");
data.put("lastUpdateDt", "2022-03-10");
data.put("intrcpReason", "도박");
data.put("register", "kkkkkkf");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 차단 상세 정보 조회
* @param paramMap
* @return
*/
public ApiResponseMessage sendNumIntrcpDetail(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
dataObj.put("sendNum", "0212345678");
dataObj.put("sendType", "공용");
dataObj.put("intrcpReason", "도박");
dataObj.put("memo", "고객사 요청");
dataObj.put("intrcpYn", "차단");
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 차단 신규 등록
* @param paramMap
* @return
*/
public ApiResponseMessage sendNumInsertIntrcp(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 차단 수정
* @param paramMap
* @return
*/
public ApiResponseMessage sendNumUpdateIntrcp(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 차단 삭제
* @param paramMap
* @return
*/
public ApiResponseMessage sendNumDeleteIntrcp(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 080수신번호 차단 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage zezNumIntrcpList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt","999");
data.put("currentPage","1");
dataObj.put("paging", data);
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("no", ""+(i+1));
data.put("custNm", "가나다");
data.put("bRegNo", "123-11-12345");
data.put("authCd", "12345");
data.put("recvNum", "01012345678");
data.put("regDt", "2022-03-10");
data.put("regType", "자동등록");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메시지 차단 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage msgIntrcpList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt","999");
data.put("currentPage","1");
dataObj.put("paging", data);
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("no", ""+(i+1));
data.put("intrcpMsg", "도박");
data.put("intrcpYn", "차단");
data.put("lastUpdateDt", "2022-03-10");
data.put("intrcpReason", "도박");
data.put("register", "Abcefu");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메시지 차단 상세 정보 조회
* @param paramMap
* @return
*/
public ApiResponseMessage msgIntrcpDetail(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
dataObj.put("intrcpMsgId", "testMsgId");
dataObj.put("intrcpString1", "도박");
dataObj.put("intrcpString2", "광고");
dataObj.put("intrcpString3", "");
dataObj.put("intrcpString4", "");
dataObj.put("intrcpString5", "");
dataObj.put("intrcpString6", "");
dataObj.put("intrcpString7", "");
dataObj.put("intrcpString8", "");
dataObj.put("intrcpString9", "");
dataObj.put("intrcpString10", "");
dataObj.put("condition", "OR");
dataObj.put("intrcpReason", "도박");
dataObj.put("memo", "가나다라");
dataObj.put("intrcpYn", "차단");
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메시지 차단 신규 등록
* @param paramMap
* @return
*/
public ApiResponseMessage msgInsertIntrcp(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메시지 차단 수정
* @param paramMap
* @return
*/
public ApiResponseMessage msgUpdateIntrcp(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메시지 차단 삭제
* @param paramMap
* @return
*/
public ApiResponseMessage msgDeleteIntrcp(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 차단 내역 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage allIntrcpList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt","999");
data.put("currentPage","1");
dataObj.put("paging", data);
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("no", ""+(i+1));
data.put("intrcpType", "발신번호차단");
data.put("sendId", "Abcd");
data.put("sendNum", "021540000");
data.put("custNm", "가나다");
data.put("custId", "Uplus01");
data.put("bRegNo", "123-11-12345");
data.put("recvNum", "01022223333");
data.put("intrcpReason", "도착");
data.put("sendDt", "2-03-22");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
}

View File

@@ -0,0 +1,193 @@
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 리스크 관리
*/
package kr.co.uplus.ez.api.riskMgt;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/riskMgt")
public class RistMgtController {
@Autowired
RiskMgtService riskService;
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 차단 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/sendNum/intrcpList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage sendNumIntrcpList(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.sendNumIntrcpList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 차단 상세 정보 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/sendNum/intrcpDetail" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage sendNumIntrcpDetail(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.sendNumIntrcpDetail(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 차단 신규 등록
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/sendNum/insertIntrcp" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage sendNumInsertIntrcp(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.sendNumInsertIntrcp(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 차단 수정
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/sendNum/updateIntrcp" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage sendNumUpdateIntrcp(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.sendNumUpdateIntrcp(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 차단 삭제
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/sendNum/deleteIntrcp" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage sendNumDeleteIntrcp(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.sendNumDeleteIntrcp(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 080수신번호 차단 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/zezNum/intrcpList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage zezNumIntrcpList(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.zezNumIntrcpList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메시지 차단 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/msg/intrcpList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage msgIntrcpList(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.msgIntrcpList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메시지 차단 상세 정보 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/msg/intrcpDetail" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage msgIntrcpDetail(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.msgIntrcpDetail(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메시지 차단 신규 등록
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/msg/insertIntrcp" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage msgInsertIntrcp(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.msgInsertIntrcp(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메시지 차단 수정
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/msg/updateIntrcp" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage msgUpdateIntrcp(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.msgUpdateIntrcp(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 메시지 차단 삭제
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/msg/deleteIntrcp" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage msgDeleteIntrcp(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.msgDeleteIntrcp(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 차단 내역 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/all/intrcpList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage allIntrcpList(@RequestBody Map<String, Object> paramMap) throws Exception{
return riskService.allIntrcpList(paramMap);
}
}

View File

@@ -0,0 +1,14 @@
package kr.co.uplus.ez.api.sample;
import java.io.Serializable;
import lombok.Data;
@Data
public class Sample implements Serializable {
private static final long serialVersionUID = 6443429970712121140L;
private Long addrId;
}

View File

@@ -0,0 +1,31 @@
package kr.co.uplus.ez.api.sample;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
@RestController
public class SampleController {
@Autowired
private SampleService service;
@ApiOperation(value = "sample", notes = "샘플 get api입니다.")
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "sample")
})
@RequestMapping(value = "/sample/list", method = {RequestMethod.GET})
public List<Sample> getSample(@ApiParam(value = "testId입니다", required = true) Long testId) {
return service.getSample();
}
}

View File

@@ -0,0 +1,11 @@
package kr.co.uplus.ez.api.sample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SampleMapper {
public List<Sample> selectSample(Sample param);
}

View File

@@ -0,0 +1,17 @@
package kr.co.uplus.ez.api.sample;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class SampleService {
@Autowired
private SampleMapper mapper;
public List<Sample> getSample() {
return mapper.selectSample(new Sample());
}
}

View File

@@ -0,0 +1,142 @@
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호관리
*/
package kr.co.uplus.ez.api.sendNumMgt;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/sendNumMgt")
public class SendNumMgtController {
@Autowired
SendNumMgtService sendNumService;
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신 프로필 목록 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/profileList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage profileList(@RequestBody Map<String, Object> paramMap) throws Exception{
return sendNumService.profileList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 문자 발신 번호 목록 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/numberList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage numberList(@RequestBody Map<String, Object> paramMap) throws Exception{
return sendNumService.numberList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 문자 발신 번호 삭제
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/deleteNumber" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage deleteNumber(@RequestBody Map<String, Object> paramMap) throws Exception{
return sendNumService.deleteNumber(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 문자 발신 번호 등록
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/insertNumber" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage insertNumber(@RequestBody Map<String, Object> paramMap) throws Exception{
return sendNumService.insertNumber(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 문자 발신 번호 정보 상세 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/numberDetail" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage numberDetail(@RequestBody Map<String, Object> paramMap) throws Exception{
return sendNumService.numberDetail(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자ID 목록 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/adminList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage adminList(@RequestBody Map<String, Object> paramMap) throws Exception{
return sendNumService.adminList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 승인 목록 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/apprList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage apprList(@RequestBody Map<String, Object> paramMap) throws Exception{
return sendNumService.apprList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 승인 상세 정보 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/apprDetail" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage apprDetail(@RequestBody Map<String, Object> paramMap) throws Exception{
return sendNumService.apprDetail(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발송내역 목록 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/insertAppr" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage insertAppr(@RequestBody Map<String, Object> paramMap) throws Exception{
return sendNumService.insertAppr(paramMap);
}
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.api.sendNumMgt;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public class SendNumMgtMapper {
}

View File

@@ -0,0 +1,267 @@
package kr.co.uplus.ez.api.sendNumMgt;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@Service
public class SendNumMgtService {
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신 프로필 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage profileList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt","999");
data.put("currentPage","1");
dataObj.put("paging", data);
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("no", ""+(i+1));
data.put("custNm", "유플러스");
data.put("bRegNo", "229-81-39938");
data.put("sendProfile", "@유플러스");
data.put("sendProfileKey", "Ea98cv472cff7f5bdbc90");
data.put("stat", "사용");
data.put("regDt", "2022-03-10");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 문자 발신 번호 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage numberList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt","999");
data.put("currentPage","1");
dataObj.put("paging", data);
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("no", ""+(i+1));
data.put("custNm", "유플러스");
data.put("adminId", "Uplus01");
data.put("register", "Uplus01");
data.put("bRegNo", "229-81-39938");
data.put("sendNum", "010-1234-1234");
data.put("apprStat", "승인완료");
data.put("regMethod", "본인인등");
data.put("regDt", "2022-03-10");
data.put("regNo", "12345");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 문자 발신 번호 삭제
* @param paramMap
* @return
*/
public ApiResponseMessage deleteNumber(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 문자 발신 번호 등록
* @param paramMap
* @return
*/
public ApiResponseMessage insertNumber(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 문자 발신 번호 정보 상세 조회
* @param paramMap
* @return
*/
public ApiResponseMessage numberDetail(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
dataObj.put("adminId", "Uplus01");
dataObj.put("custNm", "유플러스");
dataObj.put("bRegNo", "229-81-39938");
dataObj.put("authSendNumYn", "Y");
dataObj.put("authBsnsYn", "Y");
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("sendNm", "테스트"+(i+1));
data.put("sendNum", "02-555-5555");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자ID 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage adminList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data = new HashMap<>();
data.put("adminId", "Test");
data.put("bRegNo", "229-81-39938");
dataList.add(data);
data = new HashMap<>();
data.put("adminId", "Test01");
data.put("bRegNo", "229-81-55555");
dataList.add(data);
data = new HashMap<>();
data.put("adminId", "Test02");
data.put("bRegNo", "229-81-44444");
dataList.add(data);
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 승인 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage apprList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt","999");
data.put("currentPage","1");
dataObj.put("paging", data);
for(int i=0; i<10; i++) {
data = new HashMap<>();
data.put("no", ""+(i+1));
data.put("reqApprDt", "2022-03-03");
data.put("adminId", "Uplus01");
data.put("register", "Uplus01");
data.put("bRegNo", "229-81-39938");
data.put("reqCnt", "3");
data.put("apprCnt", "2");
data.put("returnCnt", "1");
data.put("apprStat", "처리완료");
data.put("apprDt", "2022-03-03");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발신번호 승인 상세 정보 조회
* @param paramMap
* @return
*/
public ApiResponseMessage apprDetail(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
dataObj.put("reqApprDt", "2022-03-03");
dataObj.put("apprDt", "2022-03-03");
dataObj.put("adminId", "Uplus01");
dataObj.put("register", "Uplus01");
dataObj.put("bRegNo", "229-81-39938");
dataObj.put("returnReason", "반려내용 - 사용거부 번호");
dataObj.put("authSendNumNms", "통신서비스 가입증명원.jpg");
dataObj.put("authBsnsNms", "인감증명서.jpg,사업자등록증.jpg");
data = new HashMap<>();
data.put("no", "1");
data.put("sendNum", "02-1234-5678");
data.put("apprStat", "반려");
dataList.add(data);
data = new HashMap<>();
data.put("no", "2");
data.put("sendNum", "070-1234-5678");
data.put("apprStat", "승인");
dataList.add(data);
data = new HashMap<>();
data.put("no", "3");
data.put("sendNum", "1588-1677");
data.put("apprStat", "승인");
dataList.add(data);
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발송내역 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage insertAppr(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
}

View File

@@ -0,0 +1,40 @@
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 서비스 관리
*/
package kr.co.uplus.ez.api.servMgt;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.api.login.LoginService2;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/servMgt")
public class ServMgtController {
@Autowired
ServMgtService ServService;
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 080수신거부 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/rejectRecvList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage rejectRecvList(@RequestBody Map<String, Object> paramMap) throws Exception{
return ServMgtService.rejectRecvList(paramMap);
}
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.api.servMgt;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public class ServMgtMapper {
}

View File

@@ -0,0 +1,51 @@
package kr.co.uplus.ez.api.servMgt;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@Service
public class ServMgtService {
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 080수신거부 목록 조회
* @param paramMap
* @return
*/
public static ApiResponseMessage rejectRecvList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt", "999");
data.put("currentPage", "1");
dataObj.put("paging", data);
for(int i=1; i<10; i++) {
data = new HashMap<>();
data.put("no", ""+i);
data.put("custNm", "유플러스");
data.put("bRegNo", "229-81-38889");
data.put("adminId", "Uplus01");
data.put("authCd", "12345");
data.put("useYn", "사용");
data.put("regDt", "2022-03-10");
data.put("chgDt", "2022-03-10");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
}

View File

@@ -0,0 +1,130 @@
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 발송 통계
*/
package kr.co.uplus.ez.api.stats;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/stats")
public class StatsController {
@Autowired
StatsService statsService;
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 월별 통계 목록 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/monthList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage monthList(@RequestBody Map<String, Object> paramMap) throws Exception{
return statsService.monthList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 월별 통계 목록 엑셀 다운로드
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/monthListExcel" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage monthListExcel(@RequestBody Map<String, Object> paramMap) throws Exception{
return statsService.monthListExcel(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 일별 통계 목록 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/dayList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage dayList(@RequestBody Map<String, Object> paramMap) throws Exception{
return statsService.dayList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 일별 통계 목록 엑셀 다운로드
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/dayListExcel" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage dayListExcel(@RequestBody Map<String, Object> paramMap) throws Exception{
return statsService.dayListExcel(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사업자 월별 통계 목록 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/bsnmMonthList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage bsnmMonthList(@RequestBody Map<String, Object> paramMap) throws Exception{
return statsService.bsnmMonthList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사업자 월별 통계 목록 엑셀 다운로드
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/bsnmMonthListExcel" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage bsnmMonthListExcel(@RequestBody Map<String, Object> paramMap) throws Exception{
return statsService.bsnmMonthListExcel(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사업자 일별 통계 목록 조회
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/bsnmDayList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage bsnmDayList(@RequestBody Map<String, Object> paramMap) throws Exception{
return statsService.bsnmDayList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사업자 일별 통계 목록 엑셀 다운로드
* @param paramMap
* @throws Exception
*/
@RequestMapping(value = "/bsnmDayListExcel" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage bsnmDayListExcel(@RequestBody Map<String, Object> paramMap) throws Exception{
return statsService.bsnmDayListExcel(paramMap);
}
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.api.stats;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public class StatsMapper {
}

View File

@@ -0,0 +1,304 @@
package kr.co.uplus.ez.api.stats;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@Service
public class StatsService {
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 월별 통계 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage monthList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
for(int i=1; i<=4; i++) {
data = new HashMap<>();
data.put("date", "2022-0"+i);
data.put("allSendCnt", "40000000");
data.put("allSuccesCnt", "40000000(100%)");
data.put("smsSendCnt", "10000000");
data.put("smsSuccesCnt", "10000000(100%)");
data.put("lmsSendCnt", "10000000");
data.put("lmsSuccesCnt", "10000000(100%)");
data.put("mmsSendCnt", "10000000");
data.put("mmsSuccesCnt", "10000000(100%)");
data.put("notiTalkSendCnt", "10000000");
data.put("notiTalkSuccesCnt", "10000000(100%)");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 월별 통계 목록 엑셀 다운로드
* @param paramMap
* @return
*/
public ApiResponseMessage monthListExcel(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
for(int i=1; i<=4; i++) {
data = new HashMap<>();
data.put("date", "2022-0"+i);
data.put("allSendCnt", "40000000");
data.put("allSuccesCnt", "40000000(100%)");
data.put("smsSendCnt", "10000000");
data.put("smsSuccesCnt", "10000000(100%)");
data.put("lmsSendCnt", "10000000");
data.put("lmsSuccesCnt", "10000000(100%)");
data.put("mmsSendCnt", "10000000");
data.put("mmsSuccesCnt", "10000000(100%)");
data.put("notiTalkSendCnt", "10000000");
data.put("notiTalkSuccesCnt", "10000000(100%)");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 일별 통계 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage dayList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
for(int i=1; i<=4; i++) {
data = new HashMap<>();
data.put("date", "2022-03-0"+i);
data.put("allSendCnt", "40000000");
data.put("allSuccesCnt", "40000000(100%)");
data.put("smsSendCnt", "10000000");
data.put("smsSuccesCnt", "10000000(100%)");
data.put("lmsSendCnt", "10000000");
data.put("lmsSuccesCnt", "10000000(100%)");
data.put("mmsSendCnt", "10000000");
data.put("mmsSuccesCnt", "10000000(100%)");
data.put("notiTalkSendCnt", "10000000");
data.put("notiTalkSuccesCnt", "10000000(100%)");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 일별 통계 목록 엑셀 다운로드
* @param paramMap
* @return
*/
public ApiResponseMessage dayListExcel(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
for(int i=1; i<=9; i++) {
data = new HashMap<>();
data.put("date", "2022-03-0"+i);
data.put("allSendCnt", "40000000");
data.put("allSuccesCnt", "40000000(100%)");
data.put("smsSendCnt", "10000000");
data.put("smsSuccesCnt", "10000000(100%)");
data.put("lmsSendCnt", "10000000");
data.put("lmsSuccesCnt", "10000000(100%)");
data.put("mmsSendCnt", "10000000");
data.put("mmsSuccesCnt", "10000000(100%)");
data.put("notiTalkSendCnt", "10000000");
data.put("notiTalkSuccesCnt", "10000000(100%)");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사업자 월별 통계 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage bsnmMonthList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
for(int i=1; i<=4; i++) {
data = new HashMap<>();
data.put("date", "2022-0"+i);
data.put("custNm", "유플러스");
data.put("bRegNo", "사업자번호");
data.put("allSendCnt", "40000000");
data.put("allSuccesCnt", "40000000(100%)");
data.put("smsSendCnt", "10000000");
data.put("smsSuccesCnt", "10000000(100%)");
data.put("lmsSendCnt", "10000000");
data.put("lmsSuccesCnt", "10000000(100%)");
data.put("mmsSendCnt", "10000000");
data.put("mmsSuccesCnt", "10000000(100%)");
data.put("notiTalkSendCnt", "10000000");
data.put("notiTalkSuccesCnt", "10000000(100%)");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사업자 월별 통계 목록 엑셀 다운로드
* @param paramMap
* @return
*/
public ApiResponseMessage bsnmMonthListExcel(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
for(int i=1; i<=4; i++) {
data = new HashMap<>();
data.put("date", "2022-0"+i);
data.put("custNm", "유플러스");
data.put("bRegNo", "사업자번호");
data.put("allSendCnt", "40000000");
data.put("allSuccesCnt", "40000000(100%)");
data.put("smsSendCnt", "10000000");
data.put("smsSuccesCnt", "10000000(100%)");
data.put("lmsSendCnt", "10000000");
data.put("lmsSuccesCnt", "10000000(100%)");
data.put("mmsSendCnt", "10000000");
data.put("mmsSuccesCnt", "10000000(100%)");
data.put("notiTalkSendCnt", "10000000");
data.put("notiTalkSuccesCnt", "10000000(100%)");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사업자 일별 통계 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage bsnmDayList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
for(int i=1; i<=9; i++) {
data = new HashMap<>();
data.put("date", "2022-03-0"+i);
data.put("custNm", "유플러스");
data.put("bRegNo", "사업자번호");
data.put("allSendCnt", "40000000");
data.put("allSuccesCnt", "40000000(100%)");
data.put("smsSendCnt", "10000000");
data.put("smsSuccesCnt", "10000000(100%)");
data.put("lmsSendCnt", "10000000");
data.put("lmsSuccesCnt", "10000000(100%)");
data.put("mmsSendCnt", "10000000");
data.put("mmsSuccesCnt", "10000000(100%)");
data.put("notiTalkSendCnt", "10000000");
data.put("notiTalkSuccesCnt", "10000000(100%)");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 사업자 일별 통계 목록 엑셀 다운로드
* @param paramMap
* @return
*/
public ApiResponseMessage bsnmDayListExcel(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
for(int i=1; i<=9; i++) {
data = new HashMap<>();
data.put("date", "2022-03-0"+i);
data.put("custNm", "유플러스");
data.put("bRegNo", "사업자번호");
data.put("allSendCnt", "40000000");
data.put("allSuccesCnt", "40000000(100%)");
data.put("smsSendCnt", "10000000");
data.put("smsSuccesCnt", "10000000(100%)");
data.put("lmsSendCnt", "10000000");
data.put("lmsSuccesCnt", "10000000(100%)");
data.put("mmsSendCnt", "10000000");
data.put("mmsSuccesCnt", "10000000(100%)");
data.put("notiTalkSendCnt", "10000000");
data.put("notiTalkSuccesCnt", "10000000(100%)");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
}

View File

@@ -0,0 +1,182 @@
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 시스템관리
*/
package kr.co.uplus.ez.api.sysMgt;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@RestController
@RequestMapping(value = "api/v1/bo/sysMgt")
public class SysMgtController {
@Autowired
SysMgtService sysService;
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/adminList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage adminList(@RequestBody Map<String, Object> paramMap) throws Exception{
return sysService.adminList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 마당ID 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/searchMadangId" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage searchMadangId(@RequestBody Map<String, Object> paramMap) throws Exception{
return sysService.searchMadangId(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 등록
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/insertAdmin" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage insertAdmin(@RequestBody Map<String, Object> paramMap) throws Exception{
return sysService.insertAdmin(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 수정
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/updateAdmin" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage updateAdmin(@RequestBody Map<String, Object> paramMap) throws Exception{
return sysService.updateAdmin(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 삭제
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/deleteAdmin" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage deleteAdmin(@RequestBody Map<String, Object> paramMap) throws Exception{
return sysService.deleteAdmin(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 정보 상세 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/adminDetail" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage adminDetail(@RequestBody Map<String, Object> paramMap) throws Exception{
return sysService.adminDetail(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 권한 목록 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/authList" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage authList(@RequestBody Map<String, Object> paramMap) throws Exception{
return sysService.authList(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 권한 삭제
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/deleteAuth" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage deleteAuth(@RequestBody Map<String, Object> paramMap) throws Exception{
return sysService.deleteAuth(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 권한 상세 조회
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/authDetail" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage authDetail(@RequestBody Map<String, Object> paramMap) throws Exception{
return sysService.authDetail(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 권한 추가
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/insertAuth" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage insertAuth(@RequestBody Map<String, Object> paramMap) throws Exception{
return sysService.insertAuth(paramMap);
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 권한 수정
* @param paramMap
* @return
* @throws Exception
*/
@RequestMapping(value = "/updateAuth" , method = {RequestMethod.POST})
@ResponseBody
public ApiResponseMessage updateAuth(@RequestBody Map<String, Object> paramMap) throws Exception{
return sysService.updateAuth(paramMap);
}
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.api.sysMgt;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public class SysMgtMapper {
}

View File

@@ -0,0 +1,250 @@
package kr.co.uplus.ez.api.sysMgt;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
@Service
public class SysMgtService {
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage adminList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String, Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("totalCnt", "990");
data.put("currentPage", "1");
dataObj.put("paging", data);
for(int i=1; i<=10; i++) {
data = new HashMap<>();
data.put("no", ""+i);
data.put("auth", "대리점");
data.put("name", "유플러스");
data.put("adminId", "Uplus0"+i);
data.put("adminStat", "사용");
data.put("regDt", "2022-03-10");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 마당ID 조회
* @param paramMap
* @return
*/
public ApiResponseMessage searchMadangId(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> data = new HashMap<>();
data.put("madangId", "uplus01");
data.put("name", "홍길동");
data.put("mdn", "010123455555");
data.put("email", "abc@abc.com");
data.put("code", "1234");
result.setData(data);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 등록
* @param paramMap
* @return
*/
public ApiResponseMessage insertAdmin(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 수정
* @param paramMap
* @return
*/
public ApiResponseMessage updateAdmin(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 삭제
* @param paramMap
* @return
*/
public ApiResponseMessage deleteAdmin(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 관리자 정보 상세 조회
* @param paramMap
* @return
*/
public ApiResponseMessage adminDetail(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> data = new HashMap<>();
data.put("madangId", "uplus01");
data.put("name", "홍길동");
data.put("mdn", "010123455555");
data.put("email", "abc@abc.com");
data.put("code", "1234");
result.setData(data);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 권한 목록 조회
* @param paramMap
* @return
*/
public ApiResponseMessage authList(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String, Object>> dataList = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data = new HashMap<>();
data.put("no", "1");
data.put("authCd", "Admin_01");
data.put("authNm", "슈퍼관리자");
data.put("authStat", "사용");
data.put("regDt", "2022-03-10");
dataList.add(data);
data = new HashMap<>();
data.put("no", "2");
data.put("authCd", "Admin_02");
data.put("authNm", "대리점");
data.put("authStat", "사용");
data.put("regDt", "2022-03-10");
dataList.add(data);
data = new HashMap<>();
data.put("no", "3");
data.put("authCd", "Admin_03");
data.put("authNm", "고객센터");
data.put("authStat", "사용");
data.put("regDt", "2022-03-10");
dataList.add(data);
data = new HashMap<>();
data.put("no", "4");
data.put("authCd", "Admin_04");
data.put("authNm", "운영자");
data.put("authStat", "정지");
data.put("regDt", "2022-03-10");
dataList.add(data);
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 권한 삭제
* @param paramMap
* @return
*/
public ApiResponseMessage deleteAuth(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 권한 상세 조회
* @param paramMap
* @return
*/
public ApiResponseMessage authDetail(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
Map<String, Object> dataObj = new HashMap<>();
List<Map<String, Object>> dataList = new ArrayList<>();
Map<String, Object> data;
dataObj.put("authNm", "운영자");
dataObj.put("authCd", "Admin_02");
dataObj.put("authDesc", "운영자 권한");
dataObj.put("authStat", "Y");
for(int i=1; i<=10; i++) {
data = new HashMap<>();
data.put("upperMenuNo", "1");
data.put("name", "청약고객관리"+i);
data.put("order", ""+i);
data.put("useYn", "Y");
data.put("menuLv", "1");
dataList.add(data);
}
dataObj.put("list", dataList);
result.setData(dataObj);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 권한 추가
* @param paramMap
* @return
*/
public ApiResponseMessage insertAuth(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
/**
* date : 2022. 4. 25.
* auth : ckr
* desc : 권한 수정
* @param paramMap
* @return
*/
public ApiResponseMessage updateAuth(Map<String, Object> paramMap) {
ApiResponseMessage result = new ApiResponseMessage(ApiResponseCode.SUCCESS);
return result;
}
}

View File

@@ -0,0 +1,130 @@
package kr.co.uplus.ez.api.user;
//package kr.co.uplus.hub.api.user;
//
//import java.util.List;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import com.lguplus.rcs.webtpl.api.sys.log.work.Work;
//import com.lguplus.rcs.webtpl.api.sys.log.work.WorkService;
//
//import kr.co.uplus.hub.common.auth.UserPassword;
//import kr.co.uplus.hub.common.consts.ResultCode;
//import kr.co.uplus.hub.common.utils.SpringUtils;
//
//@Service
//@Transactional
//public class UserService {
//
// @Autowired
// private UserDao dao;
//
// @Autowired
// private WorkService workService;
// @Autowired
// private PasswordEncoder pwdEncoder;
//
// public int selectUserListCnt(User user) {
// System.out.println("user --> "+user.toString());
// return dao.selectUserListCnt(user);
// }
//
// public List<User> selectUserList(User user) {
// return dao.selectUserList(user);
// }
//
// public User getUser(User user) {
// List<User> userList = selectUserList(user);
// if (userList.size() > 0) {
// return userList.get(0);
// }
// return null;
// }
//
// public Integer insertUser(User user, Work work) {
// int success = dao.insertUser(user);
// if (success > 0) {
// success = dao.insertUserRole(user);
// }
// if(SpringUtils.getCurrentUser() != null) {
// if (success > 0) {
// workService.insertUserCreateWorkLog(work);
// }
// }
// return success;
// }
//
// public Integer updateUser(User user, Work work) {
// int success = dao.updateUser(user);
// if (success > 0) {
// success = dao.updateUserRole(user);
// }
// if (success > 0) {
// workService.insertUserUpdateWorkLog(work);
// }
// return success;
// }
//
// public Integer deleteUser(List<User> users) {
// return dao.deleteUser(users);
// }
//
// public User selectUser(String userId) {
// User user = new User();
// user.setUserId(userId);
// return getUser(user);
// }
//
// public String selectUserPwd(String userId) {
// return dao.selectUserPwd(userId);
// }
//
// public List<String> selectLastPwds(String userId) {
// return dao.selectLastPwds(userId);
// }
//
// public Integer updateUserPwd(UserPassword pass) {
// dao.updateUserPwd(pass);
// return dao.insertUserPwdHist(pass);
// }
//
// public User isInvldUserId(User user) {
// return dao.isInvldUserId(user);
// }
//
// public ResultCode changePassword(UserPassword pass) {
// String userId = pass.getUserId();
// String dbPwd = selectUserPwd(userId);
//
// if (pass.getCurPwd() != null && !pwdEncoder.matches(pass.getCurPwd(), dbPwd)) {
// return ResultCode.CE_WRONG_PWD;
// }
//
// String newPwd = pass.getNewPwd();
// List<String> lastPwds = selectLastPwds(userId);
// lastPwds.add(dbPwd);
// boolean reuse = lastPwds.stream().anyMatch(s -> pwdEncoder.matches(newPwd, s));
//
// if (reuse) {
// return ResultCode.CE_USED_PWD;
// }
//
// UserPassword encPass = new UserPassword();
// encPass.setUserId(userId);
// encPass.setCurPwd(dbPwd);
// encPass.setNewPwd(pwdEncoder.encode(newPwd));
// encPass.setRegUserId(userId);
// updateUserPwd(encPass);
//
// return ResultCode.SUCCESS;
//
// }
//
// public boolean aleadyExistId(User user) {
// return dao.aleadyExistId(user) > 0;
// }
//
//}

View File

@@ -0,0 +1,35 @@
package kr.co.uplus.ez.common.auth;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 권한에 따른 URI 접근제어용 어노테이션.
* menu()는 클래스 레벨 또는 메서드 레벨 중 하나에선 반드시 설정해야 한다.
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface AccessMapping {
/**
* 대상 API URI가 소속된 메뉴 URI.
* RCS_MENU 테이블의 URL 컬럼 값으로 설정해야 한다.
* 클래스 레벨에 설정하면 모든 메서드에 대해 접근권한을 검사한다.
* 메서드 레벨 설정이 클래스 레벨 설정보다 우선한다(덮어쓴다).
*/
String menu() default "";
/**
* 편집 허용여부를 체크해야 하는 URI면 true, 아니면 false.
* 메서드 레벨 설정 전용.
*/
boolean edit() default false;
/**
* true면 접근권한을 검사하지 않음.
* 클래스 레벨 설정을 메서드 레벨 설정에서 무효화하기 위해 사용한다.
* 메서드 레벨 설정 전용.
*/
boolean skip() default false;
}

View File

@@ -0,0 +1,260 @@
package kr.co.uplus.ez.common.auth;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
import org.springframework.security.web.savedrequest.RequestCache;
import org.springframework.security.web.savedrequest.SavedRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import kr.co.uplus.ez.common.auth.jwt.JwtService;
import kr.co.uplus.ez.common.auth.jwt.PublicToken;
import kr.co.uplus.ez.common.consts.Const;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
import kr.co.uplus.ez.common.data.RestResult;
import kr.co.uplus.ez.config.SecurityConfig;
@RestController
public class AuthController {
private static final Logger logger = LoggerFactory.getLogger(AuthController.class);
@Autowired
private AuthenticationManager authManager;
@Autowired
private LoginSuccessHandler loginSuccessHandler;
@Autowired
private LoginFailureHandler loginFailureHandler;
@Autowired
private LoginService loginSvc;
@Autowired
private JwtService jwtSvc;
/**
* date : 2022. 5. 3.
* auth : ckr
* desc : 로그인
* @param user
* @param request
* @param response
* @return
* @throws Exception
*/
@PostMapping("/api/v1/bo/login/login")
public ApiResponseMessage login(@RequestBody LoginDto loginInfo) throws Exception {
ApiResponseCode rCode = loginSvc.firstLoginChk(loginInfo);
if(rCode.equals(ApiResponseCode.SUCCESS)) {
Map<String, Object> dataObj = new HashMap<>();
dataObj.put("nextUrl", "/");
ApiResponseMessage result = new ApiResponseMessage(rCode);
result.setData(dataObj);
return result;
}else {
return new ApiResponseMessage(rCode);
}
/*
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword());
Authentication authentication = null;
try {
authentication = authManager.authenticate(token);
}
catch (AuthenticationException e) {
request.setAttribute(SecurityConfig.LOGIN_ID_PARAM, user.getOprtrId());
ApiResponseCode resultCode = loginFailureHandler.process(request, response, e);
return new ApiResponseMessage(resultCode);
}
ApiResponseCode rcode = loginSuccessHandler.process(request, response, authentication);
request.setAttribute(SecurityConfig.AUTH_USER, authentication);
//jwtSvc.generatePrivateToken(response, authentication);
String nextUrl = getReturnUrl(request, response);
logger.debug("login SUCCESS - nextUrl = [{}]", nextUrl);
Map<String, Object> dataObj = new HashMap<>();
dataObj.put("nextUrl", "/");
dataObj.put("firstAuthToken", token);
Authentication authentication2 = SecurityContextHolder.getContext().getAuthentication();
ApiResponseMessage result = new ApiResponseMessage(rcode);
result.setData(dataObj);
return result;
*/
}
@PostMapping("/openapi/token")
public RestResult<?> publicToken(AuthUser user) throws Exception {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword());
Authentication authentication = null;
try {
authentication = authManager.authenticate(token);
}
catch (AuthenticationException e) {
return new RestResult<String>(false);
}
PublicToken pubToken = jwtSvc.generatePublicToken(authentication);
return new RestResult<PublicToken>().setData(pubToken);
}
@PostMapping("/openapi/refresh")
public RestResult<?> accessToken(String refreshToken) throws Exception {
try {
String accessToken = jwtSvc.accessToken(refreshToken);
PublicToken pubToken = new PublicToken();
pubToken.setAccessToken(accessToken);
return new RestResult<PublicToken>().setData(pubToken);
}
catch (Exception e) {
return new RestResult<PublicToken>(false);
}
}
/**
* 로그인 전에 요청했던 URL 반환
*/
private String getReturnUrl(HttpServletRequest request, HttpServletResponse response) {
RequestCache requestCache = new HttpSessionRequestCache();
SavedRequest savedRequest = requestCache.getRequest(request, response);
if (savedRequest == null) {
AuthUser user = (AuthUser) request.getAttribute(Const.KEY_LOAD_USER);
/* ckr
if (user != null) {
if ("Y".equals(user.getRcsYn())) {
return SecurityConfig.LOGIN_SUCC_URL;
} else {
return SecurityConfig.NO_RCS_AUTH_LOGIN_SUCC_URL;
}
}*/
return SecurityConfig.LOGIN_SUCC_URL;
}
return savedRequest.getRedirectUrl();
}
/* ckr - 삭제예정
@GetMapping("/api/auth/logout")
public RestResult<?> logout(HttpServletRequest request, HttpServletResponse response) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null){
new SecurityContextLogoutHandler().logout(request, response, auth);
}
jwtSvc.destroyPrivateToken(request, response);
return new RestResult<String>();
}*/
@PostMapping("api/v1/bo/login/logout")
@ResponseBody
public ApiResponseMessage logout(@RequestBody Map<String, Object> paramMap, HttpServletRequest request, HttpServletResponse response) throws Exception{
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null){
new SecurityContextLogoutHandler().logout(request, response, auth);
}
jwtSvc.destroyPrivateToken(request, response);
return new ApiResponseMessage();
}
/**
* date : 2022. 5. 17.
* auth : ckr
* desc : HUBEZ_BO_API_2002 - 인증번호 요청
* @param reqAuthNumDto
* @return
* @throws Exception
*/
@PostMapping("api/v1/bo/login/authNum")
@ResponseBody
public ApiResponseMessage authNum(@RequestBody ReqAuthNumDto reqAuthNumDto) throws Exception{
ApiResponseCode rcode = loginSvc.sendAuthNum(reqAuthNumDto);
return new ApiResponseMessage(rcode);
}
/**
* date : 2022. 5. 17.
* auth : ckr
* desc : HUBEZ_BO_API_2003 - 인증번호 확인
* 2차인증번호 인증 Spring security
* @param authNumDto
* @return
*/
@PostMapping("/api/v1/bo/login/confirmNum")
@ResponseBody
public ApiResponseMessage confirmNum(@RequestBody ChkAuthNumDto authNumDto, HttpServletRequest request, HttpServletResponse response) {
AuthUser user = new AuthUser();
user.setOprtrId(authNumDto.getOprtrId());
user.setInputPwd(authNumDto.getOprtrPw());
// 시큐리티 인증
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword());
Authentication authentication = null;
try {
authentication = authManager.authenticate(token);
}
catch (AuthenticationException e) {
request.setAttribute(SecurityConfig.LOGIN_ID_PARAM, user.getOprtrId());
ApiResponseCode resultCode = loginFailureHandler.process(request, response, e);
return new ApiResponseMessage(resultCode);
}
ApiResponseCode rCode = loginSvc.confirmNum(authNumDto);
if(rCode.equals(ApiResponseCode.SUCCESS)) {
// 2차인증후 시큐리티 성공핸들러
rCode = loginSuccessHandler.process(request, response, authentication);
// 토큰 생성
jwtSvc.generatePrivateToken(response, authentication);
String nextUrl = getReturnUrl(request, response);
logger.debug("login SUCCESS - nextUrl = [{}]", nextUrl);
Map<String, Object> dataObj = new HashMap<>();
dataObj.put("nextUrl", "/");
ApiResponseMessage result = new ApiResponseMessage(rCode);
result.setData(dataObj);
return result;
}else {
ApiResponseMessage result = new ApiResponseMessage(rCode);
return result;
}
}
/* ckr 불명확
@GetMapping("/api/public/auth/phone")
public RestResult<?> phone(SmsAuthNum authNum) {
String phone = loginSvc.getAuthPhone(authNum);
return new RestResult<String>()
.setData(phone);
}
*/
}

View File

@@ -0,0 +1,21 @@
package kr.co.uplus.ez.common.auth;
import lombok.Data;
// 인증문자
@Data
public class AuthNum {
private Integer seqNo; // 일련번호
private String authTpCd; // 인증 유형 코드
private String sttusCd; // 상태 코드
private String hpNo; // 휴대폰 번호
private String chrVal; // 인증 문자
private String expDt; // 만료 일시
private String regId; // 등록 ID
private String regDt; // 등록 일시
private String chgId; // 변경 ID
private String chgDt; // 변경 일시
private String oprtrId; // 어드민 ID
private Integer authchrFailCnt; // 인증 실패 카운트
}

View File

@@ -0,0 +1,16 @@
package kr.co.uplus.ez.common.auth;
import org.springframework.security.core.Authentication;
import lombok.Data;
// 인증문자 Dto
@Data
public class AuthNumDto {
public String oprtrId; // 어드민 사용자 ID
public String hpNo; // 휴대폰 번호
public String chrVal; // 인증 문자
public Boolean isLogin; // 1차 로그인 여부
}

View File

@@ -0,0 +1,286 @@
package kr.co.uplus.ez.common.auth;
import java.util.Collection;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import kr.co.uplus.ez.common.consts.UserStatus;
import kr.co.uplus.ez.common.data.SearchInfo;
import kr.co.uplus.ez.common.utils.EncryptionUtil;
import lombok.Setter;
import lombok.ToString;
@ToString
@Setter
public class AuthUser extends SearchInfo implements UserDetails {
private static final long serialVersionUID = -2568297930450189586L;
private String oprtrId;
private String oprtrNm;
//private UserStatus sttusCd;
private String sttusCd;
private String pwd;
private String email;
private String hpNo;
private String autCd;
private int authchrFailCnt;
private String rFrshTkn;
private String rFrshTknDt;
private String lastLoginDt;
private int loginFailCnt;
private String pwdChgDt;
private String regId;
private String regDt;
private String chgId;
private String chgDt;
private String inputPwd;
private Collection<? extends GrantedAuthority> authorities;
public String getOprtrId() {
return oprtrId;
}
private String corpId; // temp data
public String getCorpId() {
return corpId;
}
public String getUsername() {
String uname = "";
if (corpId != null && !"".equals(corpId)) {
uname += corpId + ".";
}
uname += oprtrId;
return uname;
}
public Collection<? extends GrantedAuthority> getAuthorities() {
return authorities;
}
/* ckr
public UserStatus getSttusCd() {
return sttusCd;
}
*/
public String getSttusCd() {
return sttusCd;
}
// public void setPwd(String pwd) {
// this.pwd = EncryptionUtil.getCustomSHA512(this.oprtrId, pwd);
// }
public void setInputPwd(String inputPwd) {
this.pwd = EncryptionUtil.getCustomSHA512(this.oprtrId, inputPwd);
}
public String getInputPwd() {
return inputPwd;
}
public String getPwd() {
return pwd;
}
public String getEmail() {
return email;
}
public String getHpNo() {
return hpNo;
}
public String getAutCd() {
return autCd;
}
public int getAuthchrFailCnt() {
return authchrFailCnt;
}
public String getRfreshTkn() {
return rFrshTkn;
}
public String getRfreshTknDt() {
return rFrshTknDt;
}
public String getLastLoginDt() {
return lastLoginDt;
}
public int getLoginFailCnt() {
return loginFailCnt;
}
public String getPwdChgDt() {
return pwdChgDt;
}
public String getRegId() {
return regId;
}
public String getRegDt() {
return regDt;
}
public String getChgId() {
return chgId;
}
public String getChgDt() {
return chgDt;
}
public boolean isAccountNonExpired() {
return true;
}
/* ckr
public boolean isAccountNonLocked() {
return sttusCd != UserStatus.LOCK;
}
*/
public boolean isAccountNonLocked() {
return sttusCd.equals("01");
}
public boolean isCredentialsNonExpired() {
return true;
}
/* ckr
public boolean isEnabled() {
return sttusCd == UserStatus.USE;
}
*/
public boolean isEnabled() {
return sttusCd.equals("01");
}
public String getPassword() {
//return "{noop}"+pwd;
return pwd;
}
/*
private String userId;
private String userPwd;
private UserStatus status;
private Collection<? extends GrantedAuthority> authorities;
private String userNm;
private String pwdChgDt;
private int loginFailCnt;
private String phone;
private SmsAuthNum sms;
private String rcsYn;
public String getRcsYn() {
if (StringUtils.isEmpty(rcsYn)) {
return "N";
}
return rcsYn;
}
private String corpId; // temp data
public String getCorpId() {
return corpId;
}
public String getUsername() {
String uname = "";
if (corpId != null && !"".equals(corpId)) {
uname += corpId + ".";
}
uname += userId;
return uname;
}
public String getPassword() {
return userPwd;
}
public Collection<? extends GrantedAuthority> getAuthorities() {
return authorities;
}
public boolean isAccountNonExpired() {
return true;
}
public boolean isAccountNonLocked() {
return status != UserStatus.LOCK;
}
public boolean isCredentialsNonExpired() {
// if (StringUtils.isEmpty(pwdChgDt))
// return true;
//
// DateTime last = DateUtils.str2dateYMDHMS(pwdChgDt);
// DateTime now = DateTime.now();
// int days = DateUtils.diffDays(last, now);
//
// return days < Const.PWD_EXPIRE_DAYS;
return true;
}
public boolean isEnabled() {
return status == UserStatus.USE;
}
public String getUserId() {
return userId;
}
public String getUserPwd() {
return userPwd;
}
public UserStatus getStatus() {
return status;
}
public String getUserNm() {
return userNm;
}
public String getPwdChgDt() {
return pwdChgDt;
}
public int getLoginFailCnt() {
return loginFailCnt;
}
public String getPhone() {
return phone;
}
public SmsAuthNum getSms() {
return sms;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("AuthUser [userId=");
builder.append(userId);
builder.append(", status=");
builder.append(status);
builder.append(", authorities=");
builder.append(authorities);
builder.append(", userNm=");
builder.append(userNm);
builder.append("]");
return builder.toString();
}
*/
}

View File

@@ -0,0 +1,32 @@
package kr.co.uplus.ez.common.auth;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AuthUserDao {
//public AuthUser getByUsername(String username);
public AuthUser getByUsername(String username);
public String[] getRoles(String username);
public int increaseFailCount(String username);
public int increaseAuthFailCnt(String userId);
public int setUserStatus(AuthUser user);
public void setLoginInfo(String userId);
//public int addSmsAuthNum(SmsAuthNum num);
public int addAuthNum(AuthNum authNum);
public AuthUser getUser(String userId);
//public SmsAuthNum getSmsAuthNum(String userId);
public AuthNum getAuthNum(AuthNum authNum);
//public int setSmsAuthNum(SmsAuthNum sms);
public int setAuthUserInfo(AuthNum authNum);
public int setAuthNum(AuthNum authNum);
public List<SmsAuthNum> getSmsAuthNumByNum(String issNum);
public String getSmsAuthPhone(SmsAuthNum num);
}

View File

@@ -0,0 +1,15 @@
package kr.co.uplus.ez.common.auth;
import lombok.Data;
// 인증문자 확인 Dto
@Data
public class ChkAuthNumDto {
public String oprtrId; // 어드민 사용자 ID
public String oprtrPw; // 어드민 사용자 PW
public String hpNo; // 휴대폰 번호
public String chrVal; // 인증 번호
public Boolean isLogin; // 1차 로그인 여부
}

View File

@@ -0,0 +1,15 @@
package kr.co.uplus.ez.common.auth;
import org.springframework.security.core.Authentication;
import lombok.Data;
// login
@Data
public class LoginDto {
private String oprtrId; // 어드민 사용자 ID
private String oprtrPw; // 어드민 사용자 Pw
}

View File

@@ -0,0 +1,110 @@
package kr.co.uplus.ez.common.auth;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.DisabledException;
import org.springframework.security.authentication.LockedException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
import kr.co.uplus.ez.common.consts.Const;
import kr.co.uplus.ez.common.consts.ResultCode;
import kr.co.uplus.ez.common.consts.UserStatus;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.config.SecurityConfig;
/**
* 로그인에 실패하면 호출되는 기본 핸들러는 SimpleUrlAuthenticationFailureHandler 클래스이다.
*/
public class LoginFailureHandler extends SimpleUrlAuthenticationFailureHandler {
@SuppressWarnings("unused")
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private LoginService svc;
public LoginFailureHandler() {
}
public LoginFailureHandler(String loginFailUrl) {
super(loginFailUrl);
}
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
AuthenticationException exception) throws IOException, ServletException {
process(request, response, exception);
super.onAuthenticationFailure(request, response, exception);
}
/*
public ResultCode process(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) {
String userId = request.getParameter(SecurityConfig.LOGIN_ID_PARAM);
if (userId == null)
userId = (String) request.getAttribute(SecurityConfig.LOGIN_ID_PARAM);
AuthUser user = (AuthUser) request.getAttribute(Const.KEY_LOAD_USER);
ResultCode resultCode = ResultCode.SE_UNKNOWN;
if (exception instanceof BadCredentialsException) {
resultCode = ResultCode.CE_ID_PWD;
if (user != null) { // 없는 ID면 user == null 이고 PWD 불일치면 user != null 이다
int failCnt = svc.increaseFailCount(userId);
if (failCnt >= Const.MAX_LOGIN_FAIL) {
svc.setUserStatus(userId, UserStatus.LOCK);
resultCode = ResultCode.CE_TO_LOCK;
}
}
}
else if (exception instanceof DisabledException) {
resultCode = ResultCode.SS_NOT_USE;
}
else if (exception instanceof LockedException) {
resultCode = ResultCode.SS_LOCK;
}
// else if (exception instanceof CredentialsExpiredException) {
// resultCode = ResultCode.SS_PWD_EXPIRE;
// }
return resultCode;
}
*/
public ApiResponseCode process(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) {
String userId = request.getParameter(SecurityConfig.LOGIN_ID_PARAM);
if (userId == null) {
userId = (String) request.getAttribute(SecurityConfig.LOGIN_ID_PARAM);
}
AuthUser user = (AuthUser) request.getAttribute(Const.KEY_LOAD_USER);
ApiResponseCode resultCode = ApiResponseCode.SE_UNKNOWN;
if (exception instanceof BadCredentialsException) {
resultCode = ApiResponseCode.CE_ID_PWD;
if (user != null) { // 없는 ID면 user == null 이고 PWD 불일치면 user != null 이다
int failCnt = svc.increaseFailCount(userId);
if (failCnt >= Const.MAX_LOGIN_FAIL) {
svc.setUserStatus(userId, "02");
resultCode = ApiResponseCode.CE_TO_LOCK;
}
}
}
else if (exception instanceof DisabledException) {
resultCode = ApiResponseCode.SS_NOT_USE;
}
else if (exception instanceof LockedException) {
resultCode = ApiResponseCode.SS_NOT_USE;
}
// else if (exception instanceof CredentialsExpiredException) {
// resultCode = ResultCode.SS_PWD_EXPIRE;
// }
return resultCode;
}
}

View File

@@ -0,0 +1,215 @@
package kr.co.uplus.ez.common.auth;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import kr.co.uplus.ez.common.consts.ConfigProps;
import kr.co.uplus.ez.common.consts.Const;
import kr.co.uplus.ez.common.consts.ResultCode;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.utils.DateUtils;
import kr.co.uplus.ez.common.utils.EncryptionUtil;
import kr.co.uplus.ez.common.utils.TextUtils;
@Service
public class LoginService {
@SuppressWarnings("unused")
private final Logger logger = LoggerFactory.getLogger(getClass());
private static final int AUTHCHR_FAIL_CNT = 5; // 인증 실패 카운트
private static final String CODE_VALUE_02 = "02"; // 코드값 02
private static final String AUTH_TP_CD = "01"; // 어드민 로그인
private static final String AUTH_STTUS_CD_01 = "01"; // 인증대기
private static final String AUTH_STTUS_CD_02 = "02"; // 인증완료
@Autowired
private AuthUserDao dao;
@Autowired
private ConfigProps cprops;
// @Autowired
// private SmsService smsSvc;
// @Autowired
// private UserService userSvc;
// 1차 로그인 인증
public ApiResponseCode firstLoginChk(LoginDto loginInfo) {
String userId = loginInfo.getOprtrId();
AuthUser user = getUser(userId);
if(user == null) {
// 사용자 여부
return ApiResponseCode.CE_ID_NOT_FOUND;
}
if(user.getLoginFailCnt() >= Const.MAX_LOGIN_FAIL) {
// 5회 로그인 실패 체크
return ApiResponseCode.CE_TO_LOCK;
}
if(user.getSttusCd().equals(CODE_VALUE_02)) {
// 사용자 상태 체크
return ApiResponseCode.SS_NOT_USE;
}
// 비밀번호 체크
String userPw = loginInfo.getOprtrPw();
String encPwd = EncryptionUtil.getCustomSHA512(userId, userPw);
if(!user.getPwd().equals(encPwd)) {
// 로그인 실패 카운트 증가
dao.increaseFailCount(userId);
return ApiResponseCode.CE_ID_PWD;
}else {
// 로그인 실패카운트 초기화
setLoginInfo(user.getOprtrId());
}
return ApiResponseCode.SUCCESS;
}
public void setLoginInfo(String userId) {
dao.setLoginInfo(userId);
}
public int increaseFailCount(String userId) {
dao.increaseFailCount(userId);
AuthUser user = dao.getByUsername(userId);
return user.getLoginFailCnt();
}
public void setUserStatus(String userId, String status) {
AuthUser user = new AuthUser();
user.setOprtrId(userId);
user.setSttusCd(status);
dao.setUserStatus(user);
}
public AuthUser getUser(String userId) {
return dao.getUser(userId);
}
// 인증번호 요청
public ApiResponseCode sendAuthNum(ReqAuthNumDto reqAuthNumDto) {
// 1차 로그인 체크
if(reqAuthNumDto.getIsLogin() != null && reqAuthNumDto.getIsLogin()) {
// return 1차로그인 인증 실패 코드
}
String userId = reqAuthNumDto.getOprtrId(); // 인증 받고자 하는 userId
AuthUser user = getUser(userId);
// 인증 요청 계정의 정보 체크(ID, HP)
if (user != null) {
if(!user.getOprtrId().equals(userId)) {
return ApiResponseCode.CE_ID_HP;
}
if(!user.getHpNo().equals(reqAuthNumDto.getHpNo())) {
return ApiResponseCode.CE_ID_HP;
}
}else {
return ApiResponseCode.CE_ID_NOT_FOUND;
}
// 2차 인증 실패 카운트 체크
int autchrFailCnt = user.getAuthchrFailCnt();
if (autchrFailCnt >= Const.MAX_AUTHNUM_FAIL) {
return ApiResponseCode.CE_AUTHNUM_LOCK;
}
String authNum = TextUtils.randNumStr(6);
// 발행한 인증번호 DB에 저장
AuthNum anum = new AuthNum();
anum.setAuthTpCd(AUTH_TP_CD);
anum.setSttusCd(AUTH_STTUS_CD_01);
anum.setHpNo(user.getHpNo());
anum.setChrVal(authNum);
anum.setRegId(user.getOprtrId());
dao.addAuthNum(anum);
return ApiResponseCode.SUCCESS;
}
// 인증 번호 확인
public ApiResponseCode confirmNum(ChkAuthNumDto authNumDto) {
AuthNum anum = new AuthNum();
anum.setOprtrId(authNumDto.getOprtrId());
anum.setAuthTpCd(AUTH_TP_CD);
anum.setSttusCd(AUTH_STTUS_CD_01); // 사용중
anum.setHpNo(authNumDto.getHpNo());
anum.setChrVal(authNumDto.getChrVal());
AuthNum curr = dao.getAuthNum(anum);
if (curr == null) {
return ApiResponseCode.CE_WRONG_AUTHNUM;
}
if (curr.getAuthchrFailCnt() > Const.MAX_AUTHNUM_FAIL) {
return ApiResponseCode.CE_AUTHNUM_LOCK;
}
if (!curr.getChrVal().equals(authNumDto.getChrVal())) {
// 실패 카운트 증가
String oprtrId = curr.getOprtrId();
dao.increaseAuthFailCnt(oprtrId);
return ApiResponseCode.CE_WRONG_AUTHNUM;
}
// 인증 성공 시
resetAuthFailCnt(curr);
return ApiResponseCode.SUCCESS;
}
// 로그인 성공시 초기화, 인증번호 상태 변경
private void resetAuthFailCnt(AuthNum curr) {
// 어드민 사용자
AuthNum authNum = new AuthNum();
authNum.setOprtrId(curr.getOprtrId());
authNum.setAuthchrFailCnt(0);
dao.setAuthUserInfo(authNum);
// 인증요청
authNum = new AuthNum();
authNum.setSeqNo(curr.getSeqNo());
authNum.setSttusCd(AUTH_STTUS_CD_02);
dao.setAuthNum(authNum);
}
// public ResultCode resetPassword(UserPassword pass) {
// String userId = pass.getUserId();
//
// List<SmsAuthNum> nums = dao.getSmsAuthNumByNum(pass.getToken());
// if (nums.size() == 0) {
// return ResultCode.CE_WRONG_AUTHNUM;
// }
// else if (nums.size() > 1) {
// SmsAuthNum anum = nums.stream()
// .filter(s -> s.getUserId().equals(userId))
// .findFirst().orElse(null);
// if (anum == null) {
// return ResultCode.CE_WRONG_AUTHNUM;
// }
// }
//
// return userSvc.changePassword(pass);
// }
/* ckr 불명확
public String getAuthPhone(SmsAuthNum anum) {
return dao.getSmsAuthPhone(anum);
}
*/
}

View File

@@ -0,0 +1,43 @@
package kr.co.uplus.ez.common.auth;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import kr.co.uplus.ez.common.consts.Const;
import kr.co.uplus.ez.common.consts.ResultCode;
import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage;
/**
* 로그인에 성공하면 호출되는 기본 핸들러는 SavedRequestAwareAuthenticationSuccessHandler 클래스이다.
*/
public class LoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
@Autowired
private LoginService svc;
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws ServletException, IOException {
process(request, response, authentication);
super.onAuthenticationSuccess(request, response, authentication);
}
public ApiResponseCode process(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
AuthUser user = (AuthUser) request.getAttribute(Const.KEY_LOAD_USER);
user.setPwd(null);
ApiResponseCode rCode = ApiResponseCode.SUCCESS;
svc.setLoginInfo(user.getOprtrId());
super.clearAuthenticationAttributes(request);
return rCode;
}
}

View File

@@ -0,0 +1,13 @@
package kr.co.uplus.ez.common.auth;
import lombok.Data;
// 인증문자 요청 Dto
@Data
public class ReqAuthNumDto {
public String oprtrId; // 어드민 사용자 ID
public String hpNo; // 휴대폰 번호
public Boolean isLogin; // 1차 로그인 여부
}

View File

@@ -0,0 +1,35 @@
package kr.co.uplus.ez.common.auth;
import org.joda.time.DateTime;
import kr.co.uplus.ez.common.consts.Const;
import kr.co.uplus.ez.common.utils.DateUtils;
import lombok.Data;
@Data
public class SmsAuthNum {
private String userId;
private String issNum;
private String regDt;
private Integer authFailCnt;
private String issLockYn;
public boolean isAuthNumIssuable() {
if (isIssueLocked() && !isIssueLockExpired()) {
return false;
}
return true;
}
public boolean isIssueLocked() {
return "Y".equals(issLockYn);
}
public boolean isIssueLockExpired() {
DateTime last = DateUtils.str2dateYMDHMS(regDt);
DateTime now = DateTime.now();
int minutes = DateUtils.diffMinutes(last, now);
return minutes >= Const.AUTHNUM_LOCK_EXPIRE_MINS;
}
}

View File

@@ -0,0 +1,99 @@
package kr.co.uplus.ez.common.auth;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import kr.co.uplus.ez.common.consts.Const;
import kr.co.uplus.ez.common.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class UserDetailsServiceImpl implements UserDetailsService {
private static final Logger logger = LoggerFactory.getLogger(UserDetailsServiceImpl.class);
@Autowired
private AuthUserDao dao;
/* ckr
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
logger.debug("username = [{}]", username);
String corpId = null;
if (username.indexOf(".") > -1) {
String[] splts = username.split("\\.");
corpId = splts[0];
username = splts[1];
}
AuthUser user = dao.getByUsername(username);
if (corpId != null) {
user.setCorpId(corpId);
}
HttpServletRequest request = SpringUtils.getCurrentRequest();
request.setAttribute(Const.KEY_LOAD_USER, user);
logger.debug("user = [{}]", user);
if (user == null) {
throw new UsernameNotFoundException(username);
}
List<GrantedAuthority> roles = AuthorityUtils.createAuthorityList(dao.getRoles(username));
logger.debug("roles = [{}]", roles);
if (roles.isEmpty()) {
roles = AuthorityUtils.createAuthorityList("ROLE_USER");
// throw new UsernameNotFoundException(username);
}
user.setAuthorities(roles);
logger.debug("user = [{}]", user);
return user;
}
*/
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
logger.debug("username = [{}]", username);
String corpId = null;
if (username.indexOf(".") > -1) {
String[] splts = username.split("\\.");
corpId = splts[0];
username = splts[1];
}
AuthUser user = dao.getByUsername(username);
log.info("userPWD = {}",user.getPwd());
if (corpId != null) {
user.setCorpId(corpId);
}
HttpServletRequest request = SpringUtils.getCurrentRequest();
request.setAttribute(Const.KEY_LOAD_USER, user);
logger.debug("user = [{}]", user);
if (user == null) {
throw new UsernameNotFoundException(username);
}
List<GrantedAuthority> roles = AuthorityUtils.createAuthorityList(user.getAutCd());
logger.debug("roles = [{}]", roles);
if (roles.isEmpty()) {
roles = AuthorityUtils.createAuthorityList("1004");
}
user.setAuthorities(roles);
logger.debug("user = [{}]", user);
return user;
}
}

View File

@@ -0,0 +1,26 @@
package kr.co.uplus.ez.common.auth;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class UserPassword {
private String userId;
private String curPwd;
private String newPwd;
private String regUserId;
private String token;
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("UserPassword [userId=");
builder.append(userId);
builder.append(", regUserId=");
builder.append(regUserId);
builder.append(", token=");
builder.append(token);
builder.append("]");
return builder.toString();
}
}

View File

@@ -0,0 +1,58 @@
package kr.co.uplus.ez.common.auth.jwt;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.JwtException;
public class JwtAuthCookieFilter extends JwtAuthFilter {
@Autowired
private JwtService jwtSvc;
public JwtAuthCookieFilter(JwtProperties jwtProps) {
super(jwtProps);
}
@Override
public String getToken(HttpServletRequest request) {
String payload = null, signature = null;
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
// 1. 쿠키에서 jwt 토큰 header.paload 부분 읽기
if (jwtProps.getPart1().equals(cookie.getName())) {
payload = cookie.getValue();
}
// 2. 쿠키에서 jwt 토큰 signature 부분 읽기
else if (jwtProps.getPart2().equals(cookie.getName())) {
signature = cookie.getValue();
}
}
}
if (cookies == null || payload == null || signature == null) {
return null;
}
String token = payload + "." + signature;
return token;
}
@Override
public void onValidateSuccess(HttpServletRequest request, HttpServletResponse response, Claims claims) {
// 토큰 업데이트 - Sliding Sessions
jwtSvc.updatePrivateToken(response, claims);
}
@Override
public void onValidateException(HttpServletRequest request, HttpServletResponse response, JwtException exception) {
if (exception instanceof ExpiredJwtException) {
jwtSvc.destroyPrivateToken(request, response);
}
}
}

View File

@@ -0,0 +1,87 @@
package kr.co.uplus.ez.common.auth.jwt;
import static kr.co.uplus.ez.config.SecurityConfig.LOGIN_API_URL;
import static kr.co.uplus.ez.config.SecurityConfig.PUBLIC_API_URL;
import java.io.IOException;
import java.util.Map;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.filter.OncePerRequestFilter;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.JwtException;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.impl.TextCodec;
import kr.co.uplus.ez.common.consts.Const;
import kr.co.uplus.ez.common.utils.WebUtils;
public abstract class JwtAuthFilter extends OncePerRequestFilter {
protected final JwtProperties jwtProps;
public JwtAuthFilter(JwtProperties jwtProps) {
this.jwtProps = jwtProps;
}
public abstract String getToken(HttpServletRequest request);
public abstract void onValidateSuccess(HttpServletRequest request, HttpServletResponse response, Claims claims);
public abstract void onValidateException(HttpServletRequest request, HttpServletResponse response, JwtException exception);
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
//if (WebUtils.isResourceRequest(request) || WebUtils.isMatchedUriPattern(request, PUBLIC_API_URL, LOGIN_API_URL)) {
if (WebUtils.isResourceRequest(request) || WebUtils.isMatchedUriPattern(request, LOGIN_API_URL)) {
chain.doFilter(request, response);
return;
}
// 쿠키에서 토큰 추출 (client - server token)
String token = getToken(request);
if(token == null) {
chain.doFilter(request, response); // go to the next filter in the filter chain
return;
}
Claims claims = null;
request.setAttribute(Const.KEY_TOKEN_EXIST, true);
try {
// 4. 토큰 검증
claims = Jwts.parser()
.setSigningKey(TextCodec.BASE64.decode(jwtProps.getKeyString()))
.parseClaimsJws(token)
.getBody();
String subject = claims.getSubject();
if(subject != null) {
onValidateSuccess(request, response, claims);
// 5. 스프링 용 UsernamePasswordAuthenticationToken 객체 생성
@SuppressWarnings("unchecked")
Map<String,Object> principalMap = (Map<String,Object>) claims.get("principal");
JwtUser user = JwtUser.createAuthUser(principalMap);
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());
// 6. 사용자 인증 처리 (Now, user is authenticated)
SecurityContextHolder.getContext().setAuthentication(auth);
}
}
catch(JwtException e) {
onValidateException(request, response, e);
throw e;
}
chain.doFilter(request, response);
}
}

View File

@@ -0,0 +1,37 @@
package kr.co.uplus.ez.common.auth.jwt;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.JwtException;
public class JwtAuthHeaderFilter extends JwtAuthFilter {
public JwtAuthHeaderFilter(JwtProperties jwtProps) {
super(jwtProps);
}
@Override
public String getToken(HttpServletRequest request) {
// 1. access token이 저장된 헤더 읽기
String header = request.getHeader(jwtProps.getHeader());
// 2. 헤더 값 검사
if(header == null || !header.startsWith(jwtProps.getPrefix())) {
return null;
}
// 3. Authorization 헤더에서 토큰 추출
return header.replace(jwtProps.getPrefix(), "");
}
@Override
public void onValidateSuccess(HttpServletRequest request, HttpServletResponse response, Claims claims) {
}
@Override
public void onValidateException(HttpServletRequest request, HttpServletResponse response, JwtException exception) {
}
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.common.auth.jwt;
import lombok.Data;
@Data
public class JwtData {
private String info;
}

View File

@@ -0,0 +1,41 @@
package kr.co.uplus.ez.common.auth.jwt;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.filter.OncePerRequestFilter;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.JwtException;
import kr.co.uplus.ez.common.consts.Const;
import kr.co.uplus.ez.common.utils.WebUtils;
import kr.co.uplus.ez.config.SecurityConfig;
public class JwtExceptionFilter extends OncePerRequestFilter {
@Override
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
try {
filterChain.doFilter(request, response);
}
catch (JwtException e) {
if (WebUtils.isJwtTokenExist(request) && WebUtils.isMatchedUriPattern(request, SecurityConfig.REST_API_URLS)) {
if (e instanceof ExpiredJwtException)
WebUtils.responseJson(response, Const.SESSION_EXPIRED);
else
WebUtils.responseJson(response, HttpServletResponse.SC_UNAUTHORIZED);
}
else {
throw e;
}
}
catch (Exception e) {
throw e;
}
}
}

View File

@@ -0,0 +1,22 @@
package kr.co.uplus.ez.common.auth.jwt;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import lombok.Data;
@Component
@ConfigurationProperties("app.props.jwt")
@Data
public class JwtProperties {
private String keyString;
private int privateTokenExpiration; // seconds
private String part1;
private String part2;
private int accessTokenExpiration; // seconds
private int refreshTokenExpiration; // seconds
private String header;
private String prefix;
}

View File

@@ -0,0 +1,169 @@
package kr.co.uplus.ez.common.auth.jwt;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.JwtException;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.impl.TextCodec;
import kr.co.uplus.ez.common.auth.AuthUser;
@Service
public class JwtService {
@Autowired
private JwtProperties jwtProps;
public void generatePrivateToken(HttpServletResponse response, Authentication auth) {
Claims claims = coreClaims(auth, jwtProps.getPrivateTokenExpiration());
// 필요하면 다른 정보 추가
JwtData data = new JwtData();
data.setInfo("추가 claim 정보");
claims.put("data", data);
String token = generateToken(claims);
// 쿠키에 토큰 추가 - 보안 강화
setTokenToCookie(response, token);
}
private Claims coreClaims(Authentication auth, int expire) {
String subject = auth.getName();
DateTime now = DateTime.now();
Date expiration = now.plusSeconds(expire).toDate();
Claims claims = Jwts.claims()
.setSubject(subject)
.setIssuedAt(now.toDate())
.setExpiration(expiration);
AuthUser user = (AuthUser) auth.getPrincipal();
JwtUser jwtUser = JwtUser.createJwtUser(user);
claims.put("principal", jwtUser);
return claims;
}
private String generateToken(Claims claims) {
String token = Jwts.builder()
.setClaims(claims)
.signWith(SignatureAlgorithm.HS512, TextCodec.BASE64.decode(jwtProps.getKeyString()))
.compact();
return token;
}
private void setTokenToCookie(HttpServletResponse response, String token) {
int idx = token.lastIndexOf(".");
String payload = token.substring(0, idx);
String signature = token.substring(idx+1);
// header.paload 부분만 일반 쿠키에 저장 - JS로 읽기 가능
Cookie part1 = new Cookie(jwtProps.getPart1(), payload);
part1.setPath("/");
response.addCookie(part1);
// signature 부분만 httpOnly 쿠키에 저장 - JS로 읽기 불가능
Cookie part2 = new Cookie(jwtProps.getPart2(), signature);
part2.setHttpOnly(true);
part2.setPath("/");
response.addCookie(part2);
}
public void destroyPrivateToken(HttpServletRequest request, HttpServletResponse response) {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
cookie.setValue("");
cookie.setPath("/");
cookie.setMaxAge(0);
response.addCookie(cookie);
}
}
}
public void updatePrivateToken(HttpServletResponse response, Claims claims) {
DateTime now = DateTime.now();
Date expiration = now.plusSeconds(jwtProps.getPrivateTokenExpiration()).toDate();
claims.setIssuedAt(now.toDate()).setExpiration(expiration);
String token = generateToken(claims);
setTokenToCookie(response, token);
}
@SuppressWarnings("unused")
private String generateToken(String subject, int expire, Map<String,Object> map) {
DateTime now = DateTime.now();
Date expiration = now.plusSeconds(expire).toDate();
Claims claims = Jwts.claims()
.setSubject(subject)
.setIssuedAt(now.toDate())
.setExpiration(expiration);
claims.putAll(map);
return generateToken(claims);
}
public PublicToken generatePublicToken(Authentication auth) {
String access = accessToken(auth);
String refresh = refreshToken(auth);
return new PublicToken(access, refresh);
}
public String accessToken(Authentication auth) {
Claims claims = coreClaims(auth, jwtProps.getAccessTokenExpiration());
// server to server API에 필요한 claims 설정
JwtData data = new JwtData();
data.setInfo("서버 claim 정보");
claims.put("data", data);
return generateToken(claims);
}
public String accessToken(String refreshToken) {
DateTime now = DateTime.now();
Date expiration = now.plusSeconds(jwtProps.getAccessTokenExpiration()).toDate();
// refreshToken의 principal 재사용
Claims claims = parseToken(refreshToken)
.setIssuedAt(now.toDate())
.setExpiration(expiration);
// server to server API에 필요한 claims 설정
JwtData data = new JwtData();
data.setInfo("서버 claim 정보");
claims.put("data", data);
return generateToken(claims);
}
private String refreshToken(Authentication auth) {
Claims claims = coreClaims(auth, jwtProps.getRefreshTokenExpiration());
return generateToken(claims);
}
private Claims parseToken(String token) {
try {
Claims claims = Jwts.parser()
.setSigningKey(TextCodec.BASE64.decode(jwtProps.getKeyString()))
.parseClaimsJws(token)
.getBody();
return claims;
}
catch(JwtException e) {
throw e;
}
}
}

View File

@@ -0,0 +1,67 @@
package kr.co.uplus.ez.common.auth.jwt;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import kr.co.uplus.ez.common.auth.AuthUser;
@JsonIgnoreProperties({ "status", "userPwd", "pwdChgDt", "loginFailCnt", "phone", "sms", "username", "password",
"enabled", "accountNonExpired", "accountNonLocked", "credentialsNonExpired" })
public class JwtUser extends AuthUser {
private static final long serialVersionUID = -1233591656437541107L;
/* ckr
public static JwtUser createJwtUser(AuthUser user) {
JwtUser u = new JwtUser();
u.setCorpId(user.getCorpId());
u.setUserId(user.getUserId());
u.setUserNm(user.getUserNm());
u.setAuthorities(user.getAuthorities());
return u;
}
public static JwtUser createAuthUser(Map<String, Object> principal) {
JwtUser u = new JwtUser();
if (principal.get("corpId") != null) {
u.setCorpId((String) principal.get("corpId"));
}
u.setUserId((String) principal.get("userId"));
u.setUserNm((String) principal.get("userNm"));
@SuppressWarnings({ "unchecked", "rawtypes" })
Collection<? extends GrantedAuthority> authorities = ((List<Map>) principal.get("authorities")).stream()
.map(o -> new SimpleGrantedAuthority((String) o.get("authority"))).collect(Collectors.toList());
u.setAuthorities(authorities);
return u;
}
*/
public static JwtUser createJwtUser(AuthUser user) {
JwtUser u = new JwtUser();
u.setCorpId(user.getCorpId());
u.setOprtrId(user.getOprtrId());
u.setOprtrNm(user.getUsername());
u.setAuthorities(user.getAuthorities());
return u;
}
public static JwtUser createAuthUser(Map<String, Object> principal) {
JwtUser u = new JwtUser();
if (principal.get("corpId") != null) {
u.setCorpId((String) principal.get("corpId"));
}
u.setOprtrId((String) principal.get("userId"));
u.setOprtrNm((String) principal.get("userNm"));
@SuppressWarnings({ "unchecked", "rawtypes" })
Collection<? extends GrantedAuthority> authorities = ((List<Map>) principal.get("authorities")).stream()
.map(o -> new SimpleGrantedAuthority((String) o.get("authority"))).collect(Collectors.toList());
u.setAuthorities(authorities);
return u;
}
}

View File

@@ -0,0 +1,13 @@
package kr.co.uplus.ez.common.auth.jwt;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PublicToken {
private String accessToken;
private String refreshToken;
}

View File

@@ -0,0 +1,33 @@
package kr.co.uplus.ez.common.components;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
@Service
public class WebClientRequestService {
private static final Logger log = LoggerFactory.getLogger(WebClientRequestService.class);
@Autowired
private WebClient webClient;
public Object callBySyncGet(String uri) {
Date startTime = new Date();
Object result = webClient.get().uri(uri).retrieve().bodyToMono(Object.class).block();
log.debug("callBySyncGet duration Time : {}", (new Date().getTime() - startTime.getTime()) / 1000f);
return result;
}
public Object callBySyncPost(String uri, Object param) {
Date startTime = new Date();
Object result = webClient.post().uri(uri).bodyValue(param).retrieve().bodyToMono(Object.class).block();
log.debug("callBySyncPost duration Time : {}", (new Date().getTime() - startTime.getTime()) / 1000f);
return result;
}
}

View File

@@ -0,0 +1,23 @@
package kr.co.uplus.ez.common.consts;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import lombok.Data;
@Component
@ConfigurationProperties("app.props")
@Data
public class ConfigProps {
private String smsAuthnumMsg;
private String smsCallback;
private String[] xssExcludes;
private Log log;
@Data
public static class Log {
private String tloRoot;
private String tloMdcKey;
}
}

View File

@@ -0,0 +1,27 @@
package kr.co.uplus.ez.common.consts;
import java.util.Arrays;
import java.util.List;
public class Const {
//
public static final String KEY_MDC_LOG = "logKey";
public static final String KEY_LOG_OBJ = "logObj";
public static final String KEY_LOAD_USER = "loadUser"; // UserDetailsService에서 로딩하는 사용자정보
public static final String KEY_TOKEN_EXIST = "jwtTokenExist";
//
public static final String TLO_LOGGER = "tloLogger";
public static final List<String> NOT_LOG_PARAMS = Arrays.asList("userPwd", "curPwd", "newPwd", "cfmPwd");
//
public static final int SESSION_EXPIRED = 418;
// 정책
public static final int PWD_EXPIRE_DAYS = 90; // 비밀번호 만료기간 (일)
public static final int MAX_LOGIN_FAIL = 5; // 5회 로그인 실패하면 계정 잠김
public static final int AUTHNUM_EXPIRE_MINS = 3; // 인증번호 만료기간 (분)
public static final int MAX_AUTHNUM_FAIL = 5; // 5회 인증번호 검증 실패하면 발행 잠김
public static final int AUTHNUM_LOCK_EXPIRE_MINS = 30; // 인증번호발행 잠김 만료기간 (분)
}

View File

@@ -0,0 +1,65 @@
package kr.co.uplus.ez.common.consts;
import java.util.HashMap;
import java.util.Map;
public enum ResultCode {
SUCCESS ("20000000", "성공")
, SS_NOT_USE ("20000101", "중지 계정")
, SS_LOCK ("20000102", "잠김 계정")
// , SS_PWD_EXPIRE ("20000103", "비밀번호 만료")
// , SS_INIT_PWD ("20000104", "최초 비밀번호 변경 필요")
, SS_XLS_LIMIT ("20000206", "최대 엑셀 rows 초과")
, SS_DUP_USER_ID ("20000207", "사용자ID 중복")
, SS_INVLD_USER_ID ("20000208", "사용 할 수 없는 사용자ID(RCS_INVLD_USER.USER_ID)")
, SS_INVLD_ROLE ("20000209", "권한이 없는 사용자ID")
, SS_NOT_FOUND ("20000404", "없는 페이지")
, CE_PARAM ("30000101", "입력 파라미터 오류")
, CE_WRONG_AUTHNUM ("30000102", "인증번호 불일치")
, CE_AUTHNUM_EXPIRE ("30000103", "인증번호 만료")
, CE_AUTHNUM_LOCK ("30000104", "인증번호 발행 잠김")
, CE_ID_PWD ("30000201", "ID/PWD 불일치")
, CE_TO_LOCK ("30000202", "ID/PWD 불일치 횟수초과로 계정 잠김")
, CE_ID_NOT_FOUND ("30000203", "존재하지 않는 사용자ID")
, CE_WRONG_PWD ("30000301", "비밀번호 불일치")
, CE_USED_PWD ("30000302", "기존 비밀번호")
, SE_DB ("50000000", "DB 연동 오류")
, SE_DOWNLOAD ("50000101", "파일 다운로드 오류")
, SE_UPLOAD ("50000102", "파일 업로드 오류")
, SE_SMS_NUM ("50000201", "인증번호 발송 실패")
, SE_REDIS ("50000200", "REDIS 연동 오류")
, SE_INTERNAL ("50000500", "Internal Error")
, SE_UNKNOWN ("59999999", "알 수 없는 에러")
, API_KEY_NOT_FOUND ("60000001", "API Key 없음")
, API_KEY_PATT_INVLD ("60000002", "유효하지 않는 API Key 형식 오류")
, API_KEY_INVLD ("60000101", "유효하지 않는 API Key (RBC)")
, API_RBC_TOKEN_FAIL ("60000102", "RBC 토큰 발행 실패")
, API_RBC_CONN_FAIL ("60000103", "RBC 연결 실패")
, API_RBC_SYNC_FAIL ("60000104", "RBC 연동 실패")
, API_RBC_URL_INVLD ("60000105", "RBC URL 확인요망")
, API_RSLT_SYNC_FAIL ("60000201", "RBC 데이터 동기화 실패")
;
private String value;
private String desc;
private ResultCode(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return value;
}
public String getDesc() {
return desc;
}
private static final Map<String, ResultCode> lookup = new HashMap<String, ResultCode>();
static {
for (ResultCode e : ResultCode.values()) {
lookup.put(e.getValue(), e);
}
}
public static ResultCode find(String value) {
return lookup.get(value);
}
}

View File

@@ -0,0 +1,32 @@
package kr.co.uplus.ez.common.consts;
import java.util.HashMap;
import java.util.Map;
public enum UserStatus {
USE("사용")
, NOTUSE("중지")
, LOCK("차단");
private String value;
private String desc;
private UserStatus(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public String getDesc() {
return desc;
}
private static final Map<String, UserStatus> lookup = new HashMap<String, UserStatus>();
static {
for (UserStatus e : UserStatus.values()) {
lookup.put(e.getValue(), e);
}
}
public static UserStatus find(String value) {
return lookup.get(value);
}
}

View File

@@ -0,0 +1,115 @@
package kr.co.uplus.ez.common.data;
public enum ApiResponseCode {
RESULT_CODE("resultCode")
, RESULT_MSG("resultMsg")
, SUCCESS("0000", "Success")
, URI_NOT_EXIST("100", "Invalid access path.") // 404 에러 처리
, METHOD_NOT_ALLOWED("101", "This is the wrong approach.") // 요청 method 오류 (405)
, UNSUPPORTED_CONTENT_TYPE("102", "Content-Type error.") // 요청 Content-Type 오류
, UNSUPPORTED_CONTENT_LENGTH("103", "Content-Length error.") // 요청 Content-Length 오류
, UNSUPPORTED_ACCEPT("104", "ACCEPT error.") // 요청 Accept 오류
, UNSUPPORTED_CACHE_CONTROL("105", "Cache-Control error.") // 요청 Cache-Control 오류
, UNSUPPORTED_ACCEPT_ENCODING("106", "Accept-Encoding error.") // 요청 Accept-Encoding 오류
, UNSUPPORTED_TIMESTAMP("107", "Timestamp error.") // 요청 Timestamp 오류
, UNSUPPORTED_TUID("108", "TUID error.") // 요청 TUID 오류
, UNSUPPORTED_APPLICATIONID("109", "ApplicationId error.") // 요청 ApplicationId 오류
, INVALID_HEADER_VALUE("110", "Not Json header type.")
, TOKEN_NOT_EXIST("200", "Missing Token.") // 토큰 누락
, TOKEN_INVALID("201", "Invalid Token.") // 유효하지 않은 Token(기간 만료)
, TOKEN_NOT_AVAILABLE("202", "Unusable Token.") // token 사용 불가(token-매핑 정보 오류)
, REQ_MSG_INVALID("300", "This is a protocol format error.")
, REQ_MANDATORY_PARAM_NOT_EXIST("301", "Required parameter error.")
, NO_DATA_FOUND("302", "There are no search results.")
, DECRYPTION_ERR("303", "Decryption error.")
, REQ_MDN_INVALID("304", "Mismatched MDN.")
, NOT_EQUAL_CTRL_CNT("305", "Not equal control count.")
, NOT_EQUAL_GEO_CNT("306", "Not equal geo count.")
, NOT_EQUAL_DATE_TYPE("307", "Not equal Date type.")
, DB_QUERY_ERR("400", "An error occurred while processing data.")
, DB_DUPLICATE_KEY_ERR("401", "Duplicate Key.") // key값 중복
, SYS_ERR("500", "An undefined error has occurred.")
//BIZ연동
, BIZ_OK("OK", "SUCCESS")
, BIZ_FAIL("FAIL", "예기치 못한 오류가 발생하였습니다. 재 시도 해 주시기 바랍니다.")
, BIZ_NOT_FOUNT("404", "Not Found") // 요청한 리소스가 없는 경우 반환
, BIZ_REQUEST_ENTITY_TOO_LARGE("413", "Request Entity Too Large") // 요청 데이터가 너무 큰 경우 반환
, BIZ_SYS_ERR("500", "Internal server error") // 처리중 시스템 오류 발생
// admin result code
, CE_AUTH_TOKEN_EXPIRE ("4001", "인증토큰 만료")
, CE_REFRESH_AUTH_TOKEN_EXPIRE ("4002", "Refresh 토큰 만료")
, CE_ID_NOT_FOUND ("4003", "사용자 정보가 없습니다.")
, CE_ID_PWD ("4004", "ID/PWD 불일치")
, CE_TO_LOCK ("4005", "ID/PWD 불일치 횟수초과")
, SS_NOT_USE ("4001", "사용자 상태 오류")
, CE_ID_HP ("4006", "ID/HP 불일치")
, CE_AUTHNUM_EXPIRE ("4007", "인증시간 초과")
, CE_WRONG_AUTHNUM ("4007", "인증번호 오류")
, CE_AUTHNUM_LOCK ("4007", "인증번호 불일치 횟수초과")
// , SS_LOCK ("20000102", "잠김 계정")
// , SS_PWD_EXPIRE ("20000103", "비밀번호 만료")
// , SS_INIT_PWD ("20000104", "최초 비밀번호 변경 필요")
// , SS_XLS_LIMIT ("20000206", "최대 엑셀 rows 초과")
// , SS_DUP_USER_ID ("20000207", "사용자ID 중복")
// , SS_INVLD_USER_ID ("20000208", "사용 할 수 없는 사용자ID(RCS_INVLD_USER.USER_ID)")
// , SS_INVLD_ROLE ("20000209", "권한이 없는 사용자ID")
// , SS_NOT_FOUND ("20000404", "없는 페이지")
// , CE_PARAM ("30000101", "입력 파라미터 오류")
// , CE_AUTHNUM_LOCK ("30000104", "인증번호 발행 잠김")
// , CE_WRONG_PWD ("30000301", "비밀번호 불일치")
// , CE_USED_PWD ("30000302", "기존 비밀번호")
// , SE_DB ("50000000", "DB 연동 오류")
// , SE_DOWNLOAD ("50000101", "파일 다운로드 오류")
// , SE_UPLOAD ("50000102", "파일 업로드 오류")
// , SE_SMS_NUM ("50000201", "인증번호 발송 실패")
// , SE_REDIS ("50000200", "REDIS 연동 오류")
, SE_INTERNAL ("50000500", "Internal Error")
, SE_UNKNOWN ("59999999", "알 수 없는 에러")
// , API_KEY_NOT_FOUND ("60000001", "API Key 없음")
// , API_KEY_PATT_INVLD ("60000002", "유효하지 않는 API Key 형식 오류")
// , API_KEY_INVLD ("60000101", "유효하지 않는 API Key (RBC)")
// , API_RBC_TOKEN_FAIL ("60000102", "RBC 토큰 발행 실패")
// , API_RBC_CONN_FAIL ("60000103", "RBC 연결 실패")
// , API_RBC_SYNC_FAIL ("60000104", "RBC 연동 실패")
// , API_RBC_URL_INVLD ("60000105", "RBC URL 확인요망")
// , API_RSLT_SYNC_FAIL ("60000201", "RBC 데이터 동기화 실패")
;
private String resultCode;
private String resultMsg;
public String getResultCode() {
return resultCode;
}
public void setResultCode(String resultCode) {
this.resultCode = resultCode;
}
public String getResultMsg() {
return resultMsg;
}
public void setResultMsg(String resultMsg) {
this.resultMsg = resultMsg;
}
private ApiResponseCode(String resultCode) {
this.resultCode = resultCode;
}
private ApiResponseCode(String resultCode, String resultMsg) {
this.resultCode = resultCode;
this.resultMsg = resultMsg;
}
public static boolean has(String key) {
ApiResponseCode[] codes = values();
for (ApiResponseCode code : codes)
if (code.name().equals(key))
return true;
return false;
}
}

View File

@@ -0,0 +1,32 @@
package kr.co.uplus.ez.common.data;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ApiResponseMessage<T> {
private String retCode;
private String retMsg;
protected T data;
public ApiResponseMessage() {
this.retCode = ApiResponseCode.SUCCESS.getResultCode();
this.retMsg = ApiResponseCode.SUCCESS.getResultMsg();
}
public ApiResponseMessage(ApiResponseCode returnStr) {
this.retCode = returnStr.getResultCode();
this.retMsg = returnStr.getResultMsg();
}
public ApiResponseMessage(String code, String msg) {
this.retCode = code;
this.retMsg = msg;
}
}

View File

@@ -0,0 +1,21 @@
package kr.co.uplus.ez.common.data;
public class Const {
private static final String COMM_YES = "Y";
// paging
private static final String TOTAL_CNT = "totalCnt";
private static final String CURRENT_PAGE = "currentPage";
public static String getCommYes() {
return COMM_YES;
}
public static String getTotalCnt() {
return TOTAL_CNT;
}
public static String getCurrentPage() {
return CURRENT_PAGE;
}
}

View File

@@ -0,0 +1,8 @@
package kr.co.uplus.ez.common.data;
public interface IResult<S, T> {
public boolean isSuccess() ;
public S getCode();
public String getMessage();
public T getData();
}

View File

@@ -0,0 +1,38 @@
package kr.co.uplus.ez.common.data;
public class PageScope extends Pagination {
private int num; // rownum
private int perPage = 1;
private int offset = 0;
private int endOffset = 1;
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public int getPerPage() {
return perPage;
}
public void setPerPage(int perPage) {
this.perPage = perPage;
}
public Integer getEndOffset() {
setEndOffset(getOffset() + getPerPage());
return endOffset;
}
public void setEndOffset(Integer endOffset) {
this.endOffset = endOffset;
}
public Integer getOffset() {
int sPage = (this.page - 1 < 0 ? 0 : this.page - 1);
offset = (sPage * this.perPage);
return offset;
}
public void setOffset(Integer offset) {
this.offset = offset;
}
}

View File

@@ -0,0 +1,20 @@
package kr.co.uplus.ez.common.data;
public class Pagination {
protected int page;
protected int totalCount;
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
}

View File

@@ -0,0 +1,59 @@
package kr.co.uplus.ez.common.data;
import kr.co.uplus.ez.common.consts.ResultCode;
public class RestResult<T> implements IResult<ResultCode, T> {
protected boolean success = true;
protected ResultCode code;
protected String message;
protected T data;
public RestResult() {
}
public RestResult(boolean success) {
this.success = success;
}
public boolean isSuccess() {
return success;
}
public RestResult<T> setSuccess(boolean success) {
this.success = success;
return this;
}
public ResultCode getCode() {
return code;
}
public RestResult<T> setCode(ResultCode code) {
this.code = code;
return this;
}
public String getMessage() {
return message;
}
public RestResult<T> setMessage(String message) {
this.message = message;
return this;
}
public T getData() {
return data;
}
public RestResult<T> setData(T data) {
this.data = data;
return this;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("RestResult [success=");
builder.append(success);
builder.append(", code=");
builder.append(code);
builder.append(", message=");
builder.append(message);
builder.append(", data=");
builder.append(data);
builder.append("]");
return builder.toString();
}
}

View File

@@ -0,0 +1,62 @@
package kr.co.uplus.ez.common.data;
public class Result<T> implements IResult<String, T> {
protected boolean success = true;
protected boolean result = true;
protected String code;
protected String message;
protected T data;
public Result() {
}
public Result(boolean success) {
this.success = success;
}
public boolean isSuccess() {
return success;
}
public boolean isResult() {
return result;
}
public Result<T> setSuccess(boolean success) {
this.success = success;
this.result = success;
return this;
}
public String getCode() {
return code;
}
public Result<T> setCode(String code) {
this.code = code;
return this;
}
public String getMessage() {
return message;
}
public Result<T> setMessage(String message) {
this.message = message;
return this;
}
public T getData() {
return data;
}
public Result<T> setData(T data) {
this.data = data;
return this;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Result [success=");
builder.append(success);
builder.append(", code=");
builder.append(code);
builder.append(", message=");
builder.append(message);
builder.append(", data=");
builder.append(data);
builder.append("]");
return builder.toString();
}
}

View File

@@ -0,0 +1,27 @@
package kr.co.uplus.ez.common.data;
public class SearchInfo extends PageScope {
private String sort;
private String searchType;
private String searchText;
public String getSearchType() {
return searchType;
}
public void setSearchType(String searchType) {
this.searchType = searchType;
}
public String getSearchText() {
return searchText;
}
public void setSearchText(String searchText) {
this.searchText = searchText;
}
public String getSort() {
return sort;
}
public void setSort(String sort) {
this.sort = sort;
}
}

View File

@@ -0,0 +1,103 @@
package kr.co.uplus.ez.common.security;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
/**
* key가 16byte(128bit)면 AES128로 동작한다.
* key가 32byte(256bit)면 AES256으로 동작한다.
*/
public class Aes256 {
private static final String ALGORITHM = "AES";
private static final String TRANSFORMATION = "AES/CBC/PKCS5Padding"; // algorithm/mode/padding
// private static final String TRANSFORMATION = "AES/ECB/PKCS5Padding"; // "AES"와 같다. ECB mode cannot use IV
public static byte[] encrypt(byte[] plainText, byte[] key) {
byte[] iv = new byte[16];
return encrypt(plainText, key, iv);
}
public static byte[] encrypt(byte[] plainText, byte[] key, byte[] iv) {
try {
Cipher c = Cipher.getInstance(TRANSFORMATION);
SecretKeySpec k = new SecretKeySpec(key, ALGORITHM);
IvParameterSpec ivSpec = new IvParameterSpec(iv);
c.init(Cipher.ENCRYPT_MODE, k, ivSpec);
return c.doFinal(plainText);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
public static String encryptBase64(String plainText, byte[] key) {
byte[] iv = new byte[16];
return encryptBase64(plainText, key, iv);
}
public static String encryptBase64(String plainText, byte[] key, byte[] iv) {
byte[] enc = encrypt(plainText.getBytes(), key, iv);
return new String(Base64.encodeBase64(enc));
}
public static byte[] decrypt(byte[] cipherText, byte[] key) {
byte[] iv = new byte[16];
return decrypt(cipherText, key, iv);
}
public static byte[] decrypt(byte[] cipherText, byte[] key, byte[] iv) {
try {
Cipher c = Cipher.getInstance(TRANSFORMATION);
SecretKeySpec k = new SecretKeySpec(key, ALGORITHM);
IvParameterSpec ivSpec = new IvParameterSpec(iv);
c.init(Cipher.DECRYPT_MODE, k, ivSpec);
return c.doFinal(cipherText);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
public static String decryptBase64(String b64CipherText, byte[] key) {
byte[] iv = new byte[16];
return decryptBase64(b64CipherText, key, iv);
}
public static String decryptBase64(String b64CipherText, byte[] key, byte[] iv) {
byte[] enc = Base64.decodeBase64(b64CipherText.getBytes());
return new String(decrypt(enc, key, iv));
}
public static String encryptNoIvBase64(String plainText, byte[] key) {
try {
Cipher c = Cipher.getInstance(ALGORITHM);
SecretKeySpec k = new SecretKeySpec(key, ALGORITHM);
c.init(Cipher.ENCRYPT_MODE, k); // ECB mode cannot use IV
byte[] enc = c.doFinal(plainText.getBytes());
return new String(Base64.encodeBase64(enc));
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
public static String decryptNoIvBase64(String b64CipherText, byte[] key) {
try {
Cipher c = Cipher.getInstance(ALGORITHM);
SecretKeySpec k = new SecretKeySpec(key, ALGORITHM);
c.init(Cipher.DECRYPT_MODE, k); // ECB mode cannot use IV
byte[] enc = Base64.decodeBase64(b64CipherText.getBytes());
return new String(c.doFinal(enc));
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,42 @@
package kr.co.uplus.ez.common.security;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.filter.GenericFilterBean;
// http://www.servletsuite.com/servlets/xssflt.htm
public class VueStaticFilter extends GenericFilterBean {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
if (shouldExclude(request)) {
chain.doFilter(request, response);
// some logic so the request doesnt go to the servlet
// maybe you could just forward
// the request directly to the file getting accessed. not sure if that would
// work
} else {
((HttpServletRequest) request).getRequestDispatcher("/").forward(request, response);
}
// file should be passed to the servlet; you can do some logic here
// if you want
}
private boolean shouldExclude(ServletRequest req) {
if (req instanceof HttpServletRequest) {
HttpServletRequest hreq = (HttpServletRequest) req;
return !(hreq.getRequestURI().startsWith("/view"));
}
return true;
}
}

View File

@@ -0,0 +1,103 @@
package kr.co.uplus.ez.common.security;
import java.io.IOException;
import java.util.regex.Pattern;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import org.springframework.web.filter.GenericFilterBean;
import kr.co.uplus.ez.common.consts.ConfigProps;
import kr.co.uplus.ez.common.utils.WebUtils;
// http://www.servletsuite.com/servlets/xssflt.htm
public class XssFilter extends GenericFilterBean {
private final ConfigProps cprops;
public XssFilter(ConfigProps cprops) {
this.cprops = cprops;
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
if (skip(request)) {
chain.doFilter(request, response);
}
else {
chain.doFilter(new RequestWrapper((HttpServletRequest) request), response);
}
}
private boolean skip(ServletRequest request) {
return WebUtils.isMatchedUri((HttpServletRequest)request, cprops.getXssExcludes());
}
/**
* 이 wrapper를 사용해도 request.getParameterMap()에는 원본 파라미터가 저장돼 있다.
*/
public static class RequestWrapper extends HttpServletRequestWrapper {
public RequestWrapper(HttpServletRequest request) {
super(request);
}
@Override
public String[] getParameterValues(String name) {
String[] values = super.getParameterValues(name);
if (values == null) {
return null;
}
int count = values.length;
String[] encodedValues = new String[count];
for (int i = 0; i < count; i++) {
encodedValues[i] = removeXSS(values[i]);
}
return encodedValues;
}
@Override
public String getParameter(String name) {
String value = super.getParameter(name);
if (value == null) {
return null;
}
return removeXSS(value);
}
@Override
public String getHeader(String name) {
String value = super.getHeader(name);
if (value == null)
return null;
return removeXSS(value);
}
}
private static Pattern p1 = Pattern.compile("eval\\((.*?)\\)");
private static Pattern p2 = Pattern.compile("onload(.*?)=");
public static String removeXSS(String value) {
value = value.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
value = value.replaceAll("\\(", "&#40;").replaceAll("\\)", "&#41;");
value = value.replaceAll("'", "&#39;");
value = value.replaceAll("javascript:", "").replaceAll("vbscript:", "").replaceAll("script", "");
value = p1.matcher(value).replaceAll("");
value = p2.matcher(value).replaceAll("");
return value;
}
public static String recoverXSS(String value) {
if (value == null || "".equals(value))
return value;
value = value.replaceAll("&lt;", "<").replaceAll("&gt;", ">");
value = value.replaceAll("&#40;", "\\(").replaceAll("&#41;", "\\)");
value = value.replaceAll("&#39;", "'");
return value;
}
}

View File

@@ -0,0 +1,123 @@
package kr.co.uplus.ez.common.utils;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.Days;
import org.joda.time.Minutes;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
public class DateUtils {
private static final String DF_FORMAT_STR = "yyyy-MM-dd HH:mm:ss";
private static final String DF_YMD_FORMAT_STR = "yyyy-MM-dd";
private static final DateTimeFormatter YMD = DateTimeFormat.forPattern("yyyyMMdd");
private static final DateTimeFormatter YMDHMS = DateTimeFormat.forPattern("yyyyMMddHHmmss");
private static final DateTimeFormatter dfFormat = DateTimeFormat.forPattern(DF_FORMAT_STR);
private static final DateTimeFormatter dfYmdHmFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");
private static final DateTimeFormatter dfYmdFormat = DateTimeFormat.forPattern(DF_YMD_FORMAT_STR);
private static final DateTimeFormatter YMDHMS_VIEW_FORMAT = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
public static DateTime str2dateYMD(String str) {
return str2date(str, YMD);
}
public static DateTime str2dateYMDHMS(String str) {
return str2date(str, YMDHMS);
}
public static DateTime str2date(String str, DateTimeFormatter fmt) {
return DateTime.parse(str, fmt);
}
public static String date2strYMD() {
return dtime2str(DateTime.now(), YMD);
}
public static String date2strYMDHMS() {
return dtime2str(DateTime.now(), YMDHMS);
}
public static String date2strYMD(Date date) {
return dtime2str(new DateTime(date), YMD);
}
public static String date2strYMDHMS(Date date) {
return dtime2str(new DateTime(date), YMDHMS);
}
public static String dtime2str(DateTime date, DateTimeFormatter fmt) {
return date.toString(fmt);
}
public static int diffDays(DateTime begin, DateTime end) {
return Days.daysBetween(begin, end).getDays();
}
public static int diffMinutes(DateTime begin, DateTime end) {
return Minutes.minutesBetween(begin, end).getMinutes();
}
public static String dfmtDate2str(Date date) {
return new DateTime(date).toString(dfFormat);
}
public static DateTime date2strYmdhms(String str) {
return new DateTime(str);
}
public static DateTime date2strYmdhmsfmt(String str) {
return str2date(str, dfFormat);
}
public static String dYmdHmfmtDate2str(Date date) {
return new DateTime(date).toString(dfYmdHmFormat);
}
public static String dYmdfmtDate2str(Date date) {
return new DateTime(date).toString(dfYmdFormat);
}
public static DateTime str2dataDYmdfmt(String str) {
return new DateTime(str);
// return DateTime.parse(dt.toString(DF_YMD_FORMAT_STR), dfYmdFormat);
}
public static String strDateFormatString(String str) {
if (StringUtils.isEmpty(str)) return "";
return dfmtDate2str(org.apache.http.client.utils.DateUtils.parseDate(str));
}
public static String datetimeToStr(DateTime dt, String pattern) {
try {
if (dt != null) {
if (org.springframework.util.StringUtils.hasLength(pattern)) {
return dt.toString(DateTimeFormat.forPattern(pattern));
} else {
return dt.toString(YMDHMS_VIEW_FORMAT);
}
}
} catch (Exception e) {
}
return null;
}
public static String dateToStr(Date dt, String pattern) {
try {
if (dt != null) {
return datetimeToStr(new DateTime(dt.getTime()), pattern);
}
} catch (Exception e) {
}
return null;
}
}

View File

@@ -0,0 +1,397 @@
package kr.co.uplus.ez.common.utils;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class EncryptionUtil {
// 파일구분자
static final char FILE_SEPARATOR = File.separatorChar;
static final int BUFFER_SIZE = 1024;
/**
* 비밀번호를 암호화하는 기능(복호화가 되면 안되므로 SHA-256 인코딩 방식 적용)
*
* @param password 암호화될 패스워드
* @param id salt로 사용될 사용자 ID 지정
* @return
* @throws Exception
*/
public static String encryptPassword(String password, String id) throws Exception {
if (password == null)
return "";
if (id == null)
return "";
byte[] hashValue = null;
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.reset();
md.update(id.getBytes());
hashValue = md.digest(password.getBytes());
return new String(Base64.encodeBase64(hashValue));
}
/**
* 비밀번호를 암호화하는 기능(복호화가 되면 안되므로 SHA-256 인코딩 방식 적용)
*
* @param data 암호화할 비밀번호
* @param salt Salt
* @return 암호화된 비밀번호
* @throws Exception
*/
public static String encryptPassword(String data, byte[] salt) throws Exception {
if (data == null) {
return "";
}
byte[] hashValue = null; // 해쉬값
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.reset();
md.update(salt);
hashValue = md.digest(data.getBytes());
return new String(Base64.encodeBase64(hashValue));
}
/**
* 비밀번호를 암호화된 패스워드 검증(salt가 사용된 경우만 적용).
*
* @param data 원 패스워드
* @param encoded 해쉬처리된 패스워드(Base64 인코딩)
* @return
* @throws Exception
*/
public static boolean checkPassword(String data, String encoded, byte[] salt) throws Exception {
byte[] hashValue = null; // 해쉬값
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.reset();
md.update(salt);
hashValue = md.digest(data.getBytes());
return MessageDigest.isEqual(hashValue, Base64.decodeBase64(encoded.getBytes()));
}
public static boolean checkPassword(String data, String encoded, String id) throws Exception {
byte[] hashValue = null; // 해쉬값
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.reset();
md.update(id.getBytes());
hashValue = md.digest(data.getBytes());
return MessageDigest.isEqual(hashValue, Base64.decodeBase64(encoded.getBytes()));
}
/**
* SHA1.
*
* @param message
* @return
* @throws Exception
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
*/
public static String getSHA1Encrypt(String message)
throws Exception, NoSuchAlgorithmException, InvalidKeyException {
StringBuffer hexString = new StringBuffer();
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] hash = md.digest(message.getBytes("UTF-8"));
for (int i = 0; i < hash.length; i++) {
String hex = Integer.toHexString(0xFF & hash[i]);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}
/**
* SHA256.
*
* @param message
* @return
* @throws Exception
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
*/
public static String getSHA256Encrypt(String message)
throws Exception, NoSuchAlgorithmException, InvalidKeyException {
StringBuffer hexString = new StringBuffer();
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] hash = md.digest(message.getBytes("UTF-8"));
for (int i = 0; i < hash.length; i++) {
String hex = Integer.toHexString(0xFF & hash[i]);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}
/**
* SHA1
*
* @param message
* @return
* @throws Exception
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
*/
public static byte[] getSHA1EncryptByte(String message)
throws Exception, NoSuchAlgorithmException, InvalidKeyException {
MessageDigest digest = MessageDigest.getInstance("SHA-1");
digest.update(message.getBytes());
return digest.digest();
}
/**
* HmacSHA256 값 비교 로직.
*
* @param message
* @param reqHashData
* @return
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws DecoderException
*/
public static boolean isHashCompare(String message, String reqHashData)
throws NoSuchAlgorithmException, InvalidKeyException, DecoderException {
String key = System.getProperty("hmac.key");
boolean isHashCompare = true;
byte[] keyBytes = key.getBytes(StandardCharsets.UTF_8);
SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(secretKeySpec);
byte[] macBytes = mac.doFinal(message.getBytes());
byte[] ba = new byte[reqHashData.length() / 2];
for (int i = 0; i < ba.length; i++) {
ba[i] = ((byte) Integer.parseInt(reqHashData.substring(2 * i, 2 * i + 2), 16));
}
if (!MessageDigest.isEqual(macBytes, ba)) {
isHashCompare = false;
}
return isHashCompare;
}
public byte[] aesEncryptEcb(String sKey, String sText) {
byte[] key = null;
byte[] text = null;
byte[] encrypted = null;
final int AES_KEY_SIZE_128 = 128;
try {
// UTF-8
key = sKey.getBytes("UTF-8");
// Key size (128bit, 16byte)
key = Arrays.copyOf(key, AES_KEY_SIZE_128 / 8);
// UTF-8
text = sText.getBytes("UTF-8");
// AES/EBC/PKCS5Padding
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"));
encrypted = cipher.doFinal(text);
} catch (Exception e) {
encrypted = null;
log.error("aesEncryptEcb exception. : {}", e.getMessage());
}
return encrypted;
}
/*
* AES128 Decrypt
*/
public byte[] aesDecryptEcb(String sKey, byte[] encrypted) throws UnsupportedEncodingException {
byte[] key = null;
byte[] decrypted = null;
final int AES_KEY_SIZE_128 = 128;
try {
// UTF-8
key = sKey.getBytes("UTF-8");
// Key size 128 (128bit, 16byte)
key = Arrays.copyOf(key, AES_KEY_SIZE_128 / 8);
// AES/EBC/PKCS5Padding
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"));
decrypted = cipher.doFinal(encrypted);
} catch (Exception e) {
decrypted = null;
log.error("aesDecryptEcb exception. : {}", e.getMessage());
}
return decrypted;
}
/*
* AES256 Encrypt
*/
public byte[] aes256EncryptEcb(String sKey, String sText) {
byte[] key = null;
byte[] text = null;
byte[] encrypted = null;
final int AES_KEY_SIZE_256 = 256;
try {
// UTF-8
key = sKey.getBytes("UTF-8");
// Key size (256bit, 16byte)
key = Arrays.copyOf(key, AES_KEY_SIZE_256 / 8);
// UTF-8
text = sText.getBytes("UTF-8");
// AES/EBC/PKCS5Padding
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"));
encrypted = cipher.doFinal(text);
} catch (Exception e) {
encrypted = null;
log.error("aes256EncryptEcb exception. : {}", e.getMessage());
}
return encrypted;
}
/*
* AES256 Decrypt
*/
public byte[] aes256DecryptEcb(String sKey, byte[] encrypted) throws UnsupportedEncodingException {
byte[] key = null;
byte[] decrypted = null;
final int AES_KEY_SIZE_256 = 256;
try {
// UTF-8
key = sKey.getBytes("UTF-8");
// Key size (256bit, 16byte)
key = Arrays.copyOf(key, AES_KEY_SIZE_256 / 8);
// AES/EBC/PKCS5Padding
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"));
decrypted = cipher.doFinal(encrypted);
} catch (Exception e) {
decrypted = null;
log.error("aes256DecryptEcb exception. : {}", e.getMessage());
}
return decrypted;
}
public String toHexString(byte[] b) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < b.length; i++) {
sb.append(String.format("%02X", b[i]));
}
return sb.toString();
}
public byte[] toHexString2(String test) {
int len = test.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(test.charAt(i), 16) << 4) + Character.digit(test.charAt(i + 1), 16));
}
return data;
}
// 128 크기 sha-512
public static String getCustomSHA512(String key1, String key2){
String result = null;
if(key1 == null) {
key1 = "";
}
if(key2 == null) {
key2 = "";
}
try {
MessageDigest md = MessageDigest.getInstance("SHA-512");
md.reset();
md.update(key1.getBytes("utf8"));
md.update(key2.getBytes("utf8"));
result = String.format("%0128x", new BigInteger(1, md.digest()));
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static void main(String[] args) throws Exception {
String userId = "jambler01";
String userPwd = "1234qwer";
String encPwd = "";
encPwd = getCustomSHA512(userId, userPwd);
System.out.println("[user Id Password]:[" + userId+" , "+userPwd + "]");
System.out.println("[Encript Password]:[" + encPwd + "]");
//System.out.println("[Password chk Result]:[" + checkPassword(userPwd, encPwd, userId) + "]");
}
}

View File

@@ -0,0 +1,279 @@
package kr.co.uplus.ez.common.utils;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.zip.GZIPInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;
public class FileIoUtils {
/**
* @return d:/Downloads/aaa.txt --> aaa.txt
*/
public static String getName(String filePath) {
return FilenameUtils.getName(filePath);
}
/**
* @return d:/Downloads/aaa.txt --> txt
*/
public static String getExtension(String filePath) {
return FilenameUtils.getExtension(filePath);
}
/**
* @return d:/Downloads/aaa.txt --> d:/Downloads
*/
public static String getDirName(String filePath) {
int idx = filePath.indexOf(getName(filePath));
return filePath.substring(0, idx > 0 ? idx - 1 : 0);
}
/**
* @return d:/Downloads/aaa.txt --> aaa
*/
public static String getBaseName(String filename) {
return FilenameUtils.getBaseName(filename);
}
public static String streamToString(InputStream input, String encoding) {
try {
return IOUtils.toString(input, encoding);
}
catch (IOException e) {
throw new RuntimeException(e);
}
finally {
IOUtils.closeQuietly(input);
}
}
public static String streamToString(InputStream input) {
return streamToString(input, null);
}
public static String fileToString(File file) {
return fileToString(file, null);
}
public static String fileToString(File file, String encoding) {
try {
return org.apache.commons.io.FileUtils.readFileToString(file, encoding);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void stringToFile(String text, File file) {
stringToFile(text, file, null);
}
public static void stringToFile(String text, File file, String encoding) {
try {
org.apache.commons.io.FileUtils.write(file, text, encoding);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* stream을 복사하고 두 스트림 모두 닫는다.
*/
public static void copy(InputStream src, OutputStream dst) {
try {
IOUtils.copy(src, dst);
}
catch (IOException e) {
throw new RuntimeException(e);
}
finally {
IOUtils.closeQuietly(src);
IOUtils.closeQuietly(dst);
}
}
public static void copy(String src, String dst) {
try {
org.apache.commons.io.FileUtils.copyFile(new File(src), new File(dst));
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
public static File mkDirIfNotExist(String dir) {
File file = new File(dir);
if (!file.isDirectory())
file.mkdirs();
return file;
}
public static void fileDownload(Resource res
, HttpServletRequest request, HttpServletResponse response) throws IOException {
fileDownload(res.getFile(), request, response);
}
public static void setDownloadHeader(String fileName, HttpServletRequest request, HttpServletResponse response) throws IOException {
// response header
String userAgent = request.getHeader("User-Agent");
String fname, dispos;
if (userAgent.indexOf("MSIE 5.5") >= 0) {
fname = URLEncoder.encode(fileName, "UTF-8");
dispos = String.format("filename=\"%s\"", fname);
}
else if (userAgent.indexOf("MSIE") >= 0) {
fname = URLEncoder.encode(fileName, "UTF-8");
dispos = String.format("attachment; filename=\"%s\"", fname);
}
else {
fname = new String(fileName.getBytes("EUC-KR"), "8859_1");
dispos = String.format("attachment; filename=\"%s\"", fname);
}
response.setHeader("Content-Disposition", dispos);
response.setHeader("Content-Transfer-Encoding", "binary;");
}
public static void fileDownload(File file, HttpServletRequest request, HttpServletResponse response) throws IOException {
String fileName = file.getName();
long fileSize = file.length();
InputStream in = new FileInputStream(file);
// response header
setDownloadHeader(fileName, request, response);
response.setHeader("Content-Length", String.valueOf(fileSize));
// write to response
OutputStream out = response.getOutputStream();
try {
IOUtils.copy(in, out);
}
finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
}
public static boolean fileUpload(MultipartFile upfile, File savefile) throws IOException {
return fileUpload(upfile, savefile, false);
}
public static boolean fileUpload(MultipartFile upfile, File savefile, boolean append) throws IOException {
if (upfile == null || upfile.isEmpty())
return false;
String saveDir = getDirName(savefile.getAbsolutePath());
mkDirIfNotExist(saveDir);
if (!append) {
upfile.transferTo(savefile);
}
else {
InputStream in = null;
OutputStream out = null;
try {
in = upfile.getInputStream();
out = new FileOutputStream(savefile, true);
IOUtils.copy(in, out);
}
finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
}
return true;
}
/**
* @param ext "."를 포함해야 정확한 결과를 얻는다.
*/
public static boolean isExtension(String fname, String... exts) {
if (fname == null) return false;
for (String ext : exts) {
if (fname.toLowerCase().endsWith(ext.toLowerCase()))
return true;
}
return false;
}
/**
* 파일이 없으면 생성, 있으면 추가.
*/
public static void writeLine(File file, String line) {
try {
org.apache.commons.io.FileUtils.writeLines(file, Arrays.asList(line), true);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void writeLines(File file, List<String> lines) {
try {
org.apache.commons.io.FileUtils.writeLines(file, lines, true);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
public static List<File> unzip(File zip, String saveDir) throws Exception {
int bufSize = 1024 * 64;
List<File> files = new ArrayList<File>();
ZipInputStream in = new ZipInputStream(new BufferedInputStream(new FileInputStream(zip), bufSize));
ZipEntry entry = null;
while ((entry = in.getNextEntry()) != null) {
byte[] buffer = new byte[bufSize];
File outfile = new File(saveDir, entry.getName());
OutputStream out = new BufferedOutputStream(new FileOutputStream(outfile), bufSize);
int size = 0;
while ((size = in.read(buffer, 0, bufSize)) != -1) {
out.write(buffer, 0, size);
}
out.flush();
IOUtils.closeQuietly(out);
files.add(outfile);
}
IOUtils.closeQuietly(in);
return files;
}
public static File ungzip(File gzip, String saveDir) throws Exception {
String outName = getBaseName(gzip.getName());
File outfile = new File(saveDir, outName);
InputStream in = new GZIPInputStream(new FileInputStream(gzip));
OutputStream out = new FileOutputStream(outfile);
IOUtils.copy(in, out);
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
return outfile;
}
}

View File

@@ -0,0 +1,271 @@
package kr.co.uplus.ez.common.utils;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FilenameUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.web.multipart.MultipartFile;
public class FileUtil {
private static int BUFFERSIZE = 1024;
/**
* 폴더 생성
*/
public static boolean makeDir(String dir) {
boolean bResult = false;
File f = new File(dir);
if (!f.exists()) {
try {
bResult = f.mkdirs();
//Runtime.getRuntime().exec("chmod 775 " + dir);
} catch (Exception e) {
bResult = false;
}
}
return bResult;
}
/**
* 파일을 지정된 경로에 지정된 이름으로 저장 후 저장여부 리턴
* @param file
* @param path
* @return
*/
public static boolean upload(MultipartFile file, String filename, String path) {
boolean saved = true;
String extension = FilenameUtils.getExtension(file.getOriginalFilename()).toLowerCase();
String fos = path + File.separatorChar + filename + "." + extension;
InputStream inputStream = null;
OutputStream outputStream = null;
try {
if (file != null && file.getSize() > 0) {
if (!existsFile(path) ) FileUtil.makeDir(path);
inputStream = file.getInputStream();
outputStream = new FileOutputStream(fos);
int readBytes = 0;
byte[] buffer = new byte[BUFFERSIZE];
while ((readBytes = inputStream.read(buffer, 0, BUFFERSIZE)) != -1) {
outputStream.write(buffer, 0, readBytes);
}
//Runtime.getRuntime().exec("chmod 775 " + saveFileName);
}
} catch (Exception e) {
saved = false;
} finally {
close(outputStream);
close(inputStream);
}
return saved;
}
/**
* 파일 업로드 후 실제 저장된 파일명을 반환한다
* @param file
* @param path
* @return
*/
public static Map<String, String> upload_newname(MultipartFile file, String path) {
String extension = FilenameUtils.getExtension(file.getOriginalFilename()).toLowerCase();
String newName = new SimpleDateFormat("yyyyMMddHHmmSSS").format(new Date()) + "." + extension;
Date d = new Date(); // your date
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Asia/Seoul"));
cal.setTime(d);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
String newFilePath = path + File.separatorChar + year + File.separatorChar + month + File.separatorChar;
String newFileName = newFilePath + newName;
String saveFileName = newFileName;
InputStream inputStream = null;
OutputStream outputStream = null;
try {
if (file != null && file.getSize() > 0) {
if (!existsFile(newFilePath) ) FileUtil.makeDir(newFilePath);
inputStream = file.getInputStream();
outputStream = new FileOutputStream(saveFileName);
int readBytes = 0;
byte[] buffer = new byte[BUFFERSIZE];
while ((readBytes = inputStream.read(buffer, 0, BUFFERSIZE)) != -1) {
outputStream.write(buffer, 0, readBytes);
}
//Runtime.getRuntime().exec("chmod 775 " + saveFileName);
}
} catch (Exception e) {
e.printStackTrace();
newName = "";
} finally {
close(outputStream);
close(inputStream);
}
Map<String, String> info = new HashMap<String, String>();
info.put("fileName", newName);
info.put("filePath", newFilePath);
return info;
}
/**
* 파일 존재 여부
*/
public static boolean existsFile(String file) {
File f = new File(file);
return f.exists();
}
/**
* HTTP 파일 다운로드
*/
public static void download(HttpServletRequest request, HttpServletResponse response, String filename, File file) {
download(request, response, filename, file, false);
}
/**
* 다운로드
*/
private static void download(HttpServletRequest request, HttpServletResponse response, String filename, File file, boolean isDeleteOnExit) {
if (file.exists()) {
FileInputStream fileInStream = null;
OutputStream outStream = null;
try {
String extension = FilenameUtils.getExtension(filename).toLowerCase();
// 형태에 따른 컨텐트 타입 분류
if ("zip".equals(extension)) response.setContentType("application/zip");
else if ("xls".equals(extension) || "xlsx".equals(extension)) response.setContentType("application/vnd.ms-excel;charset=UTF-8");
else if ("ppt".equals(extension) || "pptx".equals(extension)) response.setContentType("application/x-mspowerpoint");
else if ("doc".equals(extension) || "docx".equals(extension)) response.setContentType("application/msword");
else if ("pdf".equals(extension)) response.setContentType("application/x-msdownload");
else if ("jpg".equals(extension)) response.setContentType("image/jpg");
else if ("gif".equals(extension)) response.setContentType("image/gif");
else if ("png".equals(extension)) response.setContentType("image/png");
response.setHeader("Buffer", "true");
response.setHeader("Pragma", "no-cache;");
response.setHeader("Expires", "-1;");
response.setHeader("Content-Transfer-Encoding", "binary;");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20") + ";");
fileInStream = new FileInputStream(file);
outStream = response.getOutputStream();
int readBytes = 0;
byte[] buffer = new byte[BUFFERSIZE * 100];
while ((readBytes = fileInStream.read(buffer)) != -1) {
outStream.write(buffer, 0, readBytes);
}
outStream.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
close(fileInStream);
close(outStream);
if (isDeleteOnExit) {
file.delete();
}
}
}
}
/**
* 엑셀 파일 다운로드
*/
public static void download(HttpServletRequest request, HttpServletResponse response, String filename, Workbook workbook) {
OutputStream outStream = null;
try {
ByteArrayOutputStream outByteStream = new ByteArrayOutputStream();
workbook.write(outByteStream);
if (workbook instanceof SXSSFWorkbook) {
((SXSSFWorkbook) workbook).dispose();
}
byte [] outArray = outByteStream.toByteArray();
response.setContentLength(outArray.length);
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.setHeader("Pragma", "no-cache;");
response.setHeader("Expires", "-1;");
response.setHeader("Content-Transfer-Encoding", "binary;");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20") + ";");
response.setHeader("Buffer", "true");
outStream = response.getOutputStream();
outStream.write(outArray);
outStream.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
close(outStream);
}
}
/**
* InputStream을 종료한다.
*/
public static void close(InputStream stream) {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* OutputStream을 종료한다.
*/
public static void close(OutputStream stream) {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* FileOutputStream을 종료한다.
*/
public static void close(FileOutputStream stream) {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

View File

@@ -0,0 +1,155 @@
//package kr.co.uplus.ez.common.utils;
//
//import java.io.UnsupportedEncodingException;
//import java.lang.reflect.Method;
//import java.lang.reflect.Parameter;
//import java.util.Arrays;
//import java.util.Enumeration;
//
//import javax.servlet.http.HttpServletRequest;
//
//import org.joda.time.DateTime;
//import org.joda.time.format.DateTimeFormat;
//import org.joda.time.format.DateTimeFormatter;
//import org.springframework.util.LinkedMultiValueMap;
//import org.springframework.util.MultiValueMap;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.util.ContentCachingRequestWrapper;
//
//import kr.co.uplus.ez.common.auth.AuthUser;
//import kr.co.uplus.ez.common.consts.Const;
//
//
//public class LogUtils {
// public static final String HANG_LOG_KEY = "hangfile";
//
// private static final String HANG_LOG_ROOT = "/logs/uplus/hang/ui";
// private static final DateTimeFormatter FMT_TO_DAY = DateTimeFormat.forPattern("yyyyMMdd");
// private static final DateTimeFormatter FMT_TO_HOUR = DateTimeFormat.forPattern("yyyyMMddHH");
// private static final DateTimeFormatter FMT_TO_SECOND = DateTimeFormat.forPattern("yyyyMMddHHmmss");
// private static final DateTimeFormatter FMT_TO_MILSEC = DateTimeFormat.forPattern("yyyyMMddHHmmssSSS");
//
// public static String getTloLogfileName(String tloRoot) {
// DateTime now = DateTime.now();
// String dir = now.toString(FMT_TO_DAY);
// String suffix = now.toString(FMT_TO_HOUR);
// int min = 5 * (now.getMinuteOfHour() / 5);
// int NODE_NO = 1;
// return String.format("%s/%s/RCS.ADMIN.%03d.%s%02d.log", tloRoot, dir, NODE_NO, suffix, min);
// }
//
// public static String getLoginId() {
// AuthUser user = SpringUtils.getCurrentUser();
// if (user == null)
// return "anonymousUser";
//
// return user.getUsername();
// }
//
// public static String getCurrentTime() {
// return DateTime.now().toString(FMT_TO_MILSEC);
// }
//
//// public static void addTloOrdinaryInfo(TloLog tlo, HttpServletRequest request, HttpServletResponse response) {
//// DateTime now = DateTime.now();
//// tlo.setRspTime(now.toString(FMT_TO_MILSEC));
//// tlo.setClientIp(LogUtils.clientIp(request));
////
//// int status = response.getStatus();
//// if (status == 404) {
//// tlo.setResultCode(ResultCode.SS_NOT_FOUND.getValue());
//// }
//// }
////
//// public static void addTloCustomInfo(TloLog tlo, HttpServletRequest request) {
//// tlo.setReqUri(request.getRequestURI());
//// tlo.setReqParam(getReqMultiMap(request).toString());
//// }
////
//// public static void addTloFailInfo(Object rspObj, HttpServletRequest request) {
//// if (rspObj instanceof Result) {
//// Result<?> result = (Result<?>) rspObj;
//// if (!result.isSuccess()) {
//// TloLog tlo = (TloLog) request.getAttribute(Const.KEY_LOG_OBJ);
//// String code = result.getCode();
//// tlo.setResultCode(code != null ? code : ResultCode.SE_UNKNOWN.getValue());
//// }
//// }
//// else if (rspObj instanceof RestResult) {
//// RestResult<?> result = (RestResult<?>) rspObj;
//// if (!result.isSuccess()) {
//// TloLog tlo = (TloLog) request.getAttribute(Const.KEY_LOG_OBJ);
//// ResultCode code = result.getCode();
//// tlo.setResultCode(code != null ? code.getValue() : ResultCode.SE_UNKNOWN.getValue());
//// }
//// }
//// }
////
//// public static void addTloExceptionInfo(TloLog tlo, Exception ex) {
//// if (ex == null)
//// return;
////
//// if (ex instanceof ServletException) {
//// Throwable e = ((ServletException) ex).getRootCause();
//// if (e instanceof SQLException || e instanceof DataAccessException) {
//// tlo.setResultCode(ResultCode.SE_DB.getValue());
//// }
//// else {
//// tlo.setResultCode(ResultCode.SE_INTERNAL.getValue());
//// }
//// }
//// else {
//// tlo.setResultCode(ResultCode.SE_INTERNAL.getValue());
//// }
//// }
// public static String clientIp(HttpServletRequest request) {
// String ip = request.getHeader("X-Forwarded-For");
// if (ip == null)
// ip = request.getRemoteAddr();
// return ip;
// }
//
//
// public static MultiValueMap<String,String> getReqMultiMap(HttpServletRequest request) {
// MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
// Enumeration<String> names = request.getParameterNames();
// while (names.hasMoreElements()) {
// String name = names.nextElement();
// if (Const.NOT_LOG_PARAMS.contains(name))
// continue;
// String[] value = request.getParameterValues(name);
// params.put(name, Arrays.asList(value));
// }
// return params;
// }
//
// public static boolean isResourceUri(String uri) {
// return uri.startsWith("/static/");
// }
//
// public static String getRequestBody(HttpServletRequest request, Method method) {
// Parameter[] parameters = method.getParameters();
//
// for (Parameter param : parameters) {
// if (param.getAnnotation(RequestBody.class) != null) {
// // CommonsRequestLoggingFilter.getMessagePayload()
// ContentCachingRequestWrapper wrapper =
// org.springframework.web.util.WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class);
// if (wrapper != null) {
// byte[] buf = wrapper.getContentAsByteArray();
// if (buf.length > 0) {
// int length = Math.min(buf.length, 10000);
// try {
// return new String(buf, 0, length, wrapper.getCharacterEncoding());
// }
// catch (UnsupportedEncodingException ex) {
// return "[unknown]";
// }
// }
// }
// }
// }
// return "";
// }
//
//}

View File

@@ -0,0 +1,116 @@
package kr.co.uplus.ez.common.utils;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.util.StringUtils;
public class RegexUtils {
/**
* 전화번호 정규식
* 이통사: 010, 011, 017, 018, 019
* 개인번호: 050
* 지역번호: 02, 031, 032, 033, 041, 042, 043, 044, 051, 052, 053, 054, 055, 061, 062, 063, 064
* 인터넷: 070, 080
*/
private final static String tel_regex = "^((0(1(0|1|6|7|8|9)))|(0(2|3(1|2|3)|4(1|2|3|4)|5(0|1|2|3|4|5)|6(1|2|3|4)|70|80))).*$";
public static String formatTelStr(String str) {
if (str == null) {
return null;
}
if (str.matches(tel_regex)) {
if (str.startsWith("02")) {
return str.replaceFirst("(\\d{2})([0-9*]+)(\\d{4})", "$1-$2-$3");
} else {
return str.replaceFirst("(\\d{3})([0-9*]+)(\\d{4})", "$1-$2-$3");
}
}
if (str.length() == 8) {
// 그 외 8자리 15447788등
return str.replaceFirst("(\\d{4})(\\d{4})", "$1-$2");
}
// 나머지 무시
return str;
}
public static void main(String[] args) {
String tels[] = {
"023456677"
, "0234316125"
, "0523376868"
, "05233776868"
, "01033445566"
, "0178532656"
, "15447788"
};
for (int t=0; t<tels.length; t++) {
System.out.println(formatTelStr(tels[t]));
}
}
/**
* url http or https
*/
public static boolean validHttp(String str) {
if (StringUtils.isEmpty(str)) {
return false;
}
return str.startsWith("http://") || str.startsWith("https://");
}
/**
* 날짜 정규식
*/
private static Pattern DATE_PATTERN = Pattern.compile(
"^((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)$"
+ "|^(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))$"
+ "|^(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))$"
+ "|^(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30))$");
public static boolean validDate(String str) {
return DATE_PATTERN.matcher(str).matches();
}
/**
* 숫자
*/
public static boolean validOnlyNum(String str) {
return str.matches("\\d+");
}
private static Pattern VALI_SPLIT = Pattern.compile("\\{{2}(.*?)\\}{2}", Pattern.DOTALL);
// private static Pattern VALI_SPLIT = Pattern.compile("\\{{2}(.*?)\\}{2}");
public static boolean cellValiableCheck(String valiableText) {
boolean rtn = true;
Matcher matcher = VALI_SPLIT.matcher(valiableText);
while (matcher.find()) {
if ("".equals(matcher.group(1)) || !Pattern.matches("^[가-힣ㄱ-ㅎㅏ-ㅣA-Za-z0-9_]*$", matcher.group(1))) {
return false;
}
if (matcher.group(1) == null) break;
}
return rtn;
}
public static List<String> getParamListByRegex(String str) {
List<String> rtnParam = new ArrayList<>();
Matcher matcher = VALI_SPLIT.matcher(str);
while (matcher.find()) {
if (!"".equals(matcher.group(1)) && Pattern.matches("^[가-힣ㄱ-ㅎㅏ-ㅣA-Za-z0-9_]*$", matcher.group(1))) {
rtnParam.add(matcher.group(1));
}
if (matcher.group(1) == null) break;
}
return rtnParam;
}
}

View File

@@ -0,0 +1,126 @@
package kr.co.uplus.ez.common.utils;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import kr.co.uplus.ez.common.auth.AuthUser;
public class SpringUtils {
public static HttpServletRequest getCurrentRequest() {
ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
return sra.getRequest();
}
public static HttpServletResponse getCurrentResponse() {
ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
return sra.getResponse();
}
public static String getCurrentRequestIp() {
HttpServletRequest req = getCurrentRequest();
String ip = req.getHeader("X-FORWARDED-FOR");
if (ip == null) {
ip = req.getRemoteAddr();
}
return ip;
}
public static AuthUser getCurrentUser() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth == null || "anonymousUser".equals(auth.getPrincipal().toString()))
return null;
return (AuthUser) auth.getPrincipal();
}
public static String getCurrentUserName() {
UserDetails user = getCurrentUser();
return user == null ? null : user.getUsername();
}
public static String getCurrentUserRole() {
UserDetails user = getCurrentUser();
if (user == null) {
throw new RuntimeException("USER_NOT_FOUND");
}
String userId = user.getUsername();
Collection<? extends GrantedAuthority> roles = user.getAuthorities();
if (roles.size() == 0) {
throw new RuntimeException("ROLE_NOT_FOUND:" + userId);
}
else if (roles.size() > 1) {
throw new RuntimeException("MANY_ROLES_FOUND:" + userId);
}
return roles.toArray()[0].toString();
}
public static boolean hasRole(String... roles) {
UserDetails user = getCurrentUser();
if (user == null)
return false;
List<String> aroles = Arrays.asList(roles);
for (GrantedAuthority auth : user.getAuthorities()) {
if (aroles.contains(auth.toString()))
return true;
}
return false;
}
private static final Class[] MAPPING_ANNOTATIONS = {RequestMapping.class, GetMapping.class, PostMapping.class, PutMapping.class, DeleteMapping.class, PatchMapping.class};
public static Annotation findMappingAnnotation(AnnotatedElement element) {
for (Class<? extends Annotation> clazz : MAPPING_ANNOTATIONS) {
Annotation anno = element.getAnnotation(clazz);
if (anno != null)
return anno;
}
if (element instanceof Method) {
Method method = (Method) element;
return AnnotationUtils.findAnnotation(method, RequestMapping.class);
}
else {
Class<?> clazz = (Class<?>) element;
return AnnotationUtils.findAnnotation(clazz, RequestMapping.class);
}
}
public static String[] getMappingUrl(AnnotatedElement element) {
Annotation anno = findMappingAnnotation(element);
return (String[]) AnnotationUtils.getValue(anno);
}
public static String getWebTemplateVersion() {
Package pack = SpringUtils.class.getPackage();
return String.format("%s-%s.jar",
(pack.getImplementationTitle() == null ? "lgu-rcs-web-template" : pack.getImplementationTitle()),
(pack.getImplementationVersion() == null ? "not-found" : pack.getImplementationVersion()));
}
}

View File

@@ -0,0 +1,102 @@
package kr.co.uplus.ez.common.utils;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonObject;
public class TextUtils {
public static final List<String> RCS_PRODUCTS = Arrays.asList("sms", "lms", "mms", "tmplt");
public static final List<String> FALLBACK_PRODUCTS = Arrays.asList("fbsms", "fblms");
public static final String GW_SUCCESS_CODE = "10000";
/**
* 임의의 숫자 반환
* @param min 최소 숫자 (inclusive)
* @param max 최대 숫자 (inclusive)
*/
public static int randNum(int min, int max) {
Random r = new Random();
return r.nextInt((max - min) + 1) + min;
}
/**
* digit=1이면 ["1" ... "9"] 반환, digit=2면 ["10" ... "99"] 반환
* @param digit 자리 수
* @return 해당 자리 수의 임의의 숫자로된 문자열
*/
public static String randNumStr(int digit) {
int min = (int) Math.pow(10, digit-1);
int max = (int) Math.pow(10, digit) - 1;
return String.valueOf(randNum(min, max));
}
public static String[] str2array(String str, String delimiters) {
return org.springframework.util.StringUtils.tokenizeToStringArray(str, delimiters);
}
public static String array2str(String[] strs, String delimiter) {
return org.springframework.util.StringUtils.arrayToDelimitedString(strs, delimiter);
}
/**
* 대상 템플릿 문자열에서 ${key} 부분을 찾아서 설정한 값으로 치환한다.
* 예) "Hello ${myKey1}" 문자열에 vars.put("myKey1", "foot") 적용하면 "Hello foo" 반환.
* @param tpl 대상 템플릿 문자열
* @param vars 치환할 문자열 설정 객체
* @return 치환된 문자열
*/
public static String template(String tpl, Map<String, String> vars) {
for (Map.Entry<String, String> entry : vars.entrySet()) {
tpl = tpl.replace("${" + entry.getKey() + "}", entry.getValue());
}
return tpl;
}
public static boolean isNotNullJsonVal(JsonObject obj, String key) {
return obj.has(key) && !obj.get(key).isJsonNull();
}
public static boolean isNullJsonVal(JsonObject obj, String key) {
return !isNotNullJsonVal(obj, key);
}
public static boolean isGwSuccess(String code) {
if (StringUtils.isEmpty(code)) return false;
return GW_SUCCESS_CODE.equals(code);
}
public static boolean isGwFail(String code) {
return !isGwSuccess(code);
}
public static boolean isRcsSuccess(String prod, String code) {
return isRcsProd(prod) && isGwSuccess(code);
}
public static boolean isRcsFail(String prod, String code) {
return isRcsProd(prod) && isGwFail(code);
}
public static boolean isFallbackSuccess(String prod, String code) {
return isFallbackProd(prod) && isGwSuccess(code);
}
public static boolean isFallbackFail(String prod, String code) {
return isFallbackProd(prod) && isGwFail(code);
}
public static boolean isRcsProd (String prod) {
return StringUtils.isEmpty(prod) || RCS_PRODUCTS.contains(prod);
}
public static boolean isFallbackProd (String prod) {
if (StringUtils.isEmpty(prod)) return false;
return FALLBACK_PRODUCTS.contains(prod);
}
}

View File

@@ -0,0 +1,104 @@
package kr.co.uplus.ez.common.utils;
import java.io.IOException;
import java.util.Arrays;
import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.util.AntPathMatcher;
import kr.co.uplus.ez.common.consts.Const;
public class WebUtils {
public static boolean isAjaxRequest(HttpServletRequest request) {
return "XMLHttpRequest".equals(request.getHeader("X-Requested-With"));
}
public static boolean isJwtTokenExist(HttpServletRequest request) {
Boolean api = (Boolean) request.getAttribute(Const.KEY_TOKEN_EXIST);
return api != null && api == Boolean.TRUE;
}
public static boolean isExpiredSession(HttpServletRequest request) {
return request.getRequestedSessionId() != null && !request.isRequestedSessionIdValid();
}
public static void responseJson(HttpServletResponse response, int status) {
response.setStatus(status);
response.setContentType("application/json;charset=UTF-8");
try {
response.getWriter().write("");
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void printRequestHeader(HttpServletRequest request) {
Enumeration<String> names = request.getHeaderNames();
System.out.println("-------------- request header --------------");
while (names.hasMoreElements()) {
String name = names.nextElement();
System.out.println(name + " = " + request.getHeader(name));
}
}
public static void printRequestParameters(HttpServletRequest request) {
Enumeration<String> names = request.getParameterNames();
System.out.println("-------------- request parameter --------------");
while (names.hasMoreElements()) {
String name = names.nextElement();
System.out.println(name + " = " + request.getParameter(name));
}
}
public static void printSessionAttributes(HttpSession session) {
Enumeration<String> names = session.getAttributeNames();
System.out.println("-------------- request attribute --------------");
while (names.hasMoreElements()) {
String name = names.nextElement();
System.out.println(name + " = " + session.getAttribute(name));
}
}
public static boolean isMatchedUri(HttpServletRequest request, String... uris) {
String path = request.getRequestURI();
return Arrays.stream(uris).anyMatch(s -> path.equals(s));
}
/**
* 현재 요청 URL(request.getRequestURI())이 urlPattern으로 지정된 패턴과 일치하면 true 반환.
* @param uriPatterns ant pattern을 사용한 url. (ex. /sample/api/**)
*/
public static boolean isMatchedUriPattern(HttpServletRequest request, String... uriPatterns) {
// String ctxroot = request.getContextPath();
// if ("/".equals(ctxroot))
// ctxroot = "";
//
// String path = request.getRequestURI().replaceFirst(ctxroot, "");
// AntPathMatcher antMatcher = new AntPathMatcher();
// boolean match = false;
//
// for (String pattern : uriPatterns) {
// match = antMatcher.match(pattern, path);
// if (match)
// break;
// }
//
// return match;
String path = request.getRequestURI();
AntPathMatcher antMatcher = new AntPathMatcher();
return Arrays.stream(uriPatterns).anyMatch(s -> antMatcher.match(s, path));
}
public static boolean isResourceRequest(HttpServletRequest request) {
String path = request.getRequestURI();
return path.startsWith("/static/");
}
}

View File

@@ -0,0 +1,10 @@
package kr.co.uplus.ez.common.xss;
import lombok.Data;
@Data
public class EscapeCharacter {
private String target;
private String trans;
private String unescapeYn;
}

View File

@@ -0,0 +1,39 @@
package kr.co.uplus.ez.common.xss;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertySourceFactory;
public class XssPreventFactory implements PropertySourceFactory {
@Override
public PropertySource<?> createPropertySource(String name, EncodedResource encodedResource) throws IOException {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(encodedResource.getResource());
Properties properties = factory.getObject();
return new PropertiesPropertySource(encodedResource.getResource().getFilename(), properties);
}
@SuppressWarnings("unused")
private Properties loadYamlIntoProperties(EncodedResource resource) throws FileNotFoundException {
try {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(resource.getResource());
factory.afterPropertiesSet();
return factory.getObject();
} catch (IllegalStateException e) {
// for ignoreResourceNotFound
Throwable cause = e.getCause();
if (cause instanceof FileNotFoundException)
throw (FileNotFoundException) e.getCause();
throw e;
}
}
}

View File

@@ -0,0 +1,176 @@
package kr.co.uplus.ez.common.xss;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import kr.co.uplus.ez.common.data.Const;
import lombok.Data;
@Data
@Configuration
@ConfigurationProperties(prefix = "xssconfig")
@PropertySource(value = "classpath:xss-prevent.yml", factory = XssPreventFactory.class)
public class XssPreventer {
private static final Logger log = LoggerFactory.getLogger(XssPreventer.class);
public static String ESCAPE_TYPE_ALLOW = "allow";
public static String ESCAPE_TYPE_EXCEPT = "except";
public static String ESCAPE_TYPE; // allow, except
public static List<String> EXCLUDE_URLS;
public static List<EscapeCharacter> ESCAPE_CHARACTERS;
public static List<String> ALLOW_ELEMENTS;
public static List<EscapeCharacter> EXCEPT_ELEMENTS;
@SuppressWarnings("static-access")
public void setEscapeType(String escapeType) {
this.ESCAPE_TYPE = escapeType;
}
@SuppressWarnings("static-access")
public void setExcludeUrls(List<String> excludeUrls) {
this.EXCLUDE_URLS = excludeUrls;
}
@SuppressWarnings("static-access")
public void setEscapeCharacters(List<EscapeCharacter> escapeCharacters) {
this.ESCAPE_CHARACTERS = escapeCharacters;
}
@SuppressWarnings("static-access")
public void setAllowElements(String allowElements) {
if (StringUtils.isNotBlank(allowElements)) {
this.ALLOW_ELEMENTS = Arrays.asList(StringUtils.split(allowElements, ","));
}
}
@SuppressWarnings("static-access")
public void setExceptElements(List<EscapeCharacter> exceptElements) {
this.EXCEPT_ELEMENTS = exceptElements;
}
public static String escape(String value) {
// allow - escape-characters 를 모두 적용 후 allow-elements 만 <, > 치환
if (StringUtils.equals(ESCAPE_TYPE, ESCAPE_TYPE_ALLOW)) {
if (!CollectionUtils.isEmpty(ESCAPE_CHARACTERS)) {
for (EscapeCharacter e : ESCAPE_CHARACTERS) {
value = value.replaceAll(StringUtils.trim(e.getTarget()), StringUtils.trim(e.getTrans()));
}
// 허용태그 치환
value = replaceAllowElem(value);
}
// except - escape-characters 를 적용하지 않고 except-elements 에 해당되면 공백문자로 치환
} else if (StringUtils.equals(ESCAPE_TYPE, ESCAPE_TYPE_EXCEPT)) {
value = replaceExceptElem(value);
}
return value;
}
public static String replaceExceptElem(String value) {
if (StringUtils.isNotBlank(value)) {
Pattern p;
Matcher m;
String targetString = "";
String matchString = "";
String replaceString = "";
for (EscapeCharacter e : EXCEPT_ELEMENTS) {
targetString = e.getTarget();
replaceString = e.getTrans();
p = Pattern.compile(targetString);
m = p.matcher(value);
while (m.find()) {
matchString = m.group(0);
value = value.replace(matchString, replaceString);
}
}
}
return value;
}
public static String replaceAllowElem(String value) {
if (StringUtils.isNotBlank(value)) {
Pattern p;
Matcher m;
String matchString = "";
String replaceString = "";
// 영문, 숫자를 제외한 태그 허용
/*
* p = Pattern.compile("&lt;[\\W]*&gt;"); m = p.matcher(value); while(m.find())
* { matchString = m.group(0); replaceString = matchString.replaceFirst("&lt;",
* "<"); value = value.replace(matchString, replaceString);
*
* matchString = replaceString; replaceString = replaceLast(matchString, "&gt;",
* ">"); value = value.replace(matchString, replaceString); }
*/
// 허용 태그에 등록된있으면 허용
for (String s : ALLOW_ELEMENTS) {
s = StringUtils.trim(s);
p = Pattern.compile("&lt;\\/?(?i)" + s + "(&gt;|\\s+((?!&gt;).)*?&gt;)");
m = p.matcher(value);
while (m.find()) {
matchString = m.group(0);
replaceString = matchString.replaceFirst("&lt;", "<");
value = value.replace(matchString, replaceString);
matchString = replaceString;
replaceString = replaceLast(matchString, "&gt;", ">");
value = value.replace(matchString, replaceString);
}
}
}
return value;
}
public static String unescape(String value) {
if (!CollectionUtils.isEmpty(ESCAPE_CHARACTERS)) {
for (EscapeCharacter e : ESCAPE_CHARACTERS) {
if (StringUtils.isNotBlank(e.getTrans()) && StringUtils.equals(Const.getCommYes(), e.getUnescapeYn())) {
value = value.replaceAll(e.getTrans(), e.getTarget());
}
}
}
return value;
}
@SuppressWarnings("unchecked")
public static Map<String, Object> unescapeMap(Map<String, Object> params) {
Map<String, Object> rtn = new HashMap<String, Object>();
try {
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
String jsonString = gson.toJson(params);
String paramStr = unescape(jsonString);
rtn = gson.fromJson(paramStr, HashMap.class);
} catch (Exception e) {
log.error("XssPreventer.unescapeMap Error : {}, params : {}", e, params);
rtn = new HashMap<String, Object>(params);
}
return rtn;
}
private static String replaceLast(String string, String toReplace, String replacement) {
String s = string.replaceFirst("(?s)(.*)" + toReplace, "$1" + replacement);
return s;
}
}

View File

@@ -0,0 +1,24 @@
package kr.co.uplus.ez.config;
import java.util.Arrays;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableCaching
public class CommonCacheConfig {
@Bean
public CacheManager cacheManager() {
SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
simpleCacheManager.setCaches(Arrays.asList(new ConcurrentMapCache("sample")));
return simpleCacheManager;
}
}

View File

@@ -0,0 +1,48 @@
package kr.co.uplus.ez.config;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class JasyptConfig {
// EncKeyForUplus
@Value("${app.props.encKey:RW5jS2V5Rm9yVXBsdXM=}")
String encKey;
@Bean("jasyptStringEncryptor")
public StringEncryptor stringEncryptor() {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
config.setPassword(encKey);
config.setAlgorithm("PBEWithMD5AndDES");
config.setKeyObtentionIterations("1000");
config.setPoolSize("1");
config.setProviderName("SunJCE");
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
config.setStringOutputType("base64");
encryptor.setConfig(config);
return encryptor;
}
public static void main(String[] args) {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
config.setPassword("RW5jS2V5Rm9yVXBsdXM=");
config.setAlgorithm("PBEWithMD5AndDES");
config.setKeyObtentionIterations("1000");
config.setPoolSize("1");
config.setProviderName("SunJCE");
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
config.setStringOutputType("base64");
encryptor.setConfig(config);
// 테스트
// System.out.println(encryptor.encrypt("sample"));
}
}

View File

@@ -0,0 +1,48 @@
package kr.co.uplus.ez.config;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
import kr.co.uplus.ez.common.consts.Const;
import kr.co.uplus.ez.common.utils.WebUtils;
/**
* Spring Security를 사용하면 폼 로그인 성공/실패 시 302 Redirect가 발생한다.
* Rest API 호출 시는 인증 실패 시 401 응답만 주면된다.
* 폼 로그인과 API 로그인을 같이 사용하기 위해 위의 2가지 역할을 수행한다.
*/
public class MixedAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint {
private String[] apiUrls;
public MixedAuthenticationEntryPoint(String loginPage, String... apiUrls) {
super(loginPage);
this.apiUrls = apiUrls;
}
/**
* 인증에 실패하거나 권한 없이 접근하여 login 페이지로 redrect 해야 할 때 호출된다.
*/
@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException authException) throws IOException, ServletException {
// AJAX 요청이고 세션 만료 상태면 418 (사용자정의) 응답을 한다.
if (WebUtils.isAjaxRequest(request) && WebUtils.isExpiredSession(request)) {
response.sendError(Const.SESSION_EXPIRED, "SESSION_TIMED_OUT");
}
// RESTful API 요청이면 401 응답을 한다.
else if (WebUtils.isMatchedUriPattern(request, apiUrls)) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
}
// 일반 페이지 요청이면 302 응답을 한다.
else {
super.commence(request, response, authException);
}
}
}

Some files were not shown because too many files have changed in this diff Show More