diff options
Diffstat (limited to 'ms/controllerblueprints/application/src/main/java')
-rw-r--r-- | ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ApplicationConstants.java (renamed from ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java) | 56 | ||||
-rw-r--r-- | ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ControllerBlueprintsApplication.java (renamed from ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplication.java) | 82 | ||||
-rw-r--r-- | ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/DatabaseConfig.java (renamed from ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java) | 122 | ||||
-rw-r--r-- | ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/SwaggerConfig.java (renamed from ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java) | 4 | ||||
-rw-r--r-- | ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/WebConfig.java (renamed from ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java) | 100 | ||||
-rw-r--r-- | ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/filters/ApplicationLoggingFilter.java (renamed from ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java) | 194 | ||||
-rw-r--r-- | ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java (renamed from ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java) | 122 |
7 files changed, 340 insertions, 340 deletions
diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ApplicationConstants.java index c4759b568..9a9fafffc 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ApplicationConstants.java @@ -1,28 +1,28 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.ccsdk.apps.controllerblueprints;
-
-/**
- * ApplicationConstants.java Purpose: Provide ControllerBlueprintsApplication Constant Information
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@SuppressWarnings("unused")
-public final class ApplicationConstants {
-
-}
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.ccsdk.cds.controllerblueprints; + +/** + * ApplicationConstants.java Purpose: Provide ControllerBlueprintsApplication Constant Information + * + * @author Brinda Santh + * @version 1.0 + */ +@SuppressWarnings("unused") +public final class ApplicationConstants { + +} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplication.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ControllerBlueprintsApplication.java index e925c69c0..29d2eb7c7 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplication.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ControllerBlueprintsApplication.java @@ -1,42 +1,42 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.ccsdk.apps.controllerblueprints;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.web.reactive.config.EnableWebFlux;
-
-/**
- * @author Brinda Santh
- */
-@SpringBootApplication
-@EnableWebFlux
-@ComponentScan(basePackages = {"org.onap.ccsdk.apps.controllerblueprints"})
-@EnableAutoConfiguration
-public class ControllerBlueprintsApplication {
- private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBlueprintsApplication.class);
-
- public static void main(String[] args) {
- log.info("****** Starting Controlled Blueprints Application ******");
- SpringApplication.run(ControllerBlueprintsApplication.class, args);
- }
-
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.ccsdk.cds.controllerblueprints; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.web.reactive.config.EnableWebFlux; + +/** + * @author Brinda Santh + */ +@SpringBootApplication +@EnableWebFlux +@ComponentScan(basePackages = {"org.onap.ccsdk.cds.controllerblueprints"}) +@EnableAutoConfiguration +public class ControllerBlueprintsApplication { + private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBlueprintsApplication.class); + + public static void main(String[] args) { + log.info("****** Starting Controlled Blueprints Application ******"); + SpringApplication.run(ControllerBlueprintsApplication.class, args); + } + }
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/DatabaseConfig.java index 5b154ff25..8ec4bd4a3 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/DatabaseConfig.java @@ -1,61 +1,61 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.ccsdk.apps.controllerblueprints;
-
-import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
-import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
-import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-import javax.sql.DataSource;
-
-/**
- * DatabaseConfig.java Purpose: Provide Configuration Generator DatabaseConfig Information
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@Configuration
-@EntityScan("org.onap.ccsdk.apps.controllerblueprints.service.domain")
-@EnableTransactionManagement
-@EnableJpaRepositories("org.onap.ccsdk.apps.controllerblueprints.service.repository")
-@EnableJpaAuditing
-public class DatabaseConfig {
- /**
- * This is a entityManagerFactory method
- *
- * @param dataSource
- * @return LocalContainerEntityManagerFactoryBean
- */
-
- @Bean
- public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
- HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
- vendorAdapter.setGenerateDdl(true);
- vendorAdapter.setShowSql(false);
- LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
- factory.setJpaVendorAdapter(vendorAdapter);
- factory.setPackagesToScan("org.onap.ccsdk.apps.controllerblueprints.service.domain");
- factory.setDataSource(dataSource);
- return factory;
- }
-
-}
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.ccsdk.cds.controllerblueprints; + +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.sql.DataSource; + +/** + * DatabaseConfig.java Purpose: Provide Configuration Generator DatabaseConfig Information + * + * @author Brinda Santh + * @version 1.0 + */ +@Configuration +@EntityScan("org.onap.ccsdk.cds.controllerblueprints.service.domain") +@EnableTransactionManagement +@EnableJpaRepositories("org.onap.ccsdk.cds.controllerblueprints.service.repository") +@EnableJpaAuditing +public class DatabaseConfig { + /** + * This is a entityManagerFactory method + * + * @param dataSource + * @return LocalContainerEntityManagerFactoryBean + */ + + @Bean + public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) { + HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + vendorAdapter.setGenerateDdl(true); + vendorAdapter.setShowSql(false); + LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); + factory.setJpaVendorAdapter(vendorAdapter); + factory.setPackagesToScan("org.onap.ccsdk.cds.controllerblueprints.service.domain"); + factory.setDataSource(dataSource); + return factory; + } + +} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/SwaggerConfig.java index ca6332833..93182769b 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/SwaggerConfig.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.onap.ccsdk.apps.controllerblueprints; +package org.onap.ccsdk.cds.controllerblueprints; import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.http.HttpStatus; diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/WebConfig.java index 45faa1b57..e4799bc84 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/WebConfig.java @@ -1,50 +1,50 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- * 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.ccsdk.apps.controllerblueprints;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.reactive.config.CorsRegistry;
-import org.springframework.web.reactive.config.ResourceHandlerRegistry;
-import org.springframework.web.reactive.config.WebFluxConfigurationSupport;
-
-/**
- * WebConfig
- *
- * @author Brinda Santh 8/13/2018
- */
-@Configuration
-@SuppressWarnings("unused")
-public class WebConfig extends WebFluxConfigurationSupport {
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
- registry.addResourceHandler("swagger-ui.html")
- .addResourceLocations("classpath:/META-INF/resources/");
-
- registry.addResourceHandler("/webjars/**")
- .addResourceLocations("classpath:/META-INF/resources/webjars/");
-
- }
-
- @Override
- public void addCorsMappings(CorsRegistry corsRegistry) {
- corsRegistry.addMapping("/**")
- .allowedOrigins("*")
- .allowedMethods("*")
- .allowedHeaders("DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range")
- .maxAge(3600);
- }
-}
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * 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.ccsdk.cds.controllerblueprints; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.config.CorsRegistry; +import org.springframework.web.reactive.config.ResourceHandlerRegistry; +import org.springframework.web.reactive.config.WebFluxConfigurationSupport; + +/** + * WebConfig + * + * @author Brinda Santh 8/13/2018 + */ +@Configuration +@SuppressWarnings("unused") +public class WebConfig extends WebFluxConfigurationSupport { + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); + + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + + } + + @Override + public void addCorsMappings(CorsRegistry corsRegistry) { + corsRegistry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range") + .maxAge(3600); + } +} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/filters/ApplicationLoggingFilter.java index 367ea7d91..60837e8a7 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/filters/ApplicationLoggingFilter.java @@ -1,98 +1,98 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.ccsdk.apps.controllerblueprints.filters;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.server.reactive.ServerHttpRequest;
-import org.springframework.http.server.reactive.ServerHttpResponse;
-import org.springframework.web.server.ServerWebExchange;
-import org.springframework.web.server.WebFilter;
-import org.springframework.web.server.WebFilterChain;
-import reactor.core.publisher.Mono;
-
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.UUID;
-
-/**
- * ApplicationLoggingFilter
- *
- * @author Brinda Santh 8/14/2018
- */
-@Configuration
-@SuppressWarnings("unused")
-public class ApplicationLoggingFilter implements WebFilter {
- private static Logger log = LoggerFactory.getLogger(ApplicationLoggingFilter.class);
-
- @SuppressWarnings("unused")
- @Value("${appVersion}")
- private String appVersion;
-
- @Override
- public Mono<Void> filter(ServerWebExchange serverWebExchange, WebFilterChain webFilterChain) {
- try {
-
- ServerHttpRequest request = serverWebExchange.getRequest();
- ServerHttpResponse response = serverWebExchange.getResponse();
-
- String[] tokens = StringUtils.split(appVersion, '.');
- Preconditions.checkNotNull(tokens, "failed to split application versions");
- Preconditions.checkArgument(tokens.length == 3, "failed to tokenize application versions");
- HttpHeaders header = response.getHeaders();
-
- String requestID = defaultToUUID(request.getHeaders().getFirst("X-ONAP-RequestID"));
- String invocationID = defaultToUUID(request.getHeaders().getFirst("X-ONAP-InvocationID"));
- String partnerName = defaultToEmpty(request.getHeaders().getFirst("X-ONAP-PartnerName"));
- MDC.put("InvokeTimestamp", ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
- MDC.put("RequestID", requestID);
- MDC.put("InvocationID", invocationID);
- MDC.put("PartnerName", partnerName);
- MDC.put("ClientIPAddress", defaultToEmpty(request.getRemoteAddress().getAddress()));
- MDC.put("ServerFQDN", defaultToEmpty(request.getRemoteAddress().getHostString()));
-
- header.add(BluePrintConstants.RESPONSE_HEADER_TRANSACTION_ID, requestID);
- header.add(BluePrintConstants.RESPONSE_HEADER_MINOR_VERSION, tokens[1]);
- header.add(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, tokens[2]);
- header.add(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, appVersion);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return webFilterChain.filter(serverWebExchange);
-
- }
-
- private static String defaultToUUID(String in) {
- return in == null ? UUID.randomUUID().toString() : in;
- }
-
- private static String defaultToEmpty(Object in) {
- return in == null ? "" : in.toString();
- }
-
-
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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.ccsdk.cds.controllerblueprints.filters; + +import com.google.common.base.Preconditions; +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpHeaders; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.server.WebFilter; +import org.springframework.web.server.WebFilterChain; +import reactor.core.publisher.Mono; + +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.UUID; + +/** + * ApplicationLoggingFilter + * + * @author Brinda Santh 8/14/2018 + */ +@Configuration +@SuppressWarnings("unused") +public class ApplicationLoggingFilter implements WebFilter { + private static Logger log = LoggerFactory.getLogger(ApplicationLoggingFilter.class); + + @SuppressWarnings("unused") + @Value("${appVersion}") + private String appVersion; + + @Override + public Mono<Void> filter(ServerWebExchange serverWebExchange, WebFilterChain webFilterChain) { + try { + + ServerHttpRequest request = serverWebExchange.getRequest(); + ServerHttpResponse response = serverWebExchange.getResponse(); + + String[] tokens = StringUtils.split(appVersion, '.'); + Preconditions.checkNotNull(tokens, "failed to split application versions"); + Preconditions.checkArgument(tokens.length == 3, "failed to tokenize application versions"); + HttpHeaders header = response.getHeaders(); + + String requestID = defaultToUUID(request.getHeaders().getFirst("X-ONAP-RequestID")); + String invocationID = defaultToUUID(request.getHeaders().getFirst("X-ONAP-InvocationID")); + String partnerName = defaultToEmpty(request.getHeaders().getFirst("X-ONAP-PartnerName")); + MDC.put("InvokeTimestamp", ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT)); + MDC.put("RequestID", requestID); + MDC.put("InvocationID", invocationID); + MDC.put("PartnerName", partnerName); + MDC.put("ClientIPAddress", defaultToEmpty(request.getRemoteAddress().getAddress())); + MDC.put("ServerFQDN", defaultToEmpty(request.getRemoteAddress().getHostString())); + + header.add(BluePrintConstants.RESPONSE_HEADER_TRANSACTION_ID, requestID); + header.add(BluePrintConstants.RESPONSE_HEADER_MINOR_VERSION, tokens[1]); + header.add(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, tokens[2]); + header.add(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, appVersion); + } catch (Exception e) { + e.printStackTrace(); + } + + return webFilterChain.filter(serverWebExchange); + + } + + private static String defaultToUUID(String in) { + return in == null ? UUID.randomUUID().toString() : in; + } + + private static String defaultToEmpty(Object in) { + return in == null ? "" : in.toString(); + } + + }
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java index 334574f79..131ff015d 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java @@ -1,62 +1,62 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.ccsdk.apps.controllerblueprints.security;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
-import org.springframework.security.config.web.server.ServerHttpSecurity;
-import org.springframework.security.core.userdetails.MapReactiveUserDetailsService;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.web.server.SecurityWebFilterChain;
-
-@SuppressWarnings("unused")
-@EnableWebFluxSecurity
-public class ApplicationSecurityConfigurerAdapter {
-
- @Value("${basic-auth.user-name}")
- private String userName;
-
- @Value("${basic-auth.hashed-pwd}")
- private String userHashedPassword;
-
- private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationSecurityConfigurerAdapter.class);
-
- @Bean
- public SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception {
-
- http.csrf().disable();
- http.authorizeExchange()
- .pathMatchers("/webjars/**", "/actuator/**").permitAll()
- .anyExchange().authenticated()
- .and().httpBasic();
-
- return http.build();
- }
-
- @Bean
- public MapReactiveUserDetailsService userDetailsService() {
- User.UserBuilder userBuilder = User.builder();
- UserDetails defaultUser = userBuilder
- .username(userName)
- .password(userHashedPassword).roles("USER").build();
- return new MapReactiveUserDetailsService(defaultUser);
- }
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.ccsdk.cds.controllerblueprints.security; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; +import org.springframework.security.config.web.server.ServerHttpSecurity; +import org.springframework.security.core.userdetails.MapReactiveUserDetailsService; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.web.server.SecurityWebFilterChain; + +@SuppressWarnings("unused") +@EnableWebFluxSecurity +public class ApplicationSecurityConfigurerAdapter { + + @Value("${basic-auth.user-name}") + private String userName; + + @Value("${basic-auth.hashed-pwd}") + private String userHashedPassword; + + private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationSecurityConfigurerAdapter.class); + + @Bean + public SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception { + + http.csrf().disable(); + http.authorizeExchange() + .pathMatchers("/webjars/**", "/actuator/**").permitAll() + .anyExchange().authenticated() + .and().httpBasic(); + + return http.build(); + } + + @Bean + public MapReactiveUserDetailsService userDetailsService() { + User.UserBuilder userBuilder = User.builder(); + UserDetails defaultUser = userBuilder + .username(userName) + .password(userHashedPassword).roles("USER").build(); + return new MapReactiveUserDetailsService(defaultUser); + } }
\ No newline at end of file |