From 89f41fc779523f9234635d3e4e4841d316c2a0cf Mon Sep 17 00:00:00 2001 From: Yulian Han Date: Thu, 29 Nov 2018 17:30:55 +0800 Subject: vfc adapter authentication bug fix Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa5f064414 Issue-ID: SO-1256 Signed-off-by: Yulian Han --- .../org/onap/so/adapters/vfc/CXFConfiguration.java | 4 +- .../so/adapters/vfc/WebSecurityConfigImpl.java | 51 ++++++++++ .../scripts/CreateVFCNSResource.groovy | 100 ++++--------------- .../DoCreateVFCNetworkServiceInstance.groovy | 63 +++++++----- .../DoDeleteVFCNetworkServiceInstance.groovy | 110 +++++++++++++-------- 5 files changed, 177 insertions(+), 151 deletions(-) create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java index 031bc2edc5..ea1c3805d1 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java @@ -79,11 +79,11 @@ public class CXFConfiguration { public Swagger2Feature createSwaggerFeature() { Swagger2Feature swagger2Feature = new Swagger2Feature(); swagger2Feature.setPrettyPrint(true); - swagger2Feature.setTitle("SO Request Adapter"); + swagger2Feature.setTitle("SO VFC Adapter"); swagger2Feature.setContact("The ONAP SO team"); swagger2Feature.setDescription("This project is the SO Orchestration Engine"); swagger2Feature.setVersion("1.0.0"); - swagger2Feature.setResourcePackage("org.onap.so.adapters.requestdb"); + swagger2Feature.setResourcePackage("org.onap.so.adapters.vfc.rest"); swagger2Feature.setScan(true); return swagger2Feature; } diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java new file mode 100644 index 0000000000..37a5633d8d --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vfc; + +import org.onap.so.security.MSOSpringFirewall; +import org.onap.so.security.WebSecurityConfig; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.web.firewall.StrictHttpFirewall; +import org.springframework.util.StringUtils; + +@EnableWebSecurity +public class WebSecurityConfigImpl extends WebSecurityConfig { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable() + .authorizeRequests() + .antMatchers("/manage/health","/manage/info","/services").permitAll() + .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(),",").toString()) + .and() + .httpBasic(); + } + + @Override + public void configure(WebSecurity web) throws Exception { + super.configure(web); + StrictHttpFirewall firewall = new MSOSpringFirewall(); + web.httpFirewall(firewall); + } + +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy index 34f2f0157d..94df0a977a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy @@ -39,7 +39,7 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import groovy.json.* //import javax.ws.rs.core.Response -import org.onap.so.utils.TargetEntity +//import org.onap.so.utils.TargetEntity /** * This groovy class supports the DoCreateVFCNetworkServiceInstance.bpmn process. @@ -272,96 +272,30 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { msoLogger.trace("Started Execute VFC adapter Post Process ") msoLogger.info("url:" + urlString +"\nrequestBody:"+ requestBody) APIResponse apiResponse = null -// try{ - -// URL url = new URL(urlString); - -// HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER) -// httpClient.addAdditionalHeader("Accept", "application/json") -// httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") - -// apiResponse = httpClient.post(requestBody) -// msoLogger.info("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class)) - - // Get the Basic Auth credentials for the VFCAdapter (yes... we ARE using the PO adapters credentials) - String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) - - msoLogger.debug("basicAuthValuePO: " + basicAuthValuePO) - if (basicAuthValuePO == null || basicAuthValuePO.isEmpty()) { - msoLogger.debug("mso:adapters:po:auth URN mapping is not defined") - } - - RESTConfig config = new RESTConfig(urlString) - RESTClient client = null; - int statusCode = 0; - try { - client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(basicAuthValuePO) - - apiResponse = client.httpPost(requestBody) + try{ + // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7' + def basicAuthHeaderValue = "" + RESTConfig config = new RESTConfig(urlString) + RESTClient client = null; + int statusCode = 0; - statusCode = apiResponse.getStatusCode() + // user 'bepl' authHeader is the same with mso.db.auth + String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution) + + client = new RESTClient(config) + client.addHeader("Accept", "application/json") + client.addAuthorizationHeader(basicAuthValuedb) + client.addHeader("Content-Type", "application/json") - if(statusCode == 200 || statusCode == 201) { - return apiResponse - } - }catch(Exception e){ - msoLogger.error("VFC Aatpter Post Call Exception using mso.adapters.po.auth:" + e.getMessage()); - } - - msoLogger.debug("response code:"+ statusCode +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) - - msoLogger.debug("VFC Aatpter Post Call using mso.msoKey") - String basicAuthValue = UrnPropertiesReader.getVariable("mso.msoKey", execution) - msoLogger.debug("basicAuthValue: " + basicAuthValue) - if (basicAuthValue == null || basicAuthValue.isEmpty()) { - msoLogger.debug("mso:msoKey URN mapping is not defined") - } - try { - client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(basicAuthValue) - apiResponse = client.httpPost(requestBody) - statusCode = apiResponse.getStatusCode() - if(statusCode == 200 || statusCode == 201) { - return apiResponse - } - }catch(Exception e){ - msoLogger.error("VFC Aatpter Post Call Exception using mso.msoKey:" + e.getMessage()); - - } - - msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) - msoLogger.debug("VFC Aatpter Post Call using mso.db.auth") - String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution) - msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb) - if (basicAuthValuedb == null || basicAuthValuedb.isEmpty()) { - msoLogger.debug("mso:db.auth URN mapping is not defined") - } - try { - client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(basicAuthValuedb) - - apiResponse = client.httpPost(requestBody) - statusCode = apiResponse.getStatusCode() - - if(statusCode == 200 || statusCode == 201) { - return apiResponse - } }catch(Exception e){ - msoLogger.error("VFC Aatpter Post Call Exception using mso.msoKey:" + e.getMessage()); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VFC Aatpter Post Call Exception by using mso.msoKey or mso.adapters.po.auth") + msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage()); + throw new BpmnError("MSOWorkflowException") } - - - msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) - String auth = "Basic QlBFTENsaWVudDpwYXNzd29yZDEk" - msoLogger.debug("auth: " + basicAuthValuedb) - client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(auth) - - apiResponse = client.httpPost(requestBody) - - msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) msoLogger.trace("Completed Execute VF-C adapter Post Process ") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy index f4a542afe9..0502f7949a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy @@ -28,15 +28,18 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.HttpClient +//import org.onap.so.client.HttpClient import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.utils.TargetEntity +//import org.onap.so.utils.TargetEntity import groovy.json.* -import javax.ws.rs.core.Response +//import javax.ws.rs.core.Response /** * This groovy class supports the DoCreateVFCNetworkServiceInstance.bpmn process. @@ -138,7 +141,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces "nsOperationKey":${nsOperationKey}, "nsParameters":${nsParameters} }""" - Response apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody) + APIResponse apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody) String returnCode = apiResponse.getStatus() String aaiResponseAsString = apiResponse.readEntity(String.class) String nsInstanceId = ""; @@ -167,7 +170,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces }""" String nsInstanceId = execution.getVariable("nsInstanceId") String url = vfcAdapterUrl + "/ns/" +nsInstanceId + "/instantiate" - Response apiResponse = postRequest(execution, url, reqBody) + APIResponse apiResponse = postRequest(execution, url, reqBody) String returnCode = apiResponse.getStatus() String aaiResponseAsString = apiResponse.readEntity(String.class) String jobId = ""; @@ -187,7 +190,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces String jobId = execution.getVariable("jobId") String nsOperationKey = execution.getVariable("nsOperationKey"); String url = vfcAdapterUrl + "/jobs/" + jobId - Response apiResponse = postRequest(execution, url, nsOperationKey) + APIResponse apiResponse = postRequest(execution, url, nsOperationKey) String returnCode = apiResponse.getStatus() String aaiResponseAsString = apiResponse.readEntity(String.class) String operationStatus = "error" @@ -240,26 +243,38 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces * url: the url of the request * requestBody: the body of the request */ - private Response postRequest(DelegateExecution execution, String urlString, String requestBody){ + private APIResponse postRequest(DelegateExecution execution, String urlString, String requestBody){ msoLogger.trace("Started Execute VFC adapter Post Process") msoLogger.debug("url:"+urlString +"\nrequestBody:"+ requestBody) - Response apiResponse = null - try{ - - URL url = new URL(urlString); - - HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER) - httpClient.addAdditionalHeader("Accept", "application/json") - httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") - - apiResponse = httpClient.post(requestBody) - - msoLogger.debug("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class)) - msoLogger.trace("Completed Execute VF-C adapter Post Process") - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); - throw new BpmnError("MSOWorkflowException") - } + APIResponse apiResponse = null + try{ + // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7' + def basicAuthHeaderValue = "" + RESTConfig config = new RESTConfig(urlString) + RESTClient client = null; + int statusCode = 0; + + // user 'bepl' authHeader is the same with mso.db.auth + String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution) + msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb) + + client = new RESTClient(config) + client.addHeader("Accept", "application/json") + client.addAuthorizationHeader(basicAuthValuedb) + client.addHeader("Content-Type", "application/json") + + apiResponse = client.httpPost(requestBody) + statusCode = apiResponse.getStatusCode() + + msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + + }catch(Exception e){ + msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage()); + throw new BpmnError("MSOWorkflowException") + } + + msoLogger.trace("Completed Execute VF-C adapter Post Process ") + return apiResponse } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy index e0586163f1..5ff93363d2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy @@ -25,16 +25,19 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.HttpClient +//import org.onap.so.client.HttpClient import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger -import org.onap.so.utils.TargetEntity +import org.onap.so.rest.APIResponse +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig +//import org.onap.so.utils.TargetEntity import org.onap.so.bpmn.core.UrnPropertiesReader -import javax.ws.rs.core.Response +//import javax.ws.rs.core.Response /** * This groovy class supports the DoDeleteVFCNetworkServiceInstance.bpmn process. * flow for E2E ServiceInstance Delete @@ -136,8 +139,9 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl") String nsOperationKey = execution.getVariable("nsOperationKey"); String url = vfcAdapterUrl + "/ns/" + execution.getVariable("nsInstanceId") - Response apiResponse = deleteRequest(execution, url, nsOperationKey) - String returnCode = apiResponse.getStatus() + APIResponse apiResponse = deleteRequest(execution, url, nsOperationKey) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() String operationStatus = "error"; if(returnCode== "200" || returnCode== "202"){ operationStatus = "finished" @@ -148,7 +152,7 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces } /** - * instantiate NS task + * terminate NS task */ public void terminateNetworkService(DelegateExecution execution) { @@ -156,9 +160,9 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl") String nsOperationKey = execution.getVariable("nsOperationKey") String url = vfcAdapterUrl + "/ns/" + execution.getVariable("nsInstanceId") + "/terminate" - Response apiResponse = postRequest(execution, url, nsOperationKey) - String returnCode = apiResponse.getStatus() - String aaiResponseAsString = apiResponse.readEntity(String.class) + APIResponse apiResponse = postRequest(execution, url, nsOperationKey) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() String jobId = ""; if(returnCode== "200" || returnCode== "202"){ jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId") @@ -177,9 +181,9 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces String jobId = execution.getVariable("jobId") String nsOperationKey = execution.getVariable("nsOperationKey"); String url = vfcAdapterUrl + "/jobs/" + execution.getVariable("jobId") - Response apiResponse = postRequest(execution, url, nsOperationKey) - String returnCode = apiResponse.getStatus() - String apiResponseAsString = apiResponse.readEntity(String.class) + APIResponse apiResponse = postRequest(execution, url, nsOperationKey) + String returnCode = apiResponse.getStatusCode() + String apiResponseAsString = apiResponse.getResponseBodyAsString() String operationProgress = "100" if(returnCode== "200"){ operationProgress = jsonUtil.getJsonValue(apiResponseAsString, "responseDescriptor.progress") @@ -211,25 +215,34 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces * url: the url of the request * requestBody: the body of the request */ - private Response postRequest(DelegateExecution execution, String urlString, String requestBody){ + private APIResponse postRequest(DelegateExecution execution, String urlString, String requestBody){ msoLogger.trace("Started Execute VFC adapter Post Process ") msoLogger.info("url:"+urlString +"\nrequestBody:"+ requestBody) - Response apiResponse = null + APIResponse apiResponse = null try{ - URL url = new URL(urlString); - - HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER) - httpClient.addAdditionalHeader("Accept", "application/json") - httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") - - apiResponse = httpClient.post(requestBody) - - msoLogger.debug("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class)) - - msoLogger.trace("Completed Execute VF-C adapter Post Process ") + // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7' + def basicAuthHeaderValue = "" + RESTConfig config = new RESTConfig(urlString) + RESTClient client = null; + int statusCode = 0; + + // user 'bepl' authHeader is the same with mso.db.auth + String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution) + msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb) + + client = new RESTClient(config) + client.addHeader("Accept", "application/json") + client.addAuthorizationHeader(basicAuthValuedb) + client.addHeader("Content-Type", "application/json") + + apiResponse = client.httpPost(requestBody) + statusCode = apiResponse.getStatusCode() + + msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage()); throw new BpmnError("MSOWorkflowException") } return apiResponse @@ -239,24 +252,37 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces * url: the url of the request * requestBody: the body of the request */ - private Response deleteRequest(DelegateExecution execution, String url, String requestBody){ + private APIResponse deleteRequest(DelegateExecution execution, String url, String requestBody){ msoLogger.trace("Started Execute VFC adapter Delete Process ") msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody) - Response r - try{ - - URL Url = new URL(url) - HttpClient httpClient = new HttpClient(Url, "application/json", TargetEntity.VNF_ADAPTER) - httpClient.addAdditionalHeader("Accept", "application/json") - httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") - r = httpClient.delete(requestBody) - - msoLogger.trace("Completed Execute VF-C adapter Delete Process ") - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); - throw new BpmnError("MSOWorkflowException") - } - return r + + APIResponse apiResponse = null + try{ + // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7' + def basicAuthHeaderValue = "" + RESTConfig config = new RESTConfig(url) + RESTClient client = null; + int statusCode = 0; + + // user 'bepl' authHeader is the same with mso.db.auth + String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution) + msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb) + + client = new RESTClient(config) + client.addHeader("Accept", "application/json") + client.addAuthorizationHeader(basicAuthValuedb) + client.addHeader("Content-Type", "application/json") + + apiResponse = client.httpDelete(requestBody) + statusCode = apiResponse.getStatusCode() + + msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + + }catch(Exception e){ + msoLogger.error("Exception occured while executing VF-C Delete Call. Exception is: \n" + e.getMessage()); + throw new BpmnError("MSOWorkflowException") + } + return apiResponse } } -- cgit 1.2.3-korg