2 * ============LICENSE_START======================================================================
3 * Copyright (C) 2018-2019 Nordix Foundation. All rights reserved.
4 * ===============================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 * in compliance with the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software distributed under the License
11 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 * or implied. See the License for the specific language governing permissions and limitations under
14 * ============LICENSE_END========================================================================
17 package org.onap.dcaegen2.collectors.datafile.ftp;
19 import java.io.IOException;
20 import java.io.OutputStream;
21 import javax.net.ssl.KeyManager;
22 import javax.net.ssl.TrustManager;
23 import org.apache.commons.net.ftp.FTPSClient;
24 import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
26 public class FTPSClientWrapper implements IFTPSClient {
27 private FTPSClient ftpsClient = new FTPSClient();
30 public void setNeedClientAuth(boolean isNeedClientAuth) {
31 ftpsClient.setNeedClientAuth(isNeedClientAuth);
35 public void setKeyManager(KeyManager keyManager) {
36 ftpsClient.setKeyManager(keyManager);
40 public void setTrustManager(TrustManager trustManager) {
41 ftpsClient.setTrustManager(trustManager);
45 public void connect(String hostName, int port) throws IOException {
46 ftpsClient.connect(hostName, port);
50 public boolean login(String username, String password) throws IOException {
51 return ftpsClient.login(username, password);
55 public boolean logout() throws IOException {
56 return ftpsClient.logout();
60 public int getReplyCode() {
61 return ftpsClient.getReplyCode();
65 public void disconnect() throws IOException {
66 ftpsClient.disconnect();
70 public void enterLocalPassiveMode() {
71 ftpsClient.enterLocalPassiveMode();
75 public void setFileType(int fileType) throws IOException {
76 ftpsClient.setFileType(fileType);
80 public void execPBSZ(int psbz) throws IOException {
81 ftpsClient.execPBSZ(psbz);
85 public void execPROT(String prot) throws IOException {
86 ftpsClient.execPROT(prot);
90 public void retrieveFile(String remote, OutputStream local) throws DatafileTaskException {
92 if (!ftpsClient.retrieveFile(remote, local)) {
93 throw new DatafileTaskException("could not retrieve file");
95 } catch (IOException e) {
96 throw new DatafileTaskException(e);
101 public void setTimeout(Integer t) {
102 this.ftpsClient.setDefaultTimeout(t);
106 public boolean isConnected() {
107 return ftpsClient.isConnected();
111 public void setBufferSize(int bufSize) {
112 ftpsClient.setBufferSize(bufSize);