214c4d1c3df434d2b6b569216f59065a1c512b39
[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     @Value("${aai.host}")
29     private String host;
30
31     @Value("${aai.port}")
32     private String port;
33
34     @Value("${aai.httpProtocol}")
35     private String httpProtocol;
36
37     @Value("${aai.trustStorePath}")
38     private String trustStorePath;
39
40     @Value("${aai.keyStorePath}")
41     private String keyStorePath;
42
43     @Value("${aai.keyStorePassword}")
44     private String keyStorePassword;
45
46     @Value("${aai.keyManagerFactoryAlgorithm}")
47     private String keyManagerFactoryAlgorithm;
48
49     @Value("${aai.keyStoreType}")
50     private String keyStoreType;
51
52     @Value("${aai.securityProtocol}")
53     private String securityProtocol;
54
55     @Value("${aai.connectionTimeout}")
56     private Integer connectionTimeout;
57
58     @Value("${aai.readTimeout}")
59     private Integer readTimeout;
60
61     @Value("${aai.serviceInstancePath}")
62     private String serviceInstancePath;
63
64     @Value("${aai.resourceList}")
65     private String resourceList;
66
67     @Bean(name="aaiClient")
68     public RestClient restClient() {
69         return new RestClient()
70                 .validateServerHostname(false)
71                 .validateServerCertChain(false)
72                 .connectTimeoutMs(this.connectionTimeout)
73                 .readTimeoutMs(this.readTimeout);
74     }
75
76     @Bean(name="aaiBaseUrl")
77     public String getURL() {
78         return this.httpProtocol + "://" + this.host + ":" + this.port;
79     }
80
81     @Bean(name="aaiServiceInstancePath")
82     public String getServiceInstancePath() {
83         return this.serviceInstancePath;
84     }
85
86     @Bean(name="aaiResourceList")
87     public String getResourceList() {
88         return this.resourceList;
89     }
90 }