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 FROM amazoncorretto:17.0.8-alpine3.17
EXPOSE 8080 EXPOSE 8080
ADD /target/tendermanagement-0.0.1-SNAPSHOT.jar tendermanagement-0.0.1-SNAPSHOT.jar 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; package net.gepafin.tendermanagement.config;
import java.io.File; import java.io.FileNotFoundException;
import java.io.FileInputStream; import java.io.IOException;
import java.io.FileReader;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.KeyFactory; import java.security.KeyFactory;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.cert.CertificateFactory; import java.security.cert.CertificateFactory;
@@ -235,8 +235,7 @@ public class SecurityConfig {
public PrivateKey readPrivateKey() throws Exception { public PrivateKey readPrivateKey() throws Exception {
// Path to your private key PEM file // 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 InputStreamReader(readKey("dev/saml/private-key.pem")))) {
try (PemReader pemReader = new PemReader(new FileReader(privateKeyFile))) {
// Read the PEM content // Read the PEM content
byte[] pemContent = pemReader.readPemObject().getContent(); byte[] pemContent = pemReader.readPemObject().getContent();
// Decode the PEM content // Decode the PEM content
@@ -248,10 +247,19 @@ public class SecurityConfig {
} }
public X509Certificate readCertificate() throws Exception { public X509Certificate readCertificate() throws Exception {
// Path to your certificate PEM fileFile // Path to your certificate PEM fileFile
File certFile = new File("src/main/resources/dev/saml/public-cert.pem"); try (InputStream inStream = readKey("dev/saml/public-cert.pem")) {
try (InputStream inStream = new FileInputStream(certFile)) {
CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
return (X509Certificate) certFactory.generateCertificate(inStream); 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;
}
} }