aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChengkai Yan <martin.c.yan@est.tech>2018-10-15 13:55:55 +0200
committerChengkai Yan <martin.c.yan@est.tech>2018-10-15 17:01:55 +0200
commit36ca816e964d2f5a4b3f4702e4a76a1104740fc8 (patch)
tree3363846a995ab6cce0d93a8cc9c4fdbf5c888b58
parentb47ed92edbf3b4f50b814a4b1912b5ef6185c294 (diff)
Improve setKeyManager & setTrustManager
Change-Id: I14b1bd6872e40496ce233ec4974ad9e5fd92d949 Signed-off-by: Chengkai Yan <martin.c.yan@est.tech> Issue-ID: DCAEGEN2-867
-rw-r--r--datafile-app-server/pom.xml2
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfig.java2
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/RetryTimer.java2
-rw-r--r--datafile-app-server/src/main/resources/datafile_endpoints.json31
-rw-r--r--datafile-commons/pom.xml2
-rw-r--r--datafile-dmaap-client/pom.xml2
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FTPSClientWrapper.java4
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectResult.java5
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java26
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/IFTPSClient.java2
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java1
-rw-r--r--pom.xml2
-rw-r--r--version.properties2
13 files changed, 60 insertions, 23 deletions
diff --git a/datafile-app-server/pom.xml b/datafile-app-server/pom.xml
index 4c716bd6..3c91f94e 100644
--- a/datafile-app-server/pom.xml
+++ b/datafile-app-server/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.dcaegen2.collectors</groupId>
<artifactId>datafile</artifactId>
- <version>1.0.2-SNAPSHOT</version>
+ <version>1.0.3-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.collectors.datafile</groupId>
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfig.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfig.java
index c42749cf..6420b4a0 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfig.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfig.java
@@ -42,7 +42,7 @@ import reactor.core.publisher.Mono;
@EnableScheduling
public class SchedulerConfig extends DatafileAppConfig {
- private static final int SCHEDULING_DELAY_FOR_DATAFILE_COLLECTOR_TASKS = 10;
+ private static final int SCHEDULING_DELAY_FOR_DATAFILE_COLLECTOR_TASKS = 15;
private static final int SCHEDULING_REQUEST_FOR_CONFIGURATION_DELAY = 5;
private static volatile List<ScheduledFuture> scheduledFutureList = new ArrayList<>();
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/RetryTimer.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/RetryTimer.java
index c2b97da8..b993f204 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/RetryTimer.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/RetryTimer.java
@@ -22,7 +22,7 @@ public class RetryTimer {
public void waitRetryTime() {
try {
Thread.sleep(60000);
- } catch (InterruptedException e) {
+ } catch (Exception e) {
// Nothing, no one will interrupt.
}
diff --git a/datafile-app-server/src/main/resources/datafile_endpoints.json b/datafile-app-server/src/main/resources/datafile_endpoints.json
index dff77d2f..9da01d7b 100644
--- a/datafile-app-server/src/main/resources/datafile_endpoints.json
+++ b/datafile-app-server/src/main/resources/datafile_endpoints.json
@@ -2,27 +2,36 @@
"configs": {
"dmaap": {
"dmaapConsumerConfiguration": {
- "consumerGroup": "notification",
- "consumerId": "C12",
- "dmaapContentType": "application/json",
"dmaapHostName": "localhost",
"dmaapPortNumber": 2222,
- "dmaapProtocol": "http",
"dmaapTopicName": "/events/unauthenticated.VES_NOTIFICATION_OUTPUT",
- "dmaapUserName": "admin",
- "dmaapUserPassword": "admin",
- "messageLimit": 1000,
- "timeoutMS": 1000
+ "dmaapProtocol": "http",
+ "dmaapUserName": "",
+ "dmaapUserPassword": "",
+ "dmaapContentType": "application/json",
+ "consumerId": "C12",
+ "consumerGroup": "OpenDcae-c12",
+ "timeoutMS": -1,
+ "messageLimit": 1
},
"dmaapProducerConfiguration": {
- "dmaapContentType": "application/octet-stream",
"dmaapHostName": "localhost",
"dmaapPortNumber": 3907,
- "dmaapProtocol": "https",
"dmaapTopicName": "publish",
+ "dmaapProtocol": "https",
"dmaapUserName": "dradmin",
- "dmaapUserPassword": "dradmin"
+ "dmaapUserPassword": "dradmin",
+ "dmaapContentType": "application/octet-stream"
+ }
+ },
+ "ftp": {
+ "ftpesConfiguration": {
+ "keyCert": "config/ftpKey.jks",
+ "keyPassword": "secret",
+ "trustedCA": "config/cacerts",
+ "trustedCAPassword": "secret"
}
}
}
}
+
diff --git a/datafile-commons/pom.xml b/datafile-commons/pom.xml
index 9029769e..1ae3c2da 100644
--- a/datafile-commons/pom.xml
+++ b/datafile-commons/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.dcaegen2.collectors</groupId>
<artifactId>datafile</artifactId>
- <version>1.0.2-SNAPSHOT</version>
+ <version>1.0.3-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.collectors.datafile</groupId>
diff --git a/datafile-dmaap-client/pom.xml b/datafile-dmaap-client/pom.xml
index 9eb232ba..5006b002 100644
--- a/datafile-dmaap-client/pom.xml
+++ b/datafile-dmaap-client/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.dcaegen2.collectors</groupId>
<artifactId>datafile</artifactId>
- <version>1.0.2-SNAPSHOT</version>
+ <version>1.0.3-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.collectors.datafile</groupId>
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FTPSClientWrapper.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FTPSClientWrapper.java
index 77048042..2ccf1bab 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FTPSClientWrapper.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FTPSClientWrapper.java
@@ -89,4 +89,8 @@ public class FTPSClientWrapper implements IFTPSClient {
return ftpsClient.retrieveFile(remote, local);
}
+ @Override
+ public void setTimeout(Integer t) {
+ this.ftpsClient.setDefaultTimeout(t);
+ }
}
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectResult.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectResult.java
index 6cd048ac..c5962172 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectResult.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectResult.java
@@ -36,7 +36,10 @@ public class FileCollectResult {
}
public String getErrorData() {
- return errorData.toString();
+ if (errorData != null) {
+ return errorData.toString();
+ }
+ return "";
}
@Override
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java
index a88072c7..120868c6 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java
@@ -57,6 +57,8 @@ public class FtpsClient extends FileCollectClient {
private IFile lf;
private IFileSystemResource fileResource;
private IOutputStream os;
+ private boolean keyManagerSet = false;
+ private boolean trustManagerSet = false;
@Override
public FileCollectResult retryCollectFile() {
@@ -84,19 +86,27 @@ public class FtpsClient extends FileCollectClient {
private boolean setUpKeyManager(IFTPSClient ftps) {
boolean result = true;
+ if (keyManagerSet) {
+ return result;
+ }
try {
IKeyManagerUtils keyManagerUtils = getKeyManagerUtils();
keyManagerUtils.setCredentials(keyCertPath, keyCertPassword);
ftps.setKeyManager(keyManagerUtils.getClientKeyManager());
+ keyManagerSet = true;
} catch (GeneralSecurityException | IOException e) {
addError("Unable to use own key store " + keyCertPath, e);
result = false;
}
+ logger.trace("complete setUpKeyManager");
return result;
}
private boolean setUpTrustedCA(IFTPSClient ftps) {
boolean result = true;
+ if (trustManagerSet) {
+ return result;
+ }
try {
IFileSystemResource fileSystemResource = getFileSystemResource();
fileSystemResource.setPath(trustedCAPath);
@@ -107,11 +117,13 @@ public class FtpsClient extends FileCollectClient {
ITrustManagerFactory tmf = getTrustManagerFactory();
tmf.init(ks.getKeyStore());
ftps.setTrustManager(tmf.getTrustManagers()[0]);
+ trustManagerSet = true;
} catch (Exception e) {
addError("Unable to trust xNF's CA, " + trustedCAPath, e);
result = false;
}
+ logger.trace("complete setUpTrustedCA");
return result;
}
@@ -119,7 +131,7 @@ public class FtpsClient extends FileCollectClient {
boolean result = true;
try {
ftps.connect(fileServerData.serverAddress(), fileServerData.port());
-
+ logger.trace("after ftp connect");
boolean loginSuccesful = ftps.login(fileServerData.userId(), fileServerData.password());
if (!loginSuccesful) {
ftps.logout();
@@ -135,7 +147,8 @@ public class FtpsClient extends FileCollectClient {
ftps.execPROT("P");
} else {
ftps.disconnect();
- addError("Unable to connect to xNF. " + fileServerData + "xNF reply code: " + ftps.getReplyCode(), null);
+ addError("Unable to connect to xNF. " + fileServerData + " xNF reply code: " + ftps.getReplyCode(),
+ null);
result = false;
}
} catch (Exception ex) {
@@ -157,8 +170,13 @@ public class FtpsClient extends FileCollectClient {
IOutputStream outputStream = getOutputStream();
OutputStream output = outputStream.getOutputStream(outfile.getFile());
- ftps.retrieveFile(remoteFile, output);
-
+ result = ftps.retrieveFile(remoteFile, output);
+ if (!result) {
+ output.close();
+ logger.debug("Unable to retrieve file from xNF. Cause unknown!");
+ addError("Unable to retrieve file from xNF. Cause unknown!", null);
+ return result;
+ }
output.close();
logger.debug("File {} Download Successfull from xNF", localFile);
} catch (IOException ex) {
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/IFTPSClient.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/IFTPSClient.java
index 2f370b98..b1472026 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/IFTPSClient.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/IFTPSClient.java
@@ -48,4 +48,6 @@ public interface IFTPSClient {
public void execPROT(String prot) throws IOException;
public boolean retrieveFile(String remote, OutputStream local) throws IOException;
+
+ void setTimeout(Integer t);
}
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java
index e9e00c38..e5693d50 100644
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java
@@ -102,6 +102,7 @@ public class FtpsClientTest {
when(localFileMock.getFile()).thenReturn(fileMock);
OutputStream osMock = mock(OutputStream.class);
when(outputStreamMock.getOutputStream(fileMock)).thenReturn(osMock);
+ when(ftpsClientMock.retrieveFile(REMOTE_FILE_PATH, osMock)).thenReturn(true);
ImmutableFileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(XNF_ADDRESS)
.userId(USERNAME).password(PASSWORD).port(PORT).build();
diff --git a/pom.xml b/pom.xml
index b04a798f..a3af87a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@
<groupId>org.onap.dcaegen2.collectors</groupId>
<artifactId>datafile</artifactId>
- <version>1.0.2-SNAPSHOT</version>
+ <version>1.0.3-SNAPSHOT</version>
<name>dcaegen2-collectors.datafile</name>
<description>datafile collector</description>
diff --git a/version.properties b/version.properties
index 22632725..39e03d93 100644
--- a/version.properties
+++ b/version.properties
@@ -1,6 +1,6 @@
major=1
minor=0
-patch=2
+patch=3
base_version=${major}.${minor}.${patch}
release_version=${base_version}
snapshot_version=${base_version}-SNAPSHOT