Skip to content

Commit c150c3e

Browse files
Merge pull request #37 from Strato-YangSungHun/main
Oss Management encrypt/decrypt debugging
2 parents 0be93a1 + 50cf1b9 commit c150c3e

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/main/java/kr/co/mcmp/oss/dto/OssDto.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static Oss toEntity(OssDto ossDto, OssTypeDto ossTypeDto) {
6161
}
6262

6363
// 패스워드 Encript set
64-
public static OssDto withModifiedEncriptPassword(OssDto ossDto, String password) {
64+
public static OssDto setEncryptPassword(OssDto ossDto, String password) {
6565
return OssDto.builder()
6666
.ossIdx(ossDto.getOssIdx())
6767
.ossTypeIdx(ossDto.getOssTypeIdx())
@@ -73,14 +73,14 @@ public static OssDto withModifiedEncriptPassword(OssDto ossDto, String password)
7373
.build();
7474
}
7575
// 패스워드 decrypt set
76-
public static OssDto withDetailDecryptPassword(Oss oss, String password) {
76+
public static OssDto setDecryptPassword(OssDto ossDto, String password) {
7777
return OssDto.builder()
78-
.ossIdx(oss.getOssIdx())
79-
.ossTypeIdx(oss.getOssType().getOssTypeIdx())
80-
.ossName(oss.getOssName())
81-
.ossDesc(oss.getOssDesc())
82-
.ossUrl(oss.getOssUrl())
83-
.ossUsername(oss.getOssUsername())
78+
.ossIdx(ossDto.getOssIdx())
79+
.ossTypeIdx(ossDto.getOssTypeIdx())
80+
.ossName(ossDto.getOssName())
81+
.ossDesc(ossDto.getOssDesc())
82+
.ossUrl(ossDto.getOssUrl())
83+
.ossUsername(ossDto.getOssUsername())
8484
.ossPassword(password)
8585
.build();
8686
} // Duplicate Object set

src/main/java/kr/co/mcmp/oss/service/OssServiceImpl.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public List<OssDto> getAllOssList() {
4444

4545
if ( !CollectionUtils.isEmpty(ossList) ) {
4646
ossList = ossList.stream()
47-
.map(ossDto -> OssDto.withModifiedEncriptPassword(ossDto, encodingBase64String(decryptAesString(ossDto.getOssPassword()))))
47+
.map(ossDto -> OssDto.setDecryptPassword(ossDto, decryptAesString(ossDto.getOssPassword())))
4848
.collect(Collectors.toList());
4949
}
5050

@@ -77,7 +77,7 @@ public List<OssDto> getOssList(String ossTypeName) {
7777
if ( !CollectionUtils.isEmpty(ossList) ) {
7878
ossList = ossList
7979
.stream()
80-
.map(ossDto -> OssDto.withModifiedEncriptPassword(ossDto, encodingBase64String(decryptAesString(ossDto.getOssPassword()))))
80+
.map(ossDto -> OssDto.setDecryptPassword(ossDto, decryptAesString(ossDto.getOssPassword())))
8181
.collect(Collectors.toList());
8282
}
8383

@@ -93,7 +93,7 @@ public List<OssDto> getOssList(String ossTypeName) {
9393
@Override
9494
public Long registOss(OssDto ossDto) {
9595
OssTypeDto ossTypeDto = OssTypeDto.from(ossTypeRepository.findByOssTypeIdx(ossDto.getOssTypeIdx()));
96-
ossDto = ossDto.withModifiedEncriptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
96+
ossDto = ossDto.setEncryptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
9797
ossDto = OssDto.from(ossRepository.save(OssDto.toEntity(ossDto, ossTypeDto)));
9898
return ossDto.getOssIdx();
9999
}
@@ -107,7 +107,7 @@ public Long registOss(OssDto ossDto) {
107107
public Long updateOss(OssDto ossDto) {
108108
OssTypeDto ossTypeDto = OssTypeDto.from(ossTypeRepository.findByOssTypeIdx(ossDto.getOssTypeIdx()));
109109

110-
ossDto = ossDto.withModifiedEncriptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
110+
ossDto = ossDto.setEncryptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
111111
ossRepository.save(OssDto.toEntity(ossDto, ossTypeDto));
112112
return ossDto.getOssIdx();
113113
}
@@ -150,7 +150,7 @@ public Boolean checkConnection(OssDto ossDto) {
150150
}
151151

152152
// Front에서 Base64Encoding한 데이터를 복호화하여 AES256 암호화 함.
153-
ossDto.withModifiedEncriptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
153+
ossDto.setEncryptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
154154
return nexusService.checkNexusConnection(ossDto);
155155

156156
default:
@@ -173,7 +173,8 @@ public Boolean checkConnection(OssDto ossDto) {
173173
*/
174174
public OssDto detailOss(Long ossIdx) {
175175
Oss oss = ossRepository.findByOssIdx(ossIdx);
176-
return OssDto.withDetailDecryptPassword(oss, decryptAesString(oss.getOssPassword()));
176+
OssDto ossDto = OssDto.from(oss);
177+
return OssDto.setDecryptPassword(ossDto, decryptAesString(oss.getOssPassword()));
177178
}
178179

179180
public OssDto detailOssByOssName(String ossName) {
@@ -234,7 +235,7 @@ public String encryptBase64String(String str) {
234235
*/
235236
public String encryptAesString(String str) {
236237
if ( StringUtils.isNotBlank(str) ) {
237-
return AES256Utils.encrypt(Base64Utils.base64Decoding(str));
238+
return AES256Utils.encrypt(str);
238239
}
239240
else {
240241
return null;

0 commit comments

Comments
 (0)