summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java132
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SecurityFilters.java41
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SoCadiFilter.java117
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java80
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java69
5 files changed, 77 insertions, 362 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
index 5498b5be31..9741d4b6c2 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
@@ -24,7 +24,6 @@ package org.onap.so.client.cds;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader;
@@ -51,28 +50,29 @@ import io.grpc.Status;
*
*/
@Component
-public class AbstractCDSProcessingBBUtils implements CDSProcessingListener {
+public class AbstractCDSProcessingBBUtils {
private static final Logger logger = LoggerFactory.getLogger(AbstractCDSProcessingBBUtils.class);
private static final String SUCCESS = "Success";
private static final String FAILED = "Failed";
private static final String PROCESSING = "Processing";
+ private static final String RESPONSE_PAYLOAD = "CDSResponsePayload";
+ private static final String CDS_STATUS = "CDSStatus";
+ private static final String EXEC_INPUT = "executionServiceInput";
+
/**
* indicate exception thrown.
*/
private static final String EXCEPTION = "Exception";
-
- private final AtomicReference<String> cdsResponse = new AtomicReference<>();
-
@Autowired
private ExceptionBuilder exceptionUtil;
/**
* Extracting data from execution object and building the ExecutionServiceInput Object
- *
+ *
* @param execution DelegateExecution object
*/
public void constructExecutionServiceInputObject(DelegateExecution execution) {
@@ -105,7 +105,7 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener {
ExecutionServiceInput.newBuilder().setCommonHeader(commonHeader)
.setActionIdentifiers(actionIdentifiers).setPayload(struct.build()).build();
- execution.setVariable("executionServiceInput", executionServiceInput);
+ execution.setVariable(EXEC_INPUT, executionServiceInput);
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
@@ -114,7 +114,7 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener {
/**
* get the executionServiceInput object from execution and send a request to CDS Client and wait for TIMEOUT period
- *
+ *
* @param execution DelegateExecution object
*/
public void sendRequestToCDSClient(DelegateExecution execution) {
@@ -127,10 +127,11 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener {
"No RestProperty.CDSProperties implementation found on classpath, can't create client.");
}
- ExecutionServiceInput executionServiceInput =
- (ExecutionServiceInput) execution.getVariable("executionServiceInput");
+ ExecutionServiceInput executionServiceInput = (ExecutionServiceInput) execution.getVariable(EXEC_INPUT);
+
+ CDSResponse cdsResponse = new CDSResponse();
- try (CDSProcessingClient cdsClient = new CDSProcessingClient(this)) {
+ try (CDSProcessingClient cdsClient = new CDSProcessingClient(new ResponseHandler(cdsResponse))) {
CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput);
countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS);
} catch (InterruptedException ex) {
@@ -138,61 +139,82 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener {
Thread.currentThread().interrupt();
}
- if (cdsResponse != null) {
- String cdsResponseStatus = cdsResponse.get();
- execution.setVariable("CDSStatus", cdsResponseStatus);
+ String cdsResponseStatus = cdsResponse.status;
+
+ /**
+ * throw CDS failed exception.
+ */
+ if (!cdsResponseStatus.equals(SUCCESS)) {
+ throw new BadResponseException("CDS call failed with status: " + cdsResponse.status
+ + " and errorMessage: " + cdsResponse.errorMessage);
+ }
+
+ execution.setVariable(CDS_STATUS, cdsResponseStatus);
- /**
- * throw CDS failed exception.
- */
- if (cdsResponseStatus != SUCCESS) {
- throw new BadResponseException("CDS call failed with status: " + cdsResponseStatus);
- }
+ if (cdsResponse.payload != null) {
+ String payload = JsonFormat.printer().print(cdsResponse.payload);
+ execution.setVariable(RESPONSE_PAYLOAD, payload);
}
+
+
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
- /**
- * Get Response from CDS Client
- *
- */
- @Override
- public void onMessage(ExecutionServiceOutput message) {
- logger.info("Received notification from CDS: {}", message);
- EventType eventType = message.getStatus().getEventType();
-
- switch (eventType) {
-
- case EVENT_COMPONENT_FAILURE:
- // failed processing with failure
- cdsResponse.set(FAILED);
- break;
- case EVENT_COMPONENT_PROCESSING:
- // still processing
- cdsResponse.set(PROCESSING);
- break;
- case EVENT_COMPONENT_EXECUTED:
- // done with async processing
- cdsResponse.set(SUCCESS);
- break;
- default:
- cdsResponse.set(FAILED);
- break;
+ private class ResponseHandler implements CDSProcessingListener {
+
+ private CDSResponse cdsResponse;
+
+ ResponseHandler(CDSResponse cdsResponse) {
+ this.cdsResponse = cdsResponse;
}
- }
+ /**
+ * Get Response from CDS Client
+ */
+ @Override
+ public void onMessage(ExecutionServiceOutput message) {
+ logger.info("Received notification from CDS: {}", message);
+ EventType eventType = message.getStatus().getEventType();
+
+ switch (eventType) {
+ case EVENT_COMPONENT_PROCESSING:
+ cdsResponse.status = PROCESSING;
+ break;
+ case EVENT_COMPONENT_EXECUTED:
+ cdsResponse.status = SUCCESS;
+ break;
+ default:
+ cdsResponse.status = FAILED;
+ cdsResponse.errorMessage = message.getStatus().getErrorMessage();
+ break;
+ }
+ cdsResponse.payload = message.getPayload();
+ }
- /**
- * On error at CDS, log the error
- */
- @Override
- public void onError(Throwable t) {
- Status status = Status.fromThrowable(t);
- logger.error("Failed processing blueprint {}", status, t);
- cdsResponse.set(EXCEPTION);
+ /**
+ * On error at CDS, log the error
+ */
+ @Override
+ public void onError(Throwable t) {
+ Status status = Status.fromThrowable(t);
+ logger.error("Failed processing blueprint {}", status, t);
+ cdsResponse.status = EXCEPTION;
+ }
}
+ private class CDSResponse {
+
+ String status;
+ String errorMessage;
+ Struct payload;
+
+ @Override
+ public String toString() {
+ return "CDSResponse{" + "status='" + status + '\'' + ", errorMessage='" + errorMessage + '\'' + ", payload="
+ + payload + '}';
+ }
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SecurityFilters.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SecurityFilters.java
deleted file mode 100644
index bdc1c504f0..0000000000
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SecurityFilters.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2019 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.bpmn.infrastructure;
-
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
-import org.springframework.core.Ordered;
-
-@Configuration
-@Profile("aaf")
-public class SecurityFilters {
-
- @Bean
- public FilterRegistrationBean<SoCadiFilter> loginRegistrationBean() {
- FilterRegistrationBean<SoCadiFilter> filterRegistrationBean = new FilterRegistrationBean<>();
- filterRegistrationBean.setFilter(new SoCadiFilter());
- filterRegistrationBean.setName("cadiFilter");
- filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
- return filterRegistrationBean;
- }
-}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SoCadiFilter.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SoCadiFilter.java
deleted file mode 100644
index cb60d5d219..0000000000
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SoCadiFilter.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*-
- * ============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.bpmn.infrastructure;
-
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import org.onap.aaf.cadi.config.Config;
-import org.onap.aaf.cadi.filter.CadiFilter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Profile;
-import org.springframework.stereotype.Component;
-
-@Component
-@Profile("aaf")
-public class SoCadiFilter extends CadiFilter {
-
- protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class);
-
- private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT";
- private static String AAF_API_VERSION = "aaf_api_version";
-
- @Value("${mso.config.cadi.cadiLoglevel:#{null}}")
- private String cadiLoglevel;
-
- @Value("${mso.config.cadi.cadiKeyFile:#{null}}")
- private String cadiKeyFile;
-
- @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}")
- private String cadiTrustStorePassword;
-
- @Value("${mso.config.cadi.cadiTrustStore:#{null}}")
- private String cadiTrustStore;
-
- @Value("${mso.config.cadi.cadiLatitude:#{null}}")
- private String cadiLatitude;
-
- @Value("${mso.config.cadi.cadiLongitude:#{null}}")
- private String cadiLongitude;
-
- @Value("${mso.config.cadi.aafEnv:#{null}}")
- private String aafEnv;
-
- @Value("${mso.config.cadi.aafApiVersion:#{null}}")
- private String aafApiVersion;
-
- @Value("${mso.config.cadi.aafRootNs:#{null}}")
- private String aafRootNs;
-
- @Value("${mso.config.cadi.aafId:#{null}}")
- private String aafMechId;
-
- @Value("${mso.config.cadi.aafPassword:#{null}}")
- private String aafMechIdPassword;
-
- @Value("${mso.config.cadi.aafLocateUrl:#{null}}")
- private String aafLocateUrl;
-
- @Value("${mso.config.cadi.aafUrl:#{null}}")
- private String aafUrl;
-
- @Value("${mso.config.cadi.apiEnforcement:#{null}}")
- private String apiEnforcement;
-
- private void checkIfNullProperty(String key, String value) {
- /*
- * When value is null, it is not defined in application.yaml set nothing in System properties
- */
- if (value != null) {
- System.setProperty(key, value);
- }
- }
-
- @Override
- public void init(FilterConfig filterConfig) throws ServletException {
- checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel);
- checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile);
- checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore);
- checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword);
- checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude);
- checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude);
- checkIfNullProperty(Config.AAF_ENV, aafEnv);
- checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion);
- checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs);
- checkIfNullProperty(Config.AAF_APPID, aafMechId);
- checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword);
- checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl);
- checkIfNullProperty(Config.AAF_URL, aafUrl);
- checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement);
- // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv);
- logger.debug(" *** init Filter Config *** ");
- super.init(filterConfig);
- }
-
-
-}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java
deleted file mode 100644
index bcc38ec9e0..0000000000
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.bpmn.infrastructure;
-
-import org.onap.so.security.MSOSpringFirewall;
-import org.onap.so.security.WebSecurityConfig;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-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.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-import org.springframework.security.web.firewall.StrictHttpFirewall;
-import org.springframework.util.StringUtils;
-
-@Configuration
-@EnableWebSecurity
-public class WebSecurityConfigImpl extends WebSecurityConfig {
-
- @Profile({"basic", "test"})
- @Bean
- public WebSecurityConfigurerAdapter basicAuth() {
- return new WebSecurityConfigurerAdapter() {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll()
- .antMatchers("/async/services/**", "/workflow/services/*", "/SDNCAdapterCallbackService",
- "/WorkflowMessage", "/vnfAdapterNotify", "/vnfAdapterRestNotify")
- .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and().httpBasic();
- }
-
- @Override
- public void configure(WebSecurity web) throws Exception {
- super.configure(web);
- StrictHttpFirewall firewall = new MSOSpringFirewall();
- web.httpFirewall(firewall);
- }
-
- @Override
- protected void configure(AuthenticationManagerBuilder auth) throws Exception {
- auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService())
- .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder());
- }
-
- };
- }
-
- @Profile("aaf")
- @Bean
- public WebSecurityConfigurerAdapter noAuth() {
- return new WebSecurityConfigurerAdapter() {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.authorizeRequests().anyRequest().permitAll();
- }
- };
- }
-}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java
deleted file mode 100644
index 58e58464e1..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.bpmn.infrastructure;
-
-import org.onap.so.security.MSOSpringFirewall;
-import org.onap.so.security.WebSecurityConfig;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-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.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-import org.springframework.security.web.firewall.StrictHttpFirewall;
-import org.springframework.util.StringUtils;
-
-@Configuration
-@EnableWebSecurity
-public class WebSecurityConfigImpl extends WebSecurityConfig {
-
- @Bean
- @Profile("test")
- public WebSecurityConfigurerAdapter basicAuth() {
- return new WebSecurityConfigurerAdapter() {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll()
- .antMatchers("/async/services/**", "/workflow/services/*", "/SDNCAdapterCallbackService",
- "/WorkflowMessage", "/vnfAdapterNotify", "/vnfAdapterRestNotify")
- .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and().httpBasic();
- }
-
- @Override
- public void configure(WebSecurity web) throws Exception {
- super.configure(web);
- StrictHttpFirewall firewall = new MSOSpringFirewall();
- web.httpFirewall(firewall);
- }
-
- @Override
- protected void configure(AuthenticationManagerBuilder auth) throws Exception {
- auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService())
- .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder());
- }
-
- };
- }
-}