db4201b9cadc821783c180c15d2b80fa812944a7
[nonrtric.git] / enrichment-coordinator-service / src / main / java / org / oransc / enrichment / configuration / ApplicationConfig.java
1 /*-
2  * ========================LICENSE_START=================================
3  * O-RAN-SC
4  * %%
5  * Copyright (C) 2020 Nordix Foundation
6  * %%
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ========================LICENSE_END===================================
19  */
20
21 package org.oransc.enrichment.configuration;
22
23 import lombok.Getter;
24
25 import org.oransc.enrichment.configuration.WebClientConfig.HttpProxyConfig;
26 import org.springframework.beans.factory.annotation.Value;
27 import org.springframework.boot.context.properties.ConfigurationProperties;
28 import org.springframework.boot.context.properties.EnableConfigurationProperties;
29
30 @EnableConfigurationProperties
31 @ConfigurationProperties()
32 public class ApplicationConfig {
33
34     @Getter
35     @Value("${app.vardata-directory}")
36     private String vardataDirectory;
37
38     @Value("${server.ssl.key-store-type}")
39     private String sslKeyStoreType = "";
40
41     @Value("${server.ssl.key-store-password}")
42     private String sslKeyStorePassword = "";
43
44     @Value("${server.ssl.key-store}")
45     private String sslKeyStore = "";
46
47     @Value("${server.ssl.key-password}")
48     private String sslKeyPassword = "";
49
50     @Value("${app.webclient.trust-store-used}")
51     private boolean sslTrustStoreUsed = false;
52
53     @Value("${app.webclient.trust-store-password}")
54     private String sslTrustStorePassword = "";
55
56     @Value("${app.webclient.trust-store}")
57     private String sslTrustStore = "";
58
59     @Value("${app.webclient.http.proxy-host:\"\"}")
60     private String httpProxyHost = "";
61
62     @Value("${app.webclient.http.proxy-port:0}")
63     private int httpProxyPort = 0;
64
65     private WebClientConfig webClientConfig = null;
66
67     public WebClientConfig getWebClientConfig() {
68         if (this.webClientConfig == null) {
69             HttpProxyConfig httpProxyConfig = ImmutableHttpProxyConfig.builder() //
70                 .httpProxyHost(this.httpProxyHost) //
71                 .httpProxyPort(this.httpProxyPort) //
72                 .build();
73             this.webClientConfig = ImmutableWebClientConfig.builder() //
74                 .keyStoreType(this.sslKeyStoreType) //
75                 .keyStorePassword(this.sslKeyStorePassword) //
76                 .keyStore(this.sslKeyStore) //
77                 .keyPassword(this.sslKeyPassword) //
78                 .isTrustStoreUsed(this.sslTrustStoreUsed) //
79                 .trustStore(this.sslTrustStore) //
80                 .trustStorePassword(this.sslTrustStorePassword) //
81                 .httpProxyConfig(httpProxyConfig) //
82                 .build();
83         }
84         return this.webClientConfig;
85     }
86
87 }