2 * ============LICENSE_START======================================================================
3 * Copyright (C) 2018, 2020-2022 Nokia. All rights reserved.
4 * Copyright (C) 2018-2019 Nordix Foundation. All rights reserved.
5 * ===============================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7 * in compliance with the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software distributed under the License
12 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing permissions and limitations under
15 * ============LICENSE_END========================================================================
18 package org.onap.dcaegen2.collectors.datafile.configuration;
20 import java.util.Properties;
24 import org.springframework.beans.factory.annotation.Value;
25 import org.springframework.boot.context.properties.EnableConfigurationProperties;
26 import org.springframework.stereotype.Component;
29 * Holds all configuration for the DFC.
31 * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on
33 * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
37 @EnableConfigurationProperties
38 public class AppConfig {
40 @Value("#{systemEnvironment}")
41 Properties systemEnvironment;
43 @Value("${app.filepath}")
46 @Value("${app.kafka.bootstrap-servers:}")
47 private String kafkaBootStrapServers;
49 @Value("${app.kafka.collected-file-topic:}")
50 public String collectedFileTopic;
52 @Value("${app.kafka.file-ready-event-topic:}")
53 public String fileReadyEventTopic;
55 @Value("${app.kafka.client-id:undefined}")
56 public String kafkaClientId;
58 @Value("${app.collected-files-path:}")
59 public String collectedFilesPath;
61 @Value("${app.sftp.strict-host-key-checking:false}")
62 public boolean strictHostKeyChecking;
64 @Value("${app.sftp.known-hosts-file-path:}")
65 public String knownHostsFilePath;
67 @Value("${app.ssl.key-store-password-file}")
68 private String clientKeyStorePassword = "";
70 @Value("${app.ssl.key-store:}")
71 private String clientKeyStore = "";
73 @Value("${app.ssl.trust-store:}")
74 private String clientTrustStore = "";
76 @Value("${app.ssl.trust-store-password-file:}")
77 private String clientTrustStorePassword;
80 @Value("${app.s3.endpointOverride:}")
81 private String s3EndpointOverride;
84 @Value("${app.s3.accessKeyId:}")
85 private String s3AccessKeyId;
88 @Value("${app.s3.secretAccessKey:}")
89 private String s3SecretAccessKey;
92 @Value("${app.s3.bucket:}")
93 private String s3Bucket;
95 @Value("${app.s3.locksBucket:}")
96 private String s3LocksBucket;
98 public String getS3LocksBucket() {
99 return s3LocksBucket.isEmpty() ? s3Bucket : s3LocksBucket;
102 public boolean isS3Enabled() {
103 return !s3EndpointOverride.isEmpty() && !s3Bucket.isEmpty();
106 public String getKafkaBootStrapServers() {
107 return kafkaBootStrapServers;
110 public synchronized CertificateConfig getCertificateConfiguration() {
111 return CertificateConfig.builder() //
112 .trustedCa(this.clientTrustStore) //
113 .trustedCaPasswordPath(this.clientTrustStorePassword) //
114 .keyCert(this.clientKeyStore) //
115 .keyPasswordPath(this.clientKeyStorePassword) //
119 public synchronized SftpConfig getSftpConfiguration() {
120 return SftpConfig.builder() //
121 .knownHostsFilePath(this.knownHostsFilePath) //
122 .strictHostKeyChecking(this.strictHostKeyChecking) //