Minor changes
[nonrtric/plt/ranpm.git] / datafilecollector / src / main / java / org / onap / dcaegen2 / collectors / datafile / configuration / AppConfig.java
1 /*-
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
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
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
14  * the License.
15  * ============LICENSE_END========================================================================
16  */
17
18 package org.onap.dcaegen2.collectors.datafile.configuration;
19
20 import java.util.Properties;
21
22 import lombok.Getter;
23
24 import org.springframework.beans.factory.annotation.Value;
25 import org.springframework.boot.context.properties.EnableConfigurationProperties;
26 import org.springframework.stereotype.Component;
27
28 /**
29  * Holds all configuration for the DFC.
30  *
31  * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on
32  *         3/23/18
33  * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
34  */
35
36 @Component
37 @EnableConfigurationProperties
38 public class AppConfig {
39
40     @Value("#{systemEnvironment}")
41     Properties systemEnvironment;
42
43     @Value("${app.kafka.bootstrap-servers:}")
44     private String kafkaBootStrapServers;
45
46     @Value("${app.kafka.collected-file-topic:}")
47     public String collectedFileTopic;
48
49     @Value("${app.kafka.file-ready-event-topic:}")
50     public String fileReadyEventTopic;
51
52     @Value("${app.kafka.client-id:undefined}")
53     public String kafkaClientId;
54
55     @Value("${app.collected-files-path:}")
56     public String collectedFilesPath;
57
58     @Value("${app.sftp.strict-host-key-checking:false}")
59     public boolean strictHostKeyChecking;
60
61     @Value("${app.sftp.known-hosts-file-path:}")
62     public String knownHostsFilePath;
63
64     @Value("${app.ssl.key-store-password-file}")
65     private String clientKeyStorePassword = "";
66
67     @Value("${app.ssl.key-store:}")
68     private String clientKeyStore = "";
69
70     @Value("${app.ssl.trust-store:}")
71     private String clientTrustStore = "";
72
73     @Value("${app.ssl.trust-store-password-file:}")
74     private String clientTrustStorePassword;
75
76     @Getter
77     @Value("${app.s3.endpointOverride:}")
78     private String s3EndpointOverride;
79
80     @Getter
81     @Value("${app.s3.accessKeyId:}")
82     private String s3AccessKeyId;
83
84     @Getter
85     @Value("${app.s3.secretAccessKey:}")
86     private String s3SecretAccessKey;
87
88     @Getter
89     @Value("${app.s3.bucket:}")
90     private String s3Bucket;
91
92     @Value("${app.s3.locksBucket:}")
93     private String s3LocksBucket;
94
95     @Value("${app.number-of-worker-treads:200}")
96     @Getter
97     private int noOfWorkerThreads;
98
99     public String getS3LocksBucket() {
100         return s3LocksBucket.isEmpty() ? s3Bucket : s3LocksBucket;
101     }
102
103     public boolean isS3Enabled() {
104         return !s3EndpointOverride.isEmpty() && !s3Bucket.isEmpty();
105     }
106
107     public String getKafkaBootStrapServers() {
108         return kafkaBootStrapServers;
109     }
110
111     public synchronized CertificateConfig getCertificateConfiguration() {
112         return CertificateConfig.builder() //
113             .trustedCa(this.clientTrustStore) //
114             .trustedCaPasswordPath(this.clientTrustStorePassword) //
115             .keyCert(this.clientKeyStore) //
116             .keyPasswordPath(this.clientKeyStorePassword) //
117             .build();
118     }
119
120     public synchronized SftpConfig getSftpConfiguration() {
121         return SftpConfig.builder() //
122             .knownHostsFilePath(this.knownHostsFilePath) //
123             .strictHostKeyChecking(this.strictHostKeyChecking) //
124             .build();
125     }
126
127 }