From f35b9cff9559bff870a703255c23698b31cb01be Mon Sep 17 00:00:00 2001 From: Jan Malkiewicz Date: Thu, 23 Jul 2020 09:04:34 +0200 Subject: Removed support for FTPS protocol (from now only FTPeS and sFTP will be supported). Issue-ID: DCAEGEN2-2367 Signed-off-by: Jan Malkiewicz Change-Id: Ifada2899431c56bdbfcf3aad73fdc9b376ae9c4f --- .../collectors/datafile/ftp/FtpesClient.java | 239 +++++++++++++++++++++ .../collectors/datafile/ftp/FtpsClient.java | 238 -------------------- .../dcaegen2/collectors/datafile/ftp/Scheme.java | 9 +- .../datafile/ftp/SftpClientSettings.java | 4 +- .../collectors/datafile/tasks/FileCollector.java | 13 +- 5 files changed, 253 insertions(+), 250 deletions(-) create mode 100644 datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpesClient.java delete mode 100644 datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java (limited to 'datafile-app-server/src/main') diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpesClient.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpesClient.java new file mode 100644 index 00000000..a91d46ae --- /dev/null +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpesClient.java @@ -0,0 +1,239 @@ +/*- + * ============LICENSE_START====================================================================== + * Copyright (C) 2018-2019 Nordix Foundation. All rights reserved. + * Copyright (C) 2020 Nokia. All rights reserved. + * =============================================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END======================================================================== + */ + +package org.onap.dcaegen2.collectors.datafile.ftp; + +import java.io.File; +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; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; +import java.util.Optional; + +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; + +import org.apache.commons.net.ftp.FTP; +import org.apache.commons.net.ftp.FTPReply; +import org.apache.commons.net.ftp.FTPSClient; +import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException; +import org.onap.dcaegen2.collectors.datafile.exceptions.NonRetryableDatafileTaskException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.io.FileSystemResource; + +/** + * Gets file from PNF with FTPS protocol. + * + * @author Martin Yan + */ +public class FtpesClient implements FileCollectClient { + private static final Logger logger = LoggerFactory.getLogger(FtpesClient.class); + + private static final int DEFAULT_PORT = 21; + + FTPSClient realFtpsClient = new FTPSClient(); + private final FileServerData fileServerData; + private static TrustManager theTrustManager = null; + private static KeyManager theKeyManager = null; + + private final Path keyCertPath; + private final String keyCertPasswordPath; + private final Path trustedCaPath; + private final String trustedCaPasswordPath; + + /** + * Constructor. + * + * @param fileServerData info needed to connect to the PNF. + * @param keyCertPath path to 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 trustedCaPasswordPath path of file containing password for the PNF's trusted keystore. + */ + public FtpesClient(FileServerData fileServerData, Path keyCertPath, String keyCertPasswordPath, Path trustedCaPath, + String trustedCaPasswordPath) { + this.fileServerData = fileServerData; + this.keyCertPath = keyCertPath; + this.keyCertPasswordPath = keyCertPasswordPath; + this.trustedCaPath = trustedCaPath; + this.trustedCaPasswordPath = trustedCaPasswordPath; + } + + @Override + public void open() throws DatafileTaskException { + try { + realFtpsClient.setNeedClientAuth(true); + realFtpsClient.setKeyManager(getKeyManager(keyCertPath, keyCertPasswordPath)); + realFtpsClient.setTrustManager(getTrustManager(trustedCaPath, trustedCaPasswordPath)); + setUpConnection(); + } catch (DatafileTaskException e) { + throw e; + } catch (Exception e) { + throw new DatafileTaskException("Could not open connection: " + e, e); + } + } + + @Override + public void close() { + logger.trace("starting to closeDownConnection"); + if (realFtpsClient.isConnected()) { + try { + boolean logOut = realFtpsClient.logout(); + logger.trace("logOut: {}", logOut); + } catch (Exception e) { + logger.trace("Unable to logout connection.", e); + } + try { + realFtpsClient.disconnect(); + logger.trace("disconnected!"); + } catch (Exception e) { + logger.trace("Unable to disconnect connection.", e); + } + } + } + + @Override + public void collectFile(String remoteFileName, Path localFileName) throws DatafileTaskException { + logger.trace("collectFile called"); + + try (OutputStream output = createOutputStream(localFileName)) { + logger.trace("begin to retrieve from xNF."); + if (!realFtpsClient.retrieveFile(remoteFileName, output)) { + throw new NonRetryableDatafileTaskException( + "Could not retrieve file. No retry attempts will be done, file :" + remoteFileName); + } + } catch (IOException e) { + throw new DatafileTaskException("Could not fetch file: " + e, e); + } + logger.trace("collectFile fetched: {}", localFileName); + } + + private static int getPort(Optional port) { + return port.isPresent() ? port.get() : DEFAULT_PORT; + } + + private void setUpConnection() throws DatafileTaskException, IOException { + + realFtpsClient.connect(fileServerData.serverAddress(), getPort(fileServerData.port())); + logger.trace("after ftp connect"); + + if (!realFtpsClient.login(fileServerData.userId(), fileServerData.password())) { + throw new DatafileTaskException("Unable to log in to xNF. " + fileServerData.serverAddress()); + } + + if (FTPReply.isPositiveCompletion(realFtpsClient.getReplyCode())) { + realFtpsClient.enterLocalPassiveMode(); + realFtpsClient.setFileType(FTP.BINARY_FILE_TYPE); + // Set protection buffer size + realFtpsClient.execPBSZ(0); + // Set data channel protection to private + realFtpsClient.execPROT("P"); + realFtpsClient.setBufferSize(1024 * 1024); + } else { + throw new DatafileTaskException("Unable to connect to xNF. " + fileServerData.serverAddress() + + " xNF reply code: " + realFtpsClient.getReplyCode()); + } + + logger.trace("setUpConnection successfully!"); + } + + private TrustManager createTrustManager(Path trustedCaPath, String trustedCaPassword) + throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException { + logger.trace("Creating trust manager from file: {}", trustedCaPath); + try (InputStream fis = createInputStream(trustedCaPath)) { + KeyStore keyStore = KeyStore.getInstance("JKS"); + keyStore.load(fis, trustedCaPassword.toCharArray()); + TrustManagerFactory factory = TrustManagerFactory.getInstance("SunX509"); + factory.init(keyStore); + return factory.getTrustManagers()[0]; + } + } + + protected InputStream createInputStream(Path localFileName) throws IOException { + FileSystemResource realResource = new FileSystemResource(localFileName); + return realResource.getInputStream(); + } + + protected OutputStream createOutputStream(Path localFileName) throws IOException { + File localFile = localFileName.toFile(); + if (!localFile.createNewFile()) { + logger.warn("Local file {} already created", localFileName); + } + OutputStream output = new FileOutputStream(localFile); + logger.trace("File {} opened xNF", localFileName); + return output; + } + + 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 (FtpesClient.class) { + if (theTrustManager == null) { + theTrustManager = createTrustManager(trustedCaPath, trustedCaPassword); + } + return theTrustManager; + } + } + + protected KeyManager getKeyManager(Path 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(); + } + + synchronized (FtpesClient.class) { + if (theKeyManager == null) { + theKeyManager = createKeyManager(keyCertPath, keyCertPassword); + } + return theKeyManager; + } + } + + private KeyManager createKeyManager(Path keyCertPath, String keyCertPassword) throws IOException, KeyStoreException, + NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException { + logger.trace("Creating key manager from file: {}", keyCertPath); + try (InputStream fis = createInputStream(keyCertPath)) { + KeyStore keyStore = KeyStore.getInstance("JKS"); + keyStore.load(fis, keyCertPassword.toCharArray()); + KeyManagerFactory factory = KeyManagerFactory.getInstance("SunX509"); + factory.init(keyStore, keyCertPassword.toCharArray()); + return factory.getKeyManagers()[0]; + } + } +} 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 deleted file mode 100644 index fea578ba..00000000 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java +++ /dev/null @@ -1,238 +0,0 @@ -/*- - * ============LICENSE_START====================================================================== - * Copyright (C) 2018-2019 Nordix Foundation. All rights reserved. - * =============================================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END======================================================================== - */ - -package org.onap.dcaegen2.collectors.datafile.ftp; - -import java.io.File; -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; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; -import java.security.cert.CertificateException; -import java.util.Optional; - -import javax.net.ssl.KeyManager; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; - -import org.apache.commons.net.ftp.FTP; -import org.apache.commons.net.ftp.FTPReply; -import org.apache.commons.net.ftp.FTPSClient; -import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException; -import org.onap.dcaegen2.collectors.datafile.exceptions.NonRetryableDatafileTaskException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.io.FileSystemResource; - -/** - * Gets file from PNF with FTPS protocol. - * - * @author Martin Yan - */ -public class FtpsClient implements FileCollectClient { - private static final Logger logger = LoggerFactory.getLogger(FtpsClient.class); - - private static final int FTPS_DEFAULT_PORT = 21; - - FTPSClient realFtpsClient = new FTPSClient(); - private final FileServerData fileServerData; - private static TrustManager theTrustManager = null; - private static KeyManager theKeyManager = null; - - private final Path keyCertPath; - private final String keyCertPasswordPath; - private final Path trustedCaPath; - private final String trustedCaPasswordPath; - - /** - * Constructor. - * - * @param fileServerData info needed to connect to the PNF. - * @param keyCertPath path to 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 trustedCaPasswordPath path of file containing password for the PNF's trusted keystore. - */ - public FtpsClient(FileServerData fileServerData, Path keyCertPath, String keyCertPasswordPath, Path trustedCaPath, - String trustedCaPasswordPath) { - this.fileServerData = fileServerData; - this.keyCertPath = keyCertPath; - this.keyCertPasswordPath = keyCertPasswordPath; - this.trustedCaPath = trustedCaPath; - this.trustedCaPasswordPath = trustedCaPasswordPath; - } - - @Override - public void open() throws DatafileTaskException { - try { - realFtpsClient.setNeedClientAuth(true); - realFtpsClient.setKeyManager(getKeyManager(keyCertPath, keyCertPasswordPath)); - realFtpsClient.setTrustManager(getTrustManager(trustedCaPath, trustedCaPasswordPath)); - setUpConnection(); - } catch (DatafileTaskException e) { - throw e; - } catch (Exception e) { - throw new DatafileTaskException("Could not open connection: " + e, e); - } - } - - @Override - public void close() { - logger.trace("starting to closeDownConnection"); - if (realFtpsClient.isConnected()) { - try { - boolean logOut = realFtpsClient.logout(); - logger.trace("logOut: {}", logOut); - } catch (Exception e) { - logger.trace("Unable to logout connection.", e); - } - try { - realFtpsClient.disconnect(); - logger.trace("disconnected!"); - } catch (Exception e) { - logger.trace("Unable to disconnect connection.", e); - } - } - } - - @Override - public void collectFile(String remoteFileName, Path localFileName) throws DatafileTaskException { - logger.trace("collectFile called"); - - try (OutputStream output = createOutputStream(localFileName)) { - logger.trace("begin to retrieve from xNF."); - if (!realFtpsClient.retrieveFile(remoteFileName, output)) { - throw new NonRetryableDatafileTaskException( - "Could not retrieve file. No retry attempts will be done, file :" + remoteFileName); - } - } catch (IOException e) { - throw new DatafileTaskException("Could not fetch file: " + e, e); - } - logger.trace("collectFile fetched: {}", localFileName); - } - - private static int getPort(Optional port) { - return port.isPresent() ? port.get() : FTPS_DEFAULT_PORT; - } - - private void setUpConnection() throws DatafileTaskException, IOException { - - realFtpsClient.connect(fileServerData.serverAddress(), getPort(fileServerData.port())); - logger.trace("after ftp connect"); - - if (!realFtpsClient.login(fileServerData.userId(), fileServerData.password())) { - throw new DatafileTaskException("Unable to log in to xNF. " + fileServerData.serverAddress()); - } - - if (FTPReply.isPositiveCompletion(realFtpsClient.getReplyCode())) { - realFtpsClient.enterLocalPassiveMode(); - realFtpsClient.setFileType(FTP.BINARY_FILE_TYPE); - // Set protection buffer size - realFtpsClient.execPBSZ(0); - // Set data channel protection to private - realFtpsClient.execPROT("P"); - realFtpsClient.setBufferSize(1024 * 1024); - } else { - throw new DatafileTaskException("Unable to connect to xNF. " + fileServerData.serverAddress() - + " xNF reply code: " + realFtpsClient.getReplyCode()); - } - - logger.trace("setUpConnection successfully!"); - } - - private TrustManager createTrustManager(Path trustedCaPath, String trustedCaPassword) - throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException { - logger.trace("Creating trust manager from file: {}", trustedCaPath); - try (InputStream fis = createInputStream(trustedCaPath)) { - KeyStore keyStore = KeyStore.getInstance("JKS"); - keyStore.load(fis, trustedCaPassword.toCharArray()); - TrustManagerFactory factory = TrustManagerFactory.getInstance("SunX509"); - factory.init(keyStore); - return factory.getTrustManagers()[0]; - } - } - - protected InputStream createInputStream(Path localFileName) throws IOException { - FileSystemResource realResource = new FileSystemResource(localFileName); - return realResource.getInputStream(); - } - - protected OutputStream createOutputStream(Path localFileName) throws IOException { - File localFile = localFileName.toFile(); - if (!localFile.createNewFile()) { - logger.warn("Local file {} already created", localFileName); - } - OutputStream output = new FileOutputStream(localFile); - logger.trace("File {} opened xNF", localFileName); - return output; - } - - 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); - } - return theTrustManager; - } - } - - protected KeyManager getKeyManager(Path 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(); - } - - synchronized (FtpsClient.class) { - if (theKeyManager == null) { - theKeyManager = createKeyManager(keyCertPath, keyCertPassword); - } - return theKeyManager; - } - } - - private KeyManager createKeyManager(Path keyCertPath, String keyCertPassword) throws IOException, KeyStoreException, - NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException { - logger.trace("Creating key manager from file: {}", keyCertPath); - try (InputStream fis = createInputStream(keyCertPath)) { - KeyStore keyStore = KeyStore.getInstance("JKS"); - keyStore.load(fis, keyCertPassword.toCharArray()); - KeyManagerFactory factory = KeyManagerFactory.getInstance("SunX509"); - factory.init(keyStore, keyCertPassword.toCharArray()); - return factory.getKeyManagers()[0]; - } - } -} diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/Scheme.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/Scheme.java index c10c0f1e..b20feb82 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/Scheme.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/Scheme.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. All rights reserved. + * Copyright (C) 2020 Nokia. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,10 +28,10 @@ import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException; * */ public enum Scheme { - FTPS, SFTP; + FTPES, SFTP; public static final String DFC_DOES_NOT_SUPPORT_PROTOCOL_ERROR_MSG = "DFC does not support protocol "; - public static final String SUPPORTED_PROTOCOLS_ERROR_MESSAGE = ". Supported protocols are FTPES, FTPS, and SFTP"; + public static final String SUPPORTED_PROTOCOLS_ERROR_MESSAGE = ". Supported protocols are FTPeS and sFTP"; /** * Get a Scheme from a string. @@ -41,8 +42,8 @@ public enum Scheme { */ public static Scheme getSchemeFromString(String schemeString) throws DatafileTaskException { Scheme result; - if ("FTPS".equalsIgnoreCase(schemeString) || "FTPES".equalsIgnoreCase(schemeString)) { - result = Scheme.FTPS; + if ("FTPES".equalsIgnoreCase(schemeString)) { + result = Scheme.FTPES; } else if ("SFTP".equalsIgnoreCase(schemeString)) { result = Scheme.SFTP; } else { diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClientSettings.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClientSettings.java index 8cab4327..a4c5cb3f 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClientSettings.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClientSettings.java @@ -53,10 +53,10 @@ public class SftpClientSettings { private void logUsageOfStrictHostCheckingFlag(boolean strictHostKeyChecking, String filePath) { if (strictHostKeyChecking) { - logger.info("StrictHostKeyChecking will be enabled with KNOW_HOSTS_FILE_PATH [{}].", filePath); + logger.info("StrictHostKeyChecking will be enabled with KNOWN_HOSTS_FILE_PATH [{}].", filePath); } else { logger.warn( - "StrictHostKeyChecking is enabled but environment variable KNOW_HOSTS_FILE_PATH is not set or points to not existing file [{}] --> falling back to StrictHostKeyChecking='no'.", + "StrictHostKeyChecking is enabled but environment variable KNOWN_HOSTS_FILE_PATH is not set or points to not existing file [{}] --> falling back to StrictHostKeyChecking='no'.", filePath); } } 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 e9c4aceb..b151b042 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 @@ -1,6 +1,7 @@ /*- * ============LICENSE_START====================================================================== * Copyright (C) 2018-2019 Nordix Foundation. All rights reserved. + * Copyright (C) 2020 Nokia. All rights reserved. * =============================================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -27,7 +28,7 @@ import org.onap.dcaegen2.collectors.datafile.configuration.FtpesConfig; import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException; import org.onap.dcaegen2.collectors.datafile.exceptions.NonRetryableDatafileTaskException; import org.onap.dcaegen2.collectors.datafile.ftp.FileCollectClient; -import org.onap.dcaegen2.collectors.datafile.ftp.FtpsClient; +import org.onap.dcaegen2.collectors.datafile.ftp.FtpesClient; import org.onap.dcaegen2.collectors.datafile.ftp.SftpClient; import org.onap.dcaegen2.collectors.datafile.ftp.SftpClientSettings; import org.onap.dcaegen2.collectors.datafile.model.Counters; @@ -124,10 +125,10 @@ public class FileCollector { switch (fileData.scheme()) { case SFTP: return createSftpClient(fileData); - case FTPS: - return createFtpsClient(fileData); + case FTPES: + return createFtpesClient(fileData); default: - throw new DatafileTaskException("Unhandeled protocol: " + fileData.scheme()); + throw new DatafileTaskException("Unhandled protocol: " + fileData.scheme()); } } @@ -158,9 +159,9 @@ public class FileCollector { new SftpClientSettings(datafileAppConfig.getSftpConfiguration())); } - protected FtpsClient createFtpsClient(FileData fileData) { + protected FtpesClient createFtpesClient(FileData fileData) { FtpesConfig config = datafileAppConfig.getFtpesConfiguration(); - return new FtpsClient(fileData.fileServerData(), Paths.get(config.keyCert()), config.keyPasswordPath(), + return new FtpesClient(fileData.fileServerData(), Paths.get(config.keyCert()), config.keyPasswordPath(), Paths.get(config.trustedCa()), config.trustedCaPasswordPath()); } } -- cgit 1.2.3-korg