fedb64c1949e5cc71b982735a56d20b261a39dce
[sdnc/apps.git] /
1 /*
2  * ============LICENSE_START===================================================
3  * Copyright (c) 2018 Amdocs
4  * ============================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * 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
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END=====================================================
17  */
18 package org.onap.sdnc.apps.pomba.servicedecomposition;
19
20 import org.onap.aai.restclient.client.RestClient;
21 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.beans.factory.annotation.Value;
23 import org.springframework.context.annotation.Bean;
24 import org.springframework.stereotype.Component;
25
26 @Component
27 public class AAIConfiguration {
28     @Autowired
29     @Value("${aai.host}")
30     private String host;
31
32     @Autowired
33     @Value("${aai.port}")
34     private String port;
35
36     @Autowired
37     @Value("${aai.httpProtocol}")
38     private String httpProtocol;
39
40     @Autowired
41     @Value("${aai.trustStorePath}")
42     private String trustStorePath;
43
44     @Autowired
45     @Value("${aai.keyStorePath}")
46     private String keyStorePath;
47
48     @Autowired
49     @Value("${aai.keyStorePassword}")
50     private String keyStorePassword;
51
52     @Autowired
53     @Value("${aai.keyManagerFactoryAlgorithm}")
54     private String keyManagerFactoryAlgorithm;
55
56     @Autowired
57     @Value("${aai.keyStoreType}")
58     private String keyStoreType;
59
60     @Autowired
61     @Value("${aai.securityProtocol}")
62     private String securityProtocol;
63
64     @Autowired
65     @Value("${aai.connectionTimeout}")
66     private Integer connectionTimeout;
67
68     @Autowired
69     @Value("${aai.readTimeout}")
70     private Integer readTimeout;
71
72     @Autowired
73     @Value("${aai.serviceInstancePath}")
74     private String serviceInstancePath;
75
76     @Bean(name="aaiClient")
77     public RestClient restClient() {
78         return new RestClient()
79                 .validateServerHostname(false)
80                 .validateServerCertChain(false)
81                 .connectTimeoutMs(this.connectionTimeout)
82                 .readTimeoutMs(this.readTimeout);
83     }
84
85     @Bean(name="aaiBaseUrl")
86     public String getURL() {
87         return this.httpProtocol + "://" + this.host + ":" + this.port;
88     }
89
90     @Bean(name="aaiServiceInstancePath")
91     public String getServiceInstancePath() {
92         return this.serviceInstancePath;
93     }
94
95 }