aboutsummaryrefslogtreecommitdiffstats
path: root/datafile-app-server/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'datafile-app-server/src/main')
-rw-r--r--datafile-app-server/src/main/docker/Dockerfile9
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java2
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParser.java10
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/FtpesConfig.java4
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java41
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java4
6 files changed, 41 insertions, 29 deletions
diff --git a/datafile-app-server/src/main/docker/Dockerfile b/datafile-app-server/src/main/docker/Dockerfile
index 7343128a..bfd952e0 100644
--- a/datafile-app-server/src/main/docker/Dockerfile
+++ b/datafile-app-server/src/main/docker/Dockerfile
@@ -24,18 +24,13 @@ RUN mkdir -p /var/log/ONAP
ADD /target/datafile-app-server.jar /opt/app/datafile/
ADD /config/application.yaml /opt/app/datafile/config/
-ADD /config/dfc.jks.b64 /opt/app/datafile/config/
-ADD /config/ftp.jks.b64 /opt/app/datafile/config/
EXPOSE 8100 8433
RUN addgroup -S onap && adduser -S datafile -G onap
-RUN chown -R datafile:onap /opt/app/datafile
RUN chown -R datafile:onap /var/log/ONAP
-RUN base64 -d /opt/app/datafile/config/dfc.jks.b64 > /opt/app/datafile/config/dfc.jks && base64 -d /opt/app/datafile/config/ftp.jks.b64 > /opt/app/datafile/config/ftp.jks
-RUN chown -R datafile:onap /opt/app/datafile/config/*
-RUN chmod -R 755 /opt/app/datafile/config/
+RUN chmod -R 777 /opt/app/datafile/config/
USER datafile
-ENTRYPOINT ["/usr/bin/java", "-jar", "/opt/app/datafile/datafile-app-server.jar"]
+ENTRYPOINT ["/usr/bin/java", "-jar", "/opt/app/datafile/datafile-app-server.jar"] \ No newline at end of file
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java
index 58081a89..21c51566 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java
@@ -217,7 +217,7 @@ public class AppConfig {
}
private synchronized void setConfiguration(@NotNull ConsumerConfiguration consumerConfiguration,
- @NotNull Map<String, PublisherConfiguration> publisherConfiguration, @NotNull FtpesConfig ftpesConfig) {
+ @NotNull Map<String, PublisherConfiguration> publisherConfiguration, @NotNull FtpesConfig ftpesConfig) {
this.dmaapConsumerConfiguration = consumerConfiguration;
this.publishingConfigurations = publisherConfiguration;
this.ftpesConfiguration = ftpesConfig;
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParser.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParser.java
index fc550ab0..23197025 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParser.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParser.java
@@ -25,11 +25,10 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import javax.validation.constraints.NotNull;
-import java.util.Set;
-
import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
/**
@@ -56,7 +55,8 @@ public class CloudConfigParser {
/**
* Get the publisher configurations.
*
- * @return a map with change identifier as key and the connected publisher configuration as value.
+ * @return a map with change identifier as key and the connected publisher configuration as
+ * value.
*
* @throws DatafileTaskException if a member of the configuration is missing.
*/
@@ -122,9 +122,9 @@ public class CloudConfigParser {
public @NotNull FtpesConfig getFtpesConfig() throws DatafileTaskException {
return new ImmutableFtpesConfig.Builder() //
.keyCert(getAsString(jsonObject, "dmaap.ftpesConfig.keyCert"))
- .keyPassword(getAsString(jsonObject, "dmaap.ftpesConfig.keyPassword"))
+ .keyPasswordPath(getAsString(jsonObject, "dmaap.ftpesConfig.keyPasswordPath"))
.trustedCa(getAsString(jsonObject, "dmaap.ftpesConfig.trustedCa"))
- .trustedCaPassword(getAsString(jsonObject, "dmaap.ftpesConfig.trustedCaPassword")) //
+ .trustedCaPasswordPath(getAsString(jsonObject, "dmaap.ftpesConfig.trustedCaPasswordPath")) //
.build();
}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/FtpesConfig.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/FtpesConfig.java
index e12365e4..e7107976 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/FtpesConfig.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/FtpesConfig.java
@@ -39,12 +39,12 @@ public abstract class FtpesConfig implements Serializable {
@Value.Parameter
@Value.Redacted
- public abstract String keyPassword();
+ public abstract String keyPasswordPath();
@Value.Parameter
public abstract String trustedCa();
@Value.Parameter
@Value.Redacted
- public abstract String trustedCaPassword();
+ public abstract String trustedCaPasswordPath();
}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java
index 2d126ff8..76eb8637 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java
@@ -21,7 +21,9 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.KeyStoreException;
@@ -58,34 +60,34 @@ public class FtpsClient implements FileCollectClient {
private static TrustManager theTrustManager = null;
private final String keyCertPath;
- private final String keyCertPassword;
+ private final String keyCertPasswordPath;
private final Path trustedCaPath;
- private final String trustedCaPassword;
+ private final String trustedCaPasswordPath;
/**
* Constructor.
*
* @param fileServerData info needed to connect to the PNF.
* @param keyCertPath path to DFC's key cert.
- * @param keyCertPassword password for DFC's key cert.
+ * @param keyCertPasswordPath path of file containing password for DFC's key cert.
* @param trustedCaPath path to the PNF's trusted keystore.
- * @param trustedCaPassword password for the PNF's trusted keystore.
+ * @param trustedCaPasswordPath path of file containing password for the PNF's trusted keystore.
*/
- public FtpsClient(FileServerData fileServerData, String keyCertPath, String keyCertPassword, Path trustedCaPath,
- String trustedCaPassword) {
+ public FtpsClient(FileServerData fileServerData, String keyCertPath, String keyCertPasswordPath, Path trustedCaPath,
+ String trustedCaPasswordPath) {
this.fileServerData = fileServerData;
this.keyCertPath = keyCertPath;
- this.keyCertPassword = keyCertPassword;
+ this.keyCertPasswordPath = keyCertPasswordPath;
this.trustedCaPath = trustedCaPath;
- this.trustedCaPassword = trustedCaPassword;
+ this.trustedCaPasswordPath = trustedCaPasswordPath;
}
@Override
public void open() throws DatafileTaskException {
try {
realFtpsClient.setNeedClientAuth(true);
- realFtpsClient.setKeyManager(createKeyManager(keyCertPath, keyCertPassword));
- realFtpsClient.setTrustManager(getTrustManager(trustedCaPath, trustedCaPassword));
+ realFtpsClient.setKeyManager(createKeyManager(keyCertPath, keyCertPasswordPath));
+ realFtpsClient.setTrustManager(getTrustManager(trustedCaPath, trustedCaPasswordPath));
setUpConnection();
} catch (DatafileTaskException e) {
throw e;
@@ -185,8 +187,15 @@ public class FtpsClient implements FileCollectClient {
return output;
}
- protected TrustManager getTrustManager(Path trustedCaPath, String trustedCaPassword)
+ protected TrustManager getTrustManager(Path trustedCaPath, String trustedCaPasswordPath)
throws KeyStoreException, NoSuchAlgorithmException, IOException, CertificateException {
+ String trustedCaPassword = "";
+ try {
+ trustedCaPassword = new String(Files.readAllBytes(Paths.get(trustedCaPasswordPath)));
+ } catch (IOException e) {
+ logger.error("Truststore password file at path: {} cannot be opened ", trustedCaPasswordPath);
+ e.printStackTrace();
+ }
synchronized (FtpsClient.class) {
if (theTrustManager == null) {
theTrustManager = createTrustManager(trustedCaPath, trustedCaPassword);
@@ -195,8 +204,16 @@ public class FtpsClient implements FileCollectClient {
}
}
- protected KeyManager createKeyManager(String keyCertPath, String keyCertPassword)
+ protected KeyManager createKeyManager(String keyCertPath, String keyCertPasswordPath)
throws IOException, GeneralSecurityException {
+ String keyCertPassword = "";
+ try {
+ keyCertPassword = new String(Files.readAllBytes(Paths.get(keyCertPasswordPath)));
+ } catch (IOException e) {
+ logger.error("Keystore password file at path: {} cannot be opened ", keyCertPasswordPath);
+ e.printStackTrace();
+ }
+
return KeyManagerUtils.createClientKeyManager(new File(keyCertPath), keyCertPassword);
}
}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java
index bccbb5fc..a1f8a66e 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java
@@ -159,7 +159,7 @@ public class FileCollector {
protected FtpsClient createFtpsClient(FileData fileData) {
FtpesConfig config = datafileAppConfig.getFtpesConfiguration();
- return new FtpsClient(fileData.fileServerData(), config.keyCert(), config.keyPassword(),
- Paths.get(config.trustedCa()), config.trustedCaPassword());
+ return new FtpsClient(fileData.fileServerData(), config.keyCert(), config.keyPasswordPath(),
+ Paths.get(config.trustedCa()), config.trustedCaPasswordPath());
}
}