2 * ========================LICENSE_START=================================
5 * Copyright (C) 2020 Nordix Foundation
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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===================================
21 package org.oransc.enrichment.configuration;
25 import org.oransc.enrichment.configuration.WebClientConfig.HttpProxyConfig;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28 import org.springframework.beans.factory.annotation.Value;
29 import org.springframework.boot.context.properties.ConfigurationProperties;
30 import org.springframework.boot.context.properties.EnableConfigurationProperties;
32 @EnableConfigurationProperties
33 @ConfigurationProperties()
34 public class ApplicationConfig {
36 private static final Logger logger = LoggerFactory.getLogger(ApplicationConfig.class);
39 @Value("${app.vardata-directory}")
40 private String vardataDirectory;
42 @Value("${server.ssl.key-store-type}")
43 private String sslKeyStoreType = "";
45 @Value("${server.ssl.key-store-password}")
46 private String sslKeyStorePassword = "";
48 @Value("${server.ssl.key-store}")
49 private String sslKeyStore = "";
51 @Value("${server.ssl.key-password}")
52 private String sslKeyPassword = "";
54 @Value("${app.webclient.trust-store-used}")
55 private boolean sslTrustStoreUsed = false;
57 @Value("${app.webclient.trust-store-password}")
58 private String sslTrustStorePassword = "";
60 @Value("${app.webclient.trust-store}")
61 private String sslTrustStore = "";
63 @Value("${app.webclient.http.proxy-host:\"\"}")
64 private String httpProxyHost = "";
66 @Value("${app.webclient.http.proxy-port:0}")
67 private int httpProxyPort = 0;
69 private WebClientConfig webClientConfig = null;
71 public WebClientConfig getWebClientConfig() {
72 if (this.webClientConfig == null) {
73 if (this.httpProxyPort == 0) {
74 logger.info("Http proxy is not used");
76 logger.info("Http proxy is used for RAN access {}:{}", httpProxyHost, httpProxyPort);
78 HttpProxyConfig httpProxyConfig = ImmutableHttpProxyConfig.builder() //
79 .httpProxyHost(this.httpProxyHost) //
80 .httpProxyPort(this.httpProxyPort) //
82 this.webClientConfig = ImmutableWebClientConfig.builder() //
83 .keyStoreType(this.sslKeyStoreType) //
84 .keyStorePassword(this.sslKeyStorePassword) //
85 .keyStore(this.sslKeyStore) //
86 .keyPassword(this.sslKeyPassword) //
87 .isTrustStoreUsed(this.sslTrustStoreUsed) //
88 .trustStore(this.sslTrustStore) //
89 .trustStorePassword(this.sslTrustStorePassword) //
90 .httpProxyConfig(httpProxyConfig) //
93 return this.webClientConfig;