Merge branch 'develop' of https://github.com/Kitzanos/GEPAFIN-BE into develop

This commit is contained in:
rajesh
2024-09-23 18:34:36 +05:30
2 changed files with 16 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
FROM amazoncorretto:17.0.8-alpine3.17
EXPOSE 8080
ADD /target/tendermanagement-0.0.1-SNAPSHOT.jar tendermanagement-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java", "-jar","tendermanagement-0.0.1-SNAPSHOT.jar"]
ENTRYPOINT ["java", "-jar","tendermanagement-0.0.1-SNAPSHOT.jar"]

View File

@@ -1,8 +1,8 @@
package net.gepafin.tendermanagement.config;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.cert.CertificateFactory;
@@ -235,8 +235,7 @@ public class SecurityConfig {
public PrivateKey readPrivateKey() throws Exception {
// Path to your private key PEM file
File privateKeyFile = new File("src/main/resources/dev/saml/private-key.pem");
try (PemReader pemReader = new PemReader(new FileReader(privateKeyFile))) {
try (PemReader pemReader = new PemReader(new InputStreamReader(readKey("dev/saml/private-key.pem")))) {
// Read the PEM content
byte[] pemContent = pemReader.readPemObject().getContent();
// Decode the PEM content
@@ -248,10 +247,19 @@ public class SecurityConfig {
}
public X509Certificate readCertificate() throws Exception {
// Path to your certificate PEM fileFile
File certFile = new File("src/main/resources/dev/saml/public-cert.pem");
try (InputStream inStream = new FileInputStream(certFile)) {
try (InputStream inStream = readKey("dev/saml/public-cert.pem")) {
CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
return (X509Certificate) certFactory.generateCertificate(inStream);
}
}
public InputStream readKey(String path) throws IOException {
ClassLoader classLoader = getClass().getClassLoader();
InputStream inputStream = classLoader.getResourceAsStream(path);
if (inputStream == null) {
throw new FileNotFoundException("file not found : "+path);
}
return inputStream;
}
}