summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/application.properties22
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/AAIConfiguration.java7
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringServiceImpl.java4
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java16
4 files changed, 35 insertions, 14 deletions
diff --git a/config/application.properties b/config/application.properties
index c1645a2..a3cc78b 100644
--- a/config/application.properties
+++ b/config/application.properties
@@ -1,8 +1,20 @@
+# Copyright © 2018 Amdocs
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
spring.jersey.type=filter
spring.mvc.urls=swagger,docs,prometheus,auditevents,info,heapdump,autoconfig,beans,loggers,dump,env,trace,health,configprops,mappings,metrics,webjars
-
server.contextPath=/aaicontextbuilder
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
@@ -14,11 +26,11 @@ server.tomcat.max-threads=200
server.tomcat.min-spare-threads=25
# AAI REST Client Configuration
-aai.serviceName=10.147.57.139
-aai.servicePort=8080
+aai.serviceName=10.12.6.120
+aai.servicePort=30233
aai.username=AAI
aai.password=OBF:1gfr1ev31gg7
-aai.httpProtocol=http
+aai.httpProtocol=https
aai.connectionTimeout=5000
aai.readTimeout=1000
@@ -29,7 +41,5 @@ http.password=OBF:1u2a1toa1w8v1tok1u30
# {0} = customerId {1} = serviceType {2} = serviceInstanceId
aai.serviceInstancePath=/aai/v11/business/customers/customer/{0}/service-subscriptions/service-subscription/{1}/service-instances/service-instance/{2}
-
-
#Servlet context parameters
server.context_parameters.p-name=value #context parameter with p-name as key and value as value.
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/AAIConfiguration.java b/src/main/java/org/onap/pomba/contextbuilder/aai/AAIConfiguration.java
index 98370bd..9c6d11d 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/aai/AAIConfiguration.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/AAIConfiguration.java
@@ -76,6 +76,13 @@ public class AAIConfiguration {
return ("Basic " + encodedAuth);
}
+ @Bean(name="aaiBasicAuthorization")
+ public String getAAIBasicAuth() {
+ String auth = new String(this.username + ":" + Password.deobfuscate(this.password));
+ String encodedAuth = Base64.getEncoder().encodeToString(auth.getBytes());
+ return ("Basic " + encodedAuth);
+ }
+
@Bean(name="aaiClient")
public RestClient restClient() {
RestClient restClient = new RestClient();
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringServiceImpl.java b/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringServiceImpl.java
index 9a542a4..ff09e55 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringServiceImpl.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringServiceImpl.java
@@ -37,6 +37,8 @@ public class SpringServiceImpl implements SpringService {
private String aaiBaseUrl;
@Autowired
private String aaiServiceInstancePath;
+ @Autowired
+ private String aaiBasicAuthorization;
public SpringServiceImpl() {
// needed for instantiation
@@ -53,7 +55,7 @@ public class SpringServiceImpl implements SpringService {
// Retrieve the service instance information from AAI
try {
- context= RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiServiceInstancePath, tranId, serviceInstanceId, modelVersionId, modelInvariantId, serviceType, customerId);
+ context= RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiServiceInstancePath, tranId, serviceInstanceId, modelVersionId, modelInvariantId, serviceType, customerId,aaiBasicAuthorization);
} catch (AuditException ae) {
throw ae;
} catch (Exception e) {
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java b/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
index a997ebc..da7d241 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
@@ -83,6 +83,7 @@ public class RestUtil {
private static final String DELIMITER = "$";
private static final String DEPTH = "?depth=2";
+
/**
* Validates the URL parameter.
*
@@ -162,7 +163,7 @@ public class RestUtil {
*/
public static ModelContext retrieveAAIModelData(RestClient aaiClient, String baseURL, String aaiServiceInstancePath,
String transactionId, String serviceInstanceId, String modelVersionId, String modelInvariantId,
- String serviceType, String customerId) throws AuditException {
+ String serviceType, String customerId, String aaiBasicAuthorization) throws AuditException {
String serviceInstancePayload = null;
String genericVNFPayload = null;
String vnfcPayload = null;
@@ -177,7 +178,7 @@ public class RestUtil {
+ generateServiceInstanceURL(aaiServiceInstancePath, customerId, serviceType, serviceInstanceId);
// Response from service instance API call
serviceInstancePayload =
- getResource(aaiClient, url, transactionId, MediaType.valueOf(MediaType.APPLICATION_XML));
+ getResource(aaiClient, url, aaiBasicAuthorization, transactionId, MediaType.valueOf(MediaType.APPLICATION_JSON));
// Handle the case if the service instance is not found in AAI
if (isEmptyJson(serviceInstancePayload)) {
@@ -197,7 +198,7 @@ public class RestUtil {
String genericVNFURL = baseURL + genericVNFLink + DEPTH;
// Response from generic VNF API call
genericVNFPayload =
- getResource(aaiClient, genericVNFURL, transactionId, MediaType.valueOf(MediaType.APPLICATION_XML));
+ getResource(aaiClient, genericVNFURL, aaiBasicAuthorization, transactionId, MediaType.valueOf(MediaType.APPLICATION_JSON));
if (isEmptyJson(genericVNFPayload)) {
log.info(LogMessages.NOT_FOUND, "GenericVNF with url ", genericVNFLink);
@@ -214,7 +215,7 @@ public class RestUtil {
List<VnfcInstance> vnfcLst = new ArrayList<VnfcInstance>();
for (String vnfcLink : vnfcLinkLst) {
String vnfcURL = baseURL + vnfcLink;
- vnfcPayload = getResource(aaiClient, vnfcURL, transactionId,
+ vnfcPayload = getResource(aaiClient, vnfcURL, aaiBasicAuthorization, transactionId,
MediaType.valueOf(MediaType.APPLICATION_XML));
if (isEmptyJson(vnfcPayload)) {
@@ -410,17 +411,18 @@ public class RestUtil {
@SuppressWarnings("unchecked")
- private static Map<String, List<String>> buildHeaders(String transactionId) {
+ private static Map<String, List<String>> buildHeaders(String aaiBasicAuthorization, String transactionId) {
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.put(TRANSACTION_ID, Collections.singletonList(transactionId));
headers.put(FROM_APP_ID, Collections.singletonList(APP_NAME));
+ headers.put(AUTHORIZATION, Collections.singletonList(aaiBasicAuthorization));
return headers;
}
- private static String getResource(RestClient client, String url, String transId, MediaType mediaType)
+ private static String getResource(RestClient client, String url, String aaiBasicAuthorization, String transId, MediaType mediaType)
throws AuditException {
- OperationResult result = client.get(url, buildHeaders(transId), MediaType.valueOf(MediaType.APPLICATION_JSON));
+ OperationResult result = client.get(url, buildHeaders(aaiBasicAuthorization, transId), MediaType.valueOf(MediaType.APPLICATION_JSON));
if (result.getResultCode() == 200) {
return result.getResult();