From bd922d9788b2fea3cc2f7d67ddf59714c89053b5 Mon Sep 17 00:00:00 2001 From: LEEYONGJAE Date: Thu, 17 Oct 2024 13:18:22 +0900 Subject: [PATCH] =?UTF-8?q?Q.CAST=20=EC=9E=90=EB=8F=99=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EB=B3=B5=ED=98=B8=ED=99=94=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=9C=A0=EC=A0=80=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20api=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qcast/biz/login/LoginController.java | 38 +++++++++++++++++++ .../resources/mappers/login/loginMapper.xml | 20 ++++++++-- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/interplug/qcast/biz/login/LoginController.java b/src/main/java/com/interplug/qcast/biz/login/LoginController.java index de5cd633..916f0a3c 100644 --- a/src/main/java/com/interplug/qcast/biz/login/LoginController.java +++ b/src/main/java/com/interplug/qcast/biz/login/LoginController.java @@ -116,4 +116,42 @@ public class LoginController { return loginEncryptId; } + @Operation(description = "자동 로그인에 사용하는 아이디를 복호화한다.") + @PostMapping("/v1.0/user/login/autoLoginDecryptData") + public String getAutoLoginDecryptData(@RequestBody LoginUser loginUser) throws Exception { + + String loginDecryptId = ""; + + if ("".equals(loginUser.getLoginId()) || loginUser.getLoginId() == null) { + throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + message.getMessage("common.message.required.data", "User Id")); + } + + try { + // [0]. AES 암호화 키 : 날짜(YYYYMMDD) + autoLoginAesKey + LocalDate today = LocalDate.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); + String formattedDate = today.format(formatter); + String decryptKey = formattedDate + autoLoginAesKey; + + // [1]. 복호화 진행 + byte[] keyData = loginPasswordAesKey.getBytes(); + SecretKey secureKey = new SecretKeySpec(keyData, "AES"); + Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding"); + c.init(Cipher.DECRYPT_MODE, secureKey, + new IvParameterSpec(decryptKey.substring(0, 16).getBytes("UTF-8"))); + + byte[] byteStr = Base64.getDecoder().decode(loginUser.getLoginId().getBytes()); + + // [2]. 복호화 값 셋팅 + loginDecryptId = new String(c.doFinal(byteStr), "UTF-8"); + + } catch (Exception e) { + throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, + message.getMessage("common.message.error")); + } + + return loginDecryptId; + } + } diff --git a/src/main/resources/mappers/login/loginMapper.xml b/src/main/resources/mappers/login/loginMapper.xml index aec2bb28..9e851769 100644 --- a/src/main/resources/mappers/login/loginMapper.xml +++ b/src/main/resources/mappers/login/loginMapper.xml @@ -14,9 +14,23 @@ \ No newline at end of file