Skip to content

Commit

Permalink
Oss Management encrypt/decrypt debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Strato-YangSungHun committed Sep 19, 2024
1 parent 0797edb commit be57dec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/main/java/kr/co/mcmp/oss/dto/OssDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static Oss toEntity(OssDto ossDto, OssTypeDto ossTypeDto) {
}

// 패스워드 Encript set
public static OssDto withModifiedEncriptPassword(OssDto ossDto, String password) {
public static OssDto setEncryptPassword(OssDto ossDto, String password) {
return OssDto.builder()
.ossIdx(ossDto.getOssIdx())
.ossTypeIdx(ossDto.getOssTypeIdx())
Expand All @@ -68,14 +68,14 @@ public static OssDto withModifiedEncriptPassword(OssDto ossDto, String password)
.build();
}
// 패스워드 decrypt set
public static OssDto withDetailDecryptPassword(Oss oss, String password) {
public static OssDto setDecryptPassword(OssDto ossDto, String password) {
return OssDto.builder()
.ossIdx(oss.getOssIdx())
.ossTypeIdx(oss.getOssType().getOssTypeIdx())
.ossName(oss.getOssName())
.ossDesc(oss.getOssDesc())
.ossUrl(oss.getOssUrl())
.ossUsername(oss.getOssUsername())
.ossIdx(ossDto.getOssIdx())
.ossTypeIdx(ossDto.getOssTypeIdx())
.ossName(ossDto.getOssName())
.ossDesc(ossDto.getOssDesc())
.ossUrl(ossDto.getOssUrl())
.ossUsername(ossDto.getOssUsername())
.ossPassword(password)
.build();
} // Duplicate Object set
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/kr/co/mcmp/oss/service/OssServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public List<OssDto> getAllOssList() {

if ( !CollectionUtils.isEmpty(ossList) ) {
ossList = ossList.stream()
.map(ossDto -> OssDto.withModifiedEncriptPassword(ossDto, encodingBase64String(decryptAesString(ossDto.getOssPassword()))))
.map(ossDto -> OssDto.setDecryptPassword(ossDto, decryptAesString(ossDto.getOssPassword())))
.collect(Collectors.toList());
}

Expand Down Expand Up @@ -98,7 +98,7 @@ public List<OssDto> getOssList(String ossTypeName) {
if ( !CollectionUtils.isEmpty(ossList) ) {
ossList = ossList
.stream()
.map(ossDto -> OssDto.withModifiedEncriptPassword(ossDto, encodingBase64String(decryptAesString(ossDto.getOssPassword()))))
.map(ossDto -> OssDto.setEncryptPassword(ossDto, decryptAesString(ossDto.getOssPassword())))
.collect(Collectors.toList());
}

Expand All @@ -122,7 +122,7 @@ public Long registOss(OssDto ossDto) {
OssType ossTypeEntity = ossTypeRepository.findByOssTypeIdx(ossDto.getOssTypeIdx());
OssTypeDto ossTypeDto = OssTypeDto.from(ossTypeEntity);

OssDto encriptOssDto = ossDto.withModifiedEncriptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
OssDto encriptOssDto = ossDto.setEncryptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));

Oss ossEntity = OssDto.toEntity(encriptOssDto, ossTypeDto);
ossEntity = ossRepository.save(ossEntity);
Expand All @@ -148,7 +148,7 @@ public Boolean updateOss(OssDto ossDto) {
OssType ossTypeEntity = ossTypeRepository.findByOssTypeIdx(ossDto.getOssTypeIdx());
OssTypeDto ossTypeDto = OssTypeDto.from(ossTypeEntity);

OssDto encriptOssDto = ossDto.withModifiedEncriptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
OssDto encriptOssDto = ossDto.setEncryptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));

managedJenkinsCredential(encriptOssDto, "update");

Expand Down Expand Up @@ -212,7 +212,7 @@ public Boolean checkConnection(OssDto ossDto) {
return false;
}
// Front에서 Base64Encoding한 데이터를 복호화하여 AES256 암호화 함.
ossDto = ossDto.withModifiedEncriptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
ossDto = ossDto.setEncryptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
return jenkinsService.isJenkinsConnect(ossDto);

case "TUMBLEBUG" :
Expand All @@ -225,7 +225,7 @@ public Boolean checkConnection(OssDto ossDto) {

try {
// Front에서 Base64Encoding한 데이터를 복호화하여 AES256 암호화 함.
ossDto = ossDto.withModifiedEncriptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
ossDto = ossDto.setEncryptPassword(ossDto, encryptAesString(ossDto.getOssPassword()));
List<TumblebugDto> list = tumblebugService.getNamespaceList(ossDto);

if(list.size() >= 0) return true;
Expand Down Expand Up @@ -277,7 +277,8 @@ public Boolean checkConnection(OssDto ossDto) {
public OssDto detailOss(Long ossIdx) {
try {
Oss ossEntity = ossRepository.findByOssIdx(ossIdx);
return OssDto.withDetailDecryptPassword(ossEntity, encodingBase64String(decryptAesString(ossEntity.getOssPassword())));
OssDto ossDto = OssDto.from(ossEntity);
return OssDto.setDecryptPassword(ossDto, encodingBase64String(decryptAesString(ossEntity.getOssPassword())));
} catch (Exception e) {
log.error(e.getMessage());
return null;
Expand Down

0 comments on commit be57dec

Please sign in to comment.