diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/util/CryptoUtils.java b/src/main/java/fairytale/tbd/domain/faceSwap/util/CryptoUtils.java index 0163bb7..6b4e0e7 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/util/CryptoUtils.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/util/CryptoUtils.java @@ -6,6 +6,8 @@ import javax.crypto.spec.SecretKeySpec; import java.util.Arrays; import java.nio.charset.StandardCharsets; +import java.util.Base64; + import javax.xml.bind.DatatypeConverter; import org.springframework.beans.factory.annotation.Value; @@ -64,27 +66,6 @@ public static String generateAesDecrypt(String dataEncrypt, String clientId, Str return null; } } - - // Encryption algorithm - public static String generateAesEncrypt(String data, String clientId, String clientSecret) { - try { - byte[] keyBytes = clientSecret.getBytes(StandardCharsets.UTF_8); - byte[] ivBytes = clientId.getBytes(StandardCharsets.UTF_8); - - SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES"); - IvParameterSpec ivSpec = new IvParameterSpec(ivBytes); - - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec); - - byte[] encryptedBytes = cipher.doFinal(data.getBytes(StandardCharsets.UTF_8)); - return DatatypeConverter.printHexBinary(encryptedBytes).toLowerCase(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - // Example usage public String getURL(WebhookRequestDTO.RequestDTO webhookRequestDTO){ String newSignature = generateMsgSignature(clientId, webhookRequestDTO.getTimestamp(), webhookRequestDTO.getNonce(), webhookRequestDTO.getDataEncrypt()); diff --git a/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java index 5321864..e4d3c0a 100644 --- a/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java +++ b/src/main/java/fairytale/tbd/domain/faceSwap/web/controller/FaceSwapRestController.java @@ -15,6 +15,7 @@ import lombok.RequiredArgsConstructor; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.springframework.http.ResponseEntity; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -80,11 +81,11 @@ public ApiResponse> test(@RequestBody FaceSwapRequestDto.Fac } @PostMapping("/webhook") - public ApiResponse webhook(@RequestBody WebhookRequestDTO.RequestDTO request){ + public ResponseEntity webhook(@RequestBody WebhookRequestDTO.RequestDTO request){ LOGGER.info("request = {}", request); String swapResult = faceSwapApiService.getSwapImageURL(request); LOGGER.info("swapResult = {}", swapResult); - return ApiResponse.onSuccess("thank you"); + return ResponseEntity.ok().build(); } }