From 7350cabf184fdca4d08d1d785c51db14b0d5627d Mon Sep 17 00:00:00 2001 From: rmtomal Date: Wed, 8 May 2024 02:57:58 +0600 Subject: [PATCH] update some bug pem file --- Dockerfile | 4 ++++ .../Payment/CryptoUtility/CryptoCommon.java | 17 +++++++++++++---- .../marchent_private.pem | 0 .../marchent_public.pem | 0 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 Dockerfile rename src/main/{java/com/tomal/Nagad/Payment/CryptoUtility => resources}/marchent_private.pem (100%) rename src/main/{java/com/tomal/Nagad/Payment/CryptoUtility => resources}/marchent_public.pem (100%) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..54c4e42 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:17-jdk-alpine +ARG JAR_FILE=target/*.jar +COPY ./target/Nagad-Payment-0.0.1-SNAPSHOT.jar Nagad_payment.jar +ENTRYPOINT ["java","-jar", "Nagad_payment.jar"] \ No newline at end of file diff --git a/src/main/java/com/tomal/Nagad/Payment/CryptoUtility/CryptoCommon.java b/src/main/java/com/tomal/Nagad/Payment/CryptoUtility/CryptoCommon.java index d2aaf04..593edd3 100644 --- a/src/main/java/com/tomal/Nagad/Payment/CryptoUtility/CryptoCommon.java +++ b/src/main/java/com/tomal/Nagad/Payment/CryptoUtility/CryptoCommon.java @@ -4,6 +4,7 @@ import jakarta.xml.bind.DatatypeConverter; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -11,6 +12,8 @@ import javax.crypto.NoSuchPaddingException; import java.io.BufferedReader; import java.io.FileReader; +import java.io.InputStream; +import java.io.InputStreamReader; import java.security.*; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; @@ -18,8 +21,10 @@ public class CryptoCommon { - private final String privateKey = "src/main/java/com/tomal/Nagad/Payment/CryptoUtility/marchent_private.pem"; - private final String publicKey = "src/main/java/com/tomal/Nagad/Payment/CryptoUtility/marchent_public.pem"; + + + //InputStream inputStream = getClass().getResourceAsStream("/marchent_private.pem"); + //InputStream publicKey = getClass().getResourceAsStream("/marchent_public.pem"); public byte[] sign(PrivateKey merchantPrivateKey, byte[] bytes) { Object var4 = null; @@ -58,7 +63,9 @@ public String generateRandomString(int size, byte[] seed) { } public PublicKey getPublic() throws Exception { - BufferedReader reader = new BufferedReader(new FileReader(publicKey)); + ClassPathResource resource = new ClassPathResource("marchent_public.pem"); + InputStream inputStream = resource.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String content = reader.readLine(); System.out.println(content); @@ -71,7 +78,9 @@ public PublicKey getPublic() throws Exception { } public PrivateKey getPrivate() throws Exception { - BufferedReader reader = new BufferedReader(new FileReader(privateKey)); + ClassPathResource resource = new ClassPathResource("marchent_private.pem"); + InputStream inputStream = resource.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String content = reader.readLine(); System.out.println(content); diff --git a/src/main/java/com/tomal/Nagad/Payment/CryptoUtility/marchent_private.pem b/src/main/resources/marchent_private.pem similarity index 100% rename from src/main/java/com/tomal/Nagad/Payment/CryptoUtility/marchent_private.pem rename to src/main/resources/marchent_private.pem diff --git a/src/main/java/com/tomal/Nagad/Payment/CryptoUtility/marchent_public.pem b/src/main/resources/marchent_public.pem similarity index 100% rename from src/main/java/com/tomal/Nagad/Payment/CryptoUtility/marchent_public.pem rename to src/main/resources/marchent_public.pem