Added support for HTTP Proxy
[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     public WebClientConfig getWebClientConfig() {
66         HttpProxyConfig httpProxyConfig = ImmutableHttpProxyConfig.builder() //
67             .httpProxyHost(this.httpProxyHost) //
68             .httpProxyPort(this.httpProxyPort) //
69             .build();
70         return ImmutableWebClientConfig.builder() //
71             .keyStoreType(this.sslKeyStoreType) //
72             .keyStorePassword(this.sslKeyStorePassword) //
73             .keyStore(this.sslKeyStore) //
74             .keyPassword(this.sslKeyPassword) //
75             .isTrustStoreUsed(this.sslTrustStoreUsed) //
76             .trustStore(this.sslTrustStore) //
77             .trustStorePassword(this.sslTrustStorePassword) //
78             .httpProxyConfig(httpProxyConfig) //
79             .build();
80     }
81
82 }