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