summaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/main/java/org/onap
diff options
context:
space:
mode:
authorKeguang He <hekeguang@chinamobile.com>2022-09-01 09:25:19 +0000
committerGerrit Code Review <gerrit@onap.org>2022-09-01 09:25:19 +0000
commitbecebf63bae4001abad04bb0149498f6d4b88ed1 (patch)
treef677a1b62d7ce16e6fb3224342a0cc35e66253a7 /intentanalysis/src/main/java/org/onap
parente39a0b1353a299f379a37e511ede6d2ff85237c1 (diff)
parentdb20b5e4f99037a64eb1341f3aff584ac2781b61 (diff)
Merge "fix authorization hard coding issue"
Diffstat (limited to 'intentanalysis/src/main/java/org/onap')
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAPICall.java11
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAuthConfig.java33
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAPICall.java17
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAuthConfig.java33
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java37
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/CCVPNInstance.java15
6 files changed, 131 insertions, 15 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAPICall.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAPICall.java
index ead4d2c..db89ed6 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAPICall.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAPICall.java
@@ -18,8 +18,19 @@ package org.onap.usecaseui.intentanalysis.adapters.aai.apicall;
import com.alibaba.fastjson.JSONObject;
import retrofit2.Call;
import retrofit2.http.GET;
+import retrofit2.http.Headers;
+import retrofit2.http.Path;
public interface AAIAPICall {
@GET("/aai/v24/network/network-routes")
Call<JSONObject> queryNetworkRoute();
+
+ @Headers({
+ "X-TransactionId: 9999",
+ "X-FromAppId: MSO",
+ "Content-Type: application/json",
+ "Accept: application/json"
+ })
+ @GET("/aai/v24/business/customers/customer/IBNCustomer/service-subscriptions/service-subscription/IBN/service-instances/service-instance/{resource-service-id}")
+ Call<JSONObject> getInstanceInfo(@Path("resource-service-id") String resourceServiceId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAuthConfig.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAuthConfig.java
new file mode 100644
index 0000000..7e85e40
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAuthConfig.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2022 Huawei Technologies Co., Ltd.
+ *
+ * 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.
+ */
+package org.onap.usecaseui.intentanalysis.adapters.aai.apicall;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+@Getter
+@Setter
+public class AAIAuthConfig {
+
+ @Value("${rest.aai.username}")
+ private String userName;
+
+ @Value("${rest.aai.password}")
+ private String password;
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAPICall.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAPICall.java
index 11fae26..cd07292 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAPICall.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAPICall.java
@@ -22,26 +22,19 @@ import retrofit2.http.*;
public interface SOAPICall {
@Headers({
- "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==",
- "Accept: application/json"
+ "Accept: application/json",
+ "Content-Type: application/json"
})
@POST("/so/infra/serviceIntent/v1/create")
Call<JSONObject> createIntentInstance(@Body RequestBody body);
@Headers({
- "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==",
- "Accept: application/json"
+ "Accept: application/json",
+ "Content-Type: application/json"
})
@HTTP(method="DELETE", path="/so/infra/serviceIntent/v1/delete", hasBody = true)
Call<JSONObject> deleteIntentInstance(@Body RequestBody body);
- @Headers({
- "X-TransactionId: 9999",
- "X-FromAppId: MSO",
- "Authorization: Basic QUFJOkFBSQ==",
- "Accept: application/json"
- })
- @GET("/aai/v24/business/customers/customer/IBNCustomer/service-subscriptions/service-subscription/IBN/service-instances/service-instance/{resource-service-id}")
- Call<JSONObject> getInstanceInfo(@Path("resource-service-id") String resourceServiceId);
+
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAuthConfig.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAuthConfig.java
new file mode 100644
index 0000000..042be41
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAuthConfig.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2022 Huawei Technologies Co., Ltd.
+ *
+ * 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.
+ */
+package org.onap.usecaseui.intentanalysis.adapters.so.apicall;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+@Getter
+@Setter
+public class SOAuthConfig {
+
+ @Value("${rest.so.username}")
+ private String userName;
+
+ @Value("${rest.so.password}")
+ private String password;
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java
index 7f34584..e4e1f60 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java
@@ -18,11 +18,18 @@ package org.onap.usecaseui.intentanalysis.adapters.so.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import org.onap.usecaseui.intentanalysis.adapters.aai.apicall.AAIAPICall;
+import org.onap.usecaseui.intentanalysis.adapters.aai.apicall.AAIAuthConfig;
+import org.onap.usecaseui.intentanalysis.adapters.policy.apicall.PolicyAPICall;
+import org.onap.usecaseui.intentanalysis.adapters.policy.apicall.PolicyAuthConfig;
import org.onap.usecaseui.intentanalysis.adapters.so.SOService;
import org.onap.usecaseui.intentanalysis.adapters.so.apicall.SOAPICall;
+import org.onap.usecaseui.intentanalysis.adapters.so.apicall.SOAuthConfig;
import org.onap.usecaseui.intentanalysis.bean.models.CCVPNInstance;
+import org.onap.usecaseui.intentanalysis.util.RestfulServices;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import retrofit2.Response;
import java.io.IOException;
import java.util.ArrayList;
@@ -37,6 +44,30 @@ public class SOServiceImpl implements SOService {
private SOAPICall soapiCall;
+ private AAIAPICall aaiapiCall;
+
+ @Autowired
+ SOAuthConfig soAuthConfig;
+
+ @Autowired
+ AAIAuthConfig aaiAuthConfig;
+
+ public SOAPICall getSoApiCall() {
+ if (null == soapiCall) {
+ this.soapiCall = RestfulServices.create(SOAPICall.class, soAuthConfig.getUserName(),
+ soAuthConfig.getPassword());
+ }
+ return this.soapiCall;
+ }
+
+ public AAIAPICall getAaiApiCall() {
+ if (null == aaiapiCall) {
+ this.aaiapiCall = RestfulServices.create(AAIAPICall.class, aaiAuthConfig.getUserName(),
+ aaiAuthConfig.getPassword());
+ }
+ return this.aaiapiCall;
+ }
+
@Override
public int createCCVPNInstance(CCVPNInstance ccvpnInstance) {
try{
@@ -81,7 +112,7 @@ public class SOServiceImpl implements SOService {
Map<String, Object> params = paramsSetUp(ccvpnInstance);
params.put("additionalProperties",additionalPropertiesSetUp(ccvpnInstance));
okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params));
- Response<JSONObject> response = soapiCall.createIntentInstance(requestBody).execute();
+ Response<JSONObject> response = getSoApiCall().createIntentInstance(requestBody).execute();
if (response.isSuccessful()) {
return response.body().getString("jobId");
}
@@ -98,14 +129,14 @@ public class SOServiceImpl implements SOService {
additionalProperties.put("enableSdnc", "true");
params.put("additionalProperties", additionalProperties);
okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params));
- soapiCall.deleteIntentInstance(requestBody).execute();
+ getSoApiCall().deleteIntentInstance(requestBody).execute();
}
private int getCreateStatus(CCVPNInstance ccvpnInstance) throws IOException {
if (ccvpnInstance == null || ccvpnInstance.getResourceInstanceId() == null) {
return -1;
}
- Response<JSONObject> response = soapiCall.getInstanceInfo(ccvpnInstance.getResourceInstanceId()).execute();
+ Response<JSONObject> response = getAaiApiCall().getInstanceInfo(ccvpnInstance.getResourceInstanceId()).execute();
logger.debug(response.toString());
if (response.isSuccessful()) {
String status = response.body().getString("orchestration-status");
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/CCVPNInstance.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/CCVPNInstance.java
index b5d73f1..468725d 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/CCVPNInstance.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/CCVPNInstance.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2022 Huawei Technologies Co., Ltd.
+ *
+ * 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.
+ */
package org.onap.usecaseui.intentanalysis.bean.models;
import lombok.Data;