자동 로그인 관련 추가
This commit is contained in:
parent
3ea7807e62
commit
5ed22e1bc1
@ -154,7 +154,8 @@ public class BoardService {
|
|||||||
response.setContentType("application/octet-stream");
|
response.setContentType("application/octet-stream");
|
||||||
response.setHeader("Content-Disposition", "attachment;");
|
response.setHeader("Content-Disposition", "attachment;");
|
||||||
|
|
||||||
InputStream inputStream = new ByteArrayInputStream(strResponse.getBytes());
|
InputStream inputStream =
|
||||||
|
new ByteArrayInputStream(strResponse.getBytes(StandardCharsets.UTF_8));
|
||||||
StreamUtils.copy(inputStream, response.getOutputStream());
|
StreamUtils.copy(inputStream, response.getOutputStream());
|
||||||
|
|
||||||
response.flushBuffer();
|
response.flushBuffer();
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
package com.interplug.qcast.biz.login;
|
package com.interplug.qcast.biz.login;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Base64;
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.SecretKey;
|
||||||
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.PatchMapping;
|
import org.springframework.web.bind.annotation.PatchMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -12,6 +21,9 @@ import com.interplug.qcast.biz.login.dto.LoginUser;
|
|||||||
import com.interplug.qcast.biz.login.dto.UserLoginResponse;
|
import com.interplug.qcast.biz.login.dto.UserLoginResponse;
|
||||||
import com.interplug.qcast.biz.login.dto.UserPassword;
|
import com.interplug.qcast.biz.login.dto.UserPassword;
|
||||||
import com.interplug.qcast.biz.login.dto.UserResponse;
|
import com.interplug.qcast.biz.login.dto.UserResponse;
|
||||||
|
import com.interplug.qcast.config.Exception.ErrorCode;
|
||||||
|
import com.interplug.qcast.config.Exception.QcastException;
|
||||||
|
import com.interplug.qcast.config.message.Messages;
|
||||||
import com.interplug.qcast.util.DefaultResponse;
|
import com.interplug.qcast.util.DefaultResponse;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -25,6 +37,16 @@ public class LoginController {
|
|||||||
// @Autowired private LoginService loginService;
|
// @Autowired private LoginService loginService;
|
||||||
private final LoginService loginService;
|
private final LoginService loginService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
Messages message;
|
||||||
|
|
||||||
|
@Value("${qsp.aes256.key}")
|
||||||
|
String loginPasswordAesKey;
|
||||||
|
|
||||||
|
@Value("${qsp.auto.login.aes256.key}")
|
||||||
|
String autoLoginAesKey;
|
||||||
|
|
||||||
|
|
||||||
@Operation(description = "Q.CAST III에 로그인하여 사용자 정보를 획득한다.")
|
@Operation(description = "Q.CAST III에 로그인하여 사용자 정보를 획득한다.")
|
||||||
@PostMapping("/v1.0/login")
|
@PostMapping("/v1.0/login")
|
||||||
@ResponseStatus(HttpStatus.CREATED)
|
@ResponseStatus(HttpStatus.CREATED)
|
||||||
@ -56,4 +78,42 @@ public class LoginController {
|
|||||||
public DefaultResponse changePassword(@RequestBody UserPassword userPassword) throws Exception {
|
public DefaultResponse changePassword(@RequestBody UserPassword userPassword) throws Exception {
|
||||||
return loginService.changePassword(userPassword);
|
return loginService.changePassword(userPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(description = "자동 로그인에 사용하는 아이디를 암호화한다.")
|
||||||
|
@PostMapping("/v1.0/user/login/autoLoginEncryptData")
|
||||||
|
public String getAutoLoginEncryptData(@RequestBody LoginUser loginUser) throws Exception {
|
||||||
|
|
||||||
|
String loginEncryptId = "";
|
||||||
|
|
||||||
|
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 encryptKey = formattedDate + autoLoginAesKey;
|
||||||
|
|
||||||
|
// [1]. 암호화 진행
|
||||||
|
byte[] keyData = loginPasswordAesKey.getBytes();
|
||||||
|
SecretKey secureKey = new SecretKeySpec(keyData, "AES");
|
||||||
|
Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||||
|
c.init(Cipher.ENCRYPT_MODE, secureKey,
|
||||||
|
new IvParameterSpec(encryptKey.substring(0, 16).getBytes()));
|
||||||
|
byte[] encrypted = c.doFinal(loginUser.getLoginId().getBytes("UTF-8"));
|
||||||
|
|
||||||
|
// [2]. 암호화 값 셋팅
|
||||||
|
loginEncryptId = new String(Base64.getEncoder().encode(encrypted));;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR,
|
||||||
|
message.getMessage("common.message.error"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return loginEncryptId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,5 +23,6 @@ public class UserResponse {
|
|||||||
private String email; // E-Mail
|
private String email; // E-Mail
|
||||||
private String pwdInitYn; // Password Init Yn
|
private String pwdInitYn; // Password Init Yn
|
||||||
private String storeLvl; // Store Level
|
private String storeLvl; // Store Level
|
||||||
|
private String groupId; // groupId
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,8 @@ spring:
|
|||||||
qsp:
|
qsp:
|
||||||
url: http://172.23.4.129:8120
|
url: http://172.23.4.129:8120
|
||||||
master-store-batch-url: /api/master/storeAdditionalInfo
|
master-store-batch-url: /api/master/storeAdditionalInfo
|
||||||
|
aes256.key: jpqcellQ123456!!
|
||||||
|
auto.login.aes256.key: _autoL!!
|
||||||
#File
|
#File
|
||||||
file:
|
file:
|
||||||
root.path: C:\\
|
root.path: C:\\
|
||||||
|
|||||||
@ -27,6 +27,8 @@ spring:
|
|||||||
qsp:
|
qsp:
|
||||||
url: http://localhost:8120
|
url: http://localhost:8120
|
||||||
master-store-batch-url: /api/master/storeAdditionalInfo
|
master-store-batch-url: /api/master/storeAdditionalInfo
|
||||||
|
aes256.key: jpqcellQ123456!!
|
||||||
|
auto.login.aes256.key: _autoL!!
|
||||||
|
|
||||||
#File
|
#File
|
||||||
file:
|
file:
|
||||||
|
|||||||
@ -27,6 +27,8 @@ spring:
|
|||||||
qsp:
|
qsp:
|
||||||
url: http://jp.qsalesplatform.com
|
url: http://jp.qsalesplatform.com
|
||||||
master-store-batch-url: /api/master/storeAdditionalInfo
|
master-store-batch-url: /api/master/storeAdditionalInfo
|
||||||
|
aes256.key: jpqcellQ123456!!
|
||||||
|
auto.login.aes256.key: _autoL!!
|
||||||
|
|
||||||
#File
|
#File
|
||||||
file:
|
file:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user