diff options
author | mukesh.paliwal <mukesh.paliwal1@huawei.com> | 2021-02-18 12:10:22 +0530 |
---|---|---|
committer | mukesh.paliwal <mukesh.paliwal1@huawei.com> | 2021-02-18 12:10:22 +0530 |
commit | 48997934fa955d2b89eab9742634e4251113e6bf (patch) | |
tree | c62eac0e871fdf30d9ba6b6bc48e2819a51fb0dc /adapters/mso-oof-adapter/src/main/java | |
parent | 55365a40012d165d73e842f3f9871364a567f64f (diff) |
Remove mso-oof-adapter from SO
Issue-ID: SO-3537
Signed-off-by: mukesh.paliwal <mukesh.paliwal1@huawei.com>
Change-Id: I79b1c1f6f355fb584e30253bedf7ca5ede02e336
Diffstat (limited to 'adapters/mso-oof-adapter/src/main/java')
9 files changed, 0 insertions, 515 deletions
diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/MsoOofAdapterApplication.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/MsoOofAdapterApplication.java deleted file mode 100644 index 78fbe6e271..0000000000 --- a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/MsoOofAdapterApplication.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Wipro Limited. 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.oof; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class MsoOofAdapterApplication { - - public static void main(String[] args) { - SpringApplication.run(MsoOofAdapterApplication.class, args); - } -} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/OofAdapterClientConfig.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/OofAdapterClientConfig.java deleted file mode 100644 index 5e13c592b7..0000000000 --- a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/OofAdapterClientConfig.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Wipro Limited. 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.oof; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import org.apache.http.client.HttpClient; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.impl.client.HttpClients; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.web.client.RestTemplate; - -@Configuration -public class OofAdapterClientConfig { - - @Bean - public RestTemplate getRestTemplate() { - HttpComponentsClientHttpRequestFactory requestFactory = - new HttpComponentsClientHttpRequestFactory(getHttpsClient()); - requestFactory.setConnectTimeout(60000); - requestFactory.setReadTimeout(60000); - return new RestTemplate(requestFactory); - } - - private HttpClient getHttpsClient() { - TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - - public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {} - - public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {} - }}; - - // Install the all-trusting trust manager - try { - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - HostnameVerifier hostnameVerifier = new HostnameVerifier() { - @Override - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sc, - new String[] {"TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"}, null, hostnameVerifier); - return HttpClients.custom().setSSLSocketFactory(sslsf).build(); - } catch (Exception e) { - throw new IllegalArgumentException(e); - } - } -} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/WebSecurityConfig.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/WebSecurityConfig.java deleted file mode 100644 index 9a07b0119f..0000000000 --- a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/WebSecurityConfig.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Wipro Limited. 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.oof; - -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -@EnableWebSecurity -@Configuration -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable(); - } - -} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/constants/Constants.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/constants/Constants.java deleted file mode 100644 index 5d91bf38f8..0000000000 --- a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/constants/Constants.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Wipro Limited. 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.oof.constants; - -public class Constants { - - public static final String OOF_ENDPOINT = "mso.oof.endpoint"; - public static final String OOF_AUTH = "mso.oof.auth"; - public static final String MSO_KEY = "mso.msoKey"; - public static final String CAMUNDA_URL = "mso.camundaURL"; - public static final String CAMUNDA_AUTH = "mso.camundaAuth"; - public static final String WORKFLOW_MESSAGE_ENPOINT = "mso.workflow.message.endpoint"; - -} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/exceptions/OofAdapterException.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/exceptions/OofAdapterException.java deleted file mode 100644 index ff16d7442c..0000000000 --- a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/exceptions/OofAdapterException.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Wipro Limited. 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.oof.exceptions; - -public class OofAdapterException extends Exception { - - private static final long serialVersionUID = 1L; - - public OofAdapterException(String message) { - super(message); - } - - public OofAdapterException(Throwable e) { - super(e); - } - - public OofAdapterException(String message, Throwable e) { - super(message, e); - } - -} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/model/OofRequest.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/model/OofRequest.java deleted file mode 100644 index 1eb694fd96..0000000000 --- a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/model/OofRequest.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Wipro Limited. 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.oof.model; - -/** - * POJO representing generic request payload from BPMN processes - */ -public class OofRequest { - - private String apiPath; - - private Object requestDetails; - - public String getApiPath() { - return apiPath; - } - - public void setApiPath(String apiPath) { - this.apiPath = apiPath; - } - - public Object getRequestDetails() { - return requestDetails; - } - - public void setRequestDetails(Object requestDetails) { - this.requestDetails = requestDetails; - } - - @Override - public String toString() { - return "{\"apiPath:\"\"" + apiPath + "\"\", requestDetails:\"\"" + requestDetails + "}"; - } - -} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofCallbackHandler.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofCallbackHandler.java deleted file mode 100644 index f8da6c6d2e..0000000000 --- a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofCallbackHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Wipro Limited. 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.oof.rest; - -import org.onap.so.adapters.oof.exceptions.OofAdapterException; -import org.onap.so.adapters.oof.utils.OofUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpEntity; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; - -/** - * A generic call back handler to receive async response from OOF - */ -@RestController -@RequestMapping("/so/adapters/oof/callback/") -public class OofCallbackHandler { - - @Autowired - OofUtils utils; - - @Autowired - RestTemplate restTemplate; - - private static final Logger logger = LoggerFactory.getLogger(OofCallbackHandler.class); - - @PostMapping("/{version:[vV][1]}/{messageEventName}/{correlator}") - public ResponseEntity<String> processCallback(@PathVariable("messageEventName") String messageEventName, - @PathVariable("correlator") String correlator, @RequestBody String oofCallbackRequest) - throws OofAdapterException { - logger.debug("Oof Async response received for event : {} , callback request body : {} ", messageEventName, - oofCallbackRequest); - String camundaMsgUrl = utils.getCamundaMsgUrl(messageEventName, correlator); - HttpEntity<String> request = new HttpEntity<String>(oofCallbackRequest, utils.getCamundaHeaders()); - try { - ResponseEntity<String> response = restTemplate.postForEntity(camundaMsgUrl, request, String.class); - logger.debug("Response from BPMN : {} ", response); - return response; - } catch (Exception e) { - logger.warn("Error injecting message event into BPMN {} {} ", e.getCause(), e.getMessage()); - throw new OofAdapterException(e); - } - - } - -} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofClient.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofClient.java deleted file mode 100644 index 3a91ec495e..0000000000 --- a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofClient.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Wipro Limited. 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.oof.rest; - -import org.onap.so.adapters.oof.exceptions.OofAdapterException; -import org.onap.so.adapters.oof.model.OofRequest; -import org.onap.so.adapters.oof.utils.OofUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpEntity; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; - -/** - * A generic client class to call OOF with request from BPMN - */ -@RestController -@RequestMapping("/so/adapters/oof/") -public class OofClient { - - @Autowired - RestTemplate restTemplate; - - @Autowired - OofUtils utils; - - private static final Logger logger = LoggerFactory.getLogger(OofClient.class); - - @PostMapping("/{version:[vV][1]}") - public ResponseEntity<String> callOof(@RequestBody OofRequest oofRequest) throws OofAdapterException { - try { - logger.debug("Received Request from BPEL {} ", oofRequest); - String oofUrl = utils.getOofurl(oofRequest.getApiPath()); - HttpEntity<?> request = new HttpEntity<>(oofRequest.getRequestDetails(), utils.getOofHttpHeaders()); - ResponseEntity<String> response = restTemplate.postForEntity(oofUrl, request, String.class); - logger.debug("Response from OOF : {} ", response); - return response; - } catch (Exception e) { - logger.warn("Error while calling OOF {} {} ", e.getCause(), e.getMessage()); - throw new OofAdapterException(e); - } - } - -} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/utils/OofUtils.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/utils/OofUtils.java deleted file mode 100644 index f45baa30fe..0000000000 --- a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/utils/OofUtils.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Wipro Limited. 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.oof.utils; - -import java.security.GeneralSecurityException; -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.DatatypeConverter; -import org.onap.so.adapters.oof.constants.Constants; -import org.onap.so.utils.CryptoUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; - -@Component -public class OofUtils { - private static Logger logger = LoggerFactory.getLogger(OofUtils.class); - - @Autowired - private Environment env; - - /** - * @param messageEventName - * @param correlator - * @return - */ - public String getCamundaMsgUrl(String messageEventName, String correlator) { - System.out.println(env); - String camundaMsgUrl = new StringBuilder(env.getRequiredProperty(Constants.WORKFLOW_MESSAGE_ENPOINT)) - .append("/").append(messageEventName).append("/").append(correlator).toString(); - return camundaMsgUrl; - } - - /** - * @return - */ - public HttpHeaders getCamundaHeaders() { - HttpHeaders headers = new HttpHeaders(); - List<MediaType> acceptableMediaTypes = new ArrayList<>(); - acceptableMediaTypes.add(MediaType.ALL); - headers.setAccept(acceptableMediaTypes); - headers.setContentType(MediaType.APPLICATION_JSON); - headers.add(HttpHeaders.AUTHORIZATION, addAuthorizationHeader(env.getRequiredProperty(Constants.CAMUNDA_AUTH), - env.getRequiredProperty(Constants.MSO_KEY))); - return headers; - } - - /** - * @param auth - * @param msoKey - * @return - */ - protected String addAuthorizationHeader(String auth, String msoKey) { - String basicAuth = null; - try { - String userCredentials = CryptoUtils.decrypt(auth, msoKey); - if (userCredentials != null) { - basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); - } - } catch (GeneralSecurityException e) { - logger.error("Security exception", e); - } - return basicAuth; - } - - /** - * @return - * @throws Exception - */ - public HttpHeaders getOofHttpHeaders() throws Exception { - HttpHeaders headers = new HttpHeaders(); - List<MediaType> acceptableMediaTypes = new ArrayList<>(); - acceptableMediaTypes.add(MediaType.APPLICATION_JSON); - headers.setAccept(acceptableMediaTypes); - headers.setContentType(MediaType.APPLICATION_JSON); - return headers; - } - - /** - * @param apiPath - * @return - */ - public String getOofurl(String apiPath) { - return new StringBuilder(env.getRequiredProperty(Constants.OOF_ENDPOINT)).append(apiPath).toString(); - } - - -} |