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
9 * http://www.apache.org/licenses/LICENSE-2.0
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=====================================================
18 package org.onap.sdnc.apps.pomba.servicedecomposition;
20 import java.util.Base64;
21 import org.eclipse.jetty.util.security.Password;
22 import org.onap.aai.restclient.client.RestClient;
23 import org.springframework.beans.factory.annotation.Value;
24 import org.springframework.context.annotation.Bean;
25 import org.springframework.stereotype.Component;
28 public class AAIConfiguration {
29 @Value("${aai.serviceName}")
32 @Value("${aai.servicePort}")
35 @Value("${aai.username}")
36 private String aaiUsername;
38 @Value("${aai.password}")
39 private String aaiPassword;
41 @Value("${aai.httpProtocol}")
42 private String httpProtocol;
44 @Value("${aai.securityProtocol}")
45 private String securityProtocol;
47 @Value("${aai.connectionTimeout}")
48 private Integer connectionTimeout;
50 @Value("${aai.readTimeout}")
51 private Integer readTimeout;
53 @Value("${aai.serviceInstancePath}")
54 private String serviceInstancePath;
56 @Value("${aai.resourceList}")
57 private String resourceList;
59 @Value("${basicAuth.username:admin}")
60 private String username;
62 @Value("${basicAuth.password:OBF:1u2a1toa1w8v1tok1u30}")
63 private String password;
65 @Bean(name="aaiBasicAuthorization")
66 public String getAAIBasicAuth() {
67 return "Basic " + Base64.getEncoder().encodeToString((this.aaiUsername + ":" + Password.deobfuscate(this.aaiPassword)).getBytes());
70 @Bean(name="basicAuthHeader")
71 public String getSdBasicAuthHeader() {
72 return "Basic " + Base64.getEncoder().encodeToString((this.username + ":" + Password.deobfuscate(this.password)).getBytes());
75 @Bean(name="aaiClient")
76 public RestClient restClient() {
77 return new RestClient()
78 .validateServerHostname(false)
79 .validateServerCertChain(false)
80 .basicAuthPassword(aaiUsername)
81 .basicAuthPassword(Password.deobfuscate(aaiPassword))
82 .connectTimeoutMs(this.connectionTimeout)
83 .readTimeoutMs(this.readTimeout);
86 @Bean(name="aaiBaseUrl")
87 public String getURL() {
88 return this.httpProtocol + "://" + this.host + ":" + this.port;
91 @Bean(name="aaiServiceInstancePath")
92 public String getServiceInstancePath() {
93 return this.serviceInstancePath;
96 @Bean(name="aaiResourceList")
97 public String getResourceList() {
98 return this.resourceList;