From 02887947e4755f9c01bb98b14e65a4e7e1f418f5 Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Tue, 14 Apr 2020 17:39:38 +0100 Subject: Refactor SOL003 Adapter to organize its modules based on functions Change-Id: I7a1c172974ab5910b0c6b069dcf8c48f9893de37 Issue-ID: SO-2771 Signed-off-by: waqas.ikram --- .../etsi-sol003-adapter-application/pom.xml | 2 +- .../sol003/adapter/VnfmAdapterApplication.java | 57 ++++++++++++++++++++ .../adapter/VnfmBasicHttpSecurityConfigurer.java | 63 ++++++++++++++++++++++ .../vnfmadapter/VnfmAdapterApplication.java | 57 -------------------- .../VnfmBasicHttpSecurityConfigurer.java | 63 ---------------------- 5 files changed, 121 insertions(+), 121 deletions(-) create mode 100755 adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmAdapterApplication.java create mode 100644 adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmBasicHttpSecurityConfigurer.java delete mode 100755 adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java delete mode 100644 adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java (limited to 'adapters/etsi-sol003-adapter/etsi-sol003-adapter-application') diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml index acf4790308..85024edee0 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-maven-plugin - org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication + org.onap.so.adapters.etsi.sol003.adapter.VnfmAdapterApplication diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmAdapterApplication.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmAdapterApplication.java new file mode 100755 index 0000000000..6fe76db5e4 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmAdapterApplication.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.etsi.sol003.adapter; + +import static org.slf4j.LoggerFactory.getLogger; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.VnfmAdapterController; +import org.slf4j.Logger; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; +import org.springframework.cache.annotation.EnableCaching; + +/** + * The spring boot application for the VNFM (Virtual Network Function Manager) Adapter. + *

+ * The VNFM Adapter receives requests through its REST API {@link VnfmAdapterController} which it adapts into ETSI + * SOL003 compliant LCM (Life Cycle Management) calls towards an ETSI compliant VNFM. + * + * @see ETSI + * SOL003 v2.5.1 + */ +@EnableCaching +@SpringBootApplication(scanBasePackages = {"org.onap.so"}) +@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class}) +public class VnfmAdapterApplication { + private static final Logger logger = getLogger(VnfmAdapterApplication.class); + + /** + * Entry point for the Spring boot application + * + * @param args arguments for the application + */ + public static void main(final String[] args) { + new SpringApplication(VnfmAdapterApplication.class).run(args); + logger.info("VnfmAdapterApplication started!"); + } + +} diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmBasicHttpSecurityConfigurer.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmBasicHttpSecurityConfigurer.java new file mode 100644 index 0000000000..cfc4ef02d7 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmBasicHttpSecurityConfigurer.java @@ -0,0 +1,63 @@ +/*- + * ============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.adapters.etsi.sol003.adapter; + +import org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants; +import org.onap.so.security.HttpSecurityConfigurer; +import org.onap.so.security.SoUserCredentialConfiguration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Primary; +import org.springframework.http.HttpMethod; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * @author Gareth Roper (gareth.roper@est.tech) + */ +@Primary +@Component +public class VnfmBasicHttpSecurityConfigurer implements HttpSecurityConfigurer { + + @Autowired + private SoUserCredentialConfiguration soUserCredentialConfiguration; + + @Value("${server.ssl.client-auth:none}") + private String clientAuth; + + @Override + public void configure(final HttpSecurity http) throws Exception { + if (("need").equalsIgnoreCase(clientAuth)) { + http.csrf().disable().authorizeRequests().anyRequest().permitAll(); + } else { + http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() + .antMatchers(HttpMethod.GET, CommonConstants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL).permitAll() + .antMatchers("/**") + .hasAnyRole(StringUtils.collectionToDelimitedString(soUserCredentialConfiguration.getRoles(), ",")) + .and().httpBasic(); + } + } +} + diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java deleted file mode 100755 index 405bf896ef..0000000000 --- a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.vnfmadapter; - -import static org.slf4j.LoggerFactory.getLogger; -import org.onap.so.adapters.vnfmadapter.rest.VnfmAdapterController; -import org.slf4j.Logger; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.cache.annotation.EnableCaching; - -/** - * The spring boot application for the VNFM (Virtual Network Function Manager) Adapter. - *

- * The VNFM Adapter receives requests through its REST API {@link VnfmAdapterController} which it adapts into ETSI - * SOL003 compliant LCM (Life Cycle Management) calls towards an ETSI compliant VNFM. - * - * @see ETSI - * SOL003 v2.5.1 - */ -@EnableCaching -@SpringBootApplication(scanBasePackages = {"org.onap.so"}) -@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class}) -public class VnfmAdapterApplication { - private static final Logger logger = getLogger(VnfmAdapterApplication.class); - - /** - * Entry point for the Spring boot application - * - * @param args arguments for the application - */ - public static void main(final String[] args) { - new SpringApplication(VnfmAdapterApplication.class).run(args); - logger.info("VnfmAdapterApplication started!"); - } - -} diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java deleted file mode 100644 index da1b396aac..0000000000 --- a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java +++ /dev/null @@ -1,63 +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.adapters.vnfmadapter; - -import org.onap.so.adapters.vnfmadapter.common.CommonConstants; -import org.onap.so.security.HttpSecurityConfigurer; -import org.onap.so.security.SoUserCredentialConfiguration; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Primary; -import org.springframework.http.HttpMethod; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; - -/** - * @author Waqas Ikram (waqas.ikram@est.tech) - * @author Gareth Roper (gareth.roper@est.tech) - */ -@Primary -@Component -public class VnfmBasicHttpSecurityConfigurer implements HttpSecurityConfigurer { - - @Autowired - private SoUserCredentialConfiguration soUserCredentialConfiguration; - - @Value("${server.ssl.client-auth:none}") - private String clientAuth; - - @Override - public void configure(final HttpSecurity http) throws Exception { - if (("need").equalsIgnoreCase(clientAuth)) { - http.csrf().disable().authorizeRequests().anyRequest().permitAll(); - } else { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers(HttpMethod.GET, CommonConstants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL).permitAll() - .antMatchers("/**") - .hasAnyRole(StringUtils.collectionToDelimitedString(soUserCredentialConfiguration.getRoles(), ",")) - .and().httpBasic(); - } - } -} - -- cgit 1.2.3-korg