diff options
Diffstat (limited to 'ms/controllerblueprints/application/src/main')
13 files changed, 846 insertions, 0 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/apps/controllerblueprints/ApplicationConstants.java new file mode 100644 index 000000000..c4759b568 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java @@ -0,0 +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 {
+
+}
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/apps/controllerblueprints/ControllerBlueprintsApplication.java new file mode 100644 index 000000000..e925c69c0 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplication.java @@ -0,0 +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);
+ }
+
+}
\ 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/apps/controllerblueprints/DatabaseConfig.java new file mode 100644 index 000000000..5b154ff25 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java @@ -0,0 +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;
+ }
+
+}
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/apps/controllerblueprints/SwaggerConfig.java new file mode 100644 index 000000000..ca6332833 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java @@ -0,0 +1,155 @@ +/* + * 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 com.google.common.collect.Lists; +import org.jetbrains.annotations.NotNull; +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestMethod; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.builders.ResponseMessageBuilder; +import springfox.documentation.schema.ModelRef; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.service.Header; +import springfox.documentation.service.ResponseMessage; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * SwaggerConfig + * + * @author Brinda Santh 8/13/2018 + */ +@Deprecated +//@Configuration +//@EnableSwagger2 +@SuppressWarnings("unused") +public class SwaggerConfig { + @Value("${appVersion}") + private String appVersion; + @Value("${swagger.contact.name}") + private String contactName; + @Value("${swagger.contact.url}") + private String contactUrl; + @Value("${swagger.contact.email}") + private String contactEmail; + private String stringModelRef = "string"; + + @Bean + @SuppressWarnings("unused") + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .globalResponseMessage(RequestMethod.GET, getDefaultGetResponseMessages()) + .globalResponseMessage(RequestMethod.POST, getDefaultPostResponseMessages()) + .globalResponseMessage(RequestMethod.PUT, getDefaultPutResponseMessages()) + .globalResponseMessage(RequestMethod.DELETE, getDefaultDeleteResponseMessages()) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build() + .apiInfo(apiInfo()); + } + + private ApiInfo apiInfo() { + return new ApiInfo( + "Controller Blueprints API", + "Controller blueprints API for VNF Self Service.", + appVersion, + "Terms of service", + new Contact(contactName, contactUrl, contactEmail), + "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", Collections.emptyList()); + } + + private List<ResponseMessage> getDefaultGetResponseMessages() { + List<ResponseMessage> defaultResponseMessages = Lists.newArrayList(); + Map<String, Header> defaultHeaders = getDefaultResponseHeaders(); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.OK, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.BAD_REQUEST, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.UNAUTHORIZED, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.FORBIDDEN, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.NOT_FOUND, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR, defaultHeaders)); + return defaultResponseMessages; + } + + private List<ResponseMessage> getDefaultPostResponseMessages() { + List<ResponseMessage> defaultResponseMessages = Lists.newArrayList(); + Map<String, Header> defaultHeaders = getDefaultResponseHeaders(); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.OK, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.CREATED, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.BAD_REQUEST, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.UNAUTHORIZED, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.FORBIDDEN, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR, defaultHeaders)); + return defaultResponseMessages; + } + + private List<ResponseMessage> getDefaultPutResponseMessages() { + List<ResponseMessage> defaultResponseMessages = Lists.newArrayList(); + Map<String, Header> defaultHeaders = getDefaultResponseHeaders(); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.OK, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.BAD_REQUEST, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.UNAUTHORIZED, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.FORBIDDEN, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR, defaultHeaders)); + return defaultResponseMessages; + } + + private List<ResponseMessage> getDefaultDeleteResponseMessages() { + List<ResponseMessage> defaultResponseMessages = Lists.newArrayList(); + Map<String, Header> defaultHeaders = getDefaultResponseHeaders(); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.OK, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.BAD_REQUEST, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.UNAUTHORIZED, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.FORBIDDEN, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR, defaultHeaders)); + return defaultResponseMessages; + } + + private ResponseMessage getResponseBuilder(@NotNull HttpStatus httpStatus, Map<String, Header> defaultHeaders) { + ResponseMessageBuilder responseMessageBuilder = new ResponseMessageBuilder(); + responseMessageBuilder.code(httpStatus.value()) + .message(httpStatus.getReasonPhrase()) + .headersWithDescription(defaultHeaders) + .build(); + return responseMessageBuilder.build(); + } + + private Map<String, Header> getDefaultResponseHeaders() { + Map<String, Header> defaultHeaders = new HashMap<>(); + defaultHeaders.put(BluePrintConstants.RESPONSE_HEADER_TRANSACTION_ID, + new Header(BluePrintConstants.RESPONSE_HEADER_TRANSACTION_ID, "Transaction Id", new ModelRef(stringModelRef))); + defaultHeaders.put(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, + new Header(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, "API Latest Version", new ModelRef(stringModelRef))); + defaultHeaders.put(BluePrintConstants.RESPONSE_HEADER_MINOR_VERSION, + new Header(BluePrintConstants.RESPONSE_HEADER_MINOR_VERSION, "API Minor Version", new ModelRef(stringModelRef))); + defaultHeaders.put(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, + new Header(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, "API Patch Version", new ModelRef(stringModelRef))); + return defaultHeaders; + } +} 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/apps/controllerblueprints/WebConfig.java new file mode 100644 index 000000000..45faa1b57 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java @@ -0,0 +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);
+ }
+}
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/apps/controllerblueprints/filters/ApplicationLoggingFilter.java new file mode 100644 index 000000000..367ea7d91 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java @@ -0,0 +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();
+ }
+
+
+}
\ 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/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java new file mode 100644 index 000000000..334574f79 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java @@ -0,0 +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);
+ }
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/resources/application-dev.properties b/ms/controllerblueprints/application/src/main/resources/application-dev.properties new file mode 100755 index 000000000..3401ece04 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/resources/application-dev.properties @@ -0,0 +1,70 @@ +# +# 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. +# +appName=ControllerBluePrints +ms_name=org.onap.ccsdk.apps.controllerblueprints +appVersion=1.0.0 + +# Basic Authentication +basic-auth.user-name=ccsdkapps +basic-auth.hashed-pwd={bcrypt}$2a$10$MJxhNiOAffxbyrV9.rrOUewP9Q/ASg5Nit2cmP.yBaXGsVXo8BW3y + +#logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex + +logging.level.org.springframework.web=INFO +logging.level.org.hibernate.SQL=warn +logging.level.org.hibernate.type.descriptor.sql=debug + +#To Remove Null in JSON API Response +spring.jackson.default-property-inclusion=non_null + +#Swagger Configuration +swagger.contact.name=Brinda Santh Muthuramalingam +swagger.contact.url=www.onap.com +swagger.contact.email=brindasanth@onap.com + +spring.jpa.properties.hibernate.show_sql=true +spring.jpa.properties.hibernate.use_sql_comments=true +spring.jpa.properties.hibernate.format_sql=true + +# spring.datasource.url, spring.datasource.username,spring.datasource.password may be overridden by ENV variables +spring.datasource.url=jdbc:mysql://localhost:3306/sdnctl +spring.datasource.username=sdnctl +spring.datasource.password=sdnctl +spring.datasource.driver-class-name=org.mariadb.jdbc.Driver +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto=none +spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect +# Load Resource Source Mappings +resourceSourceMappings=processor-db=source-processor-db,input=source-input,default=source-default,primary-config-data=source-rest,capability=source-capability +# Controller Blueprints Core Configuration +controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy +controllerblueprints.blueprintArchivePath=/etc/blueprints/archive +controllerblueprints.blueprintEnrichmentPath=/etc/blueprints/enrichment +# Controller Blueprint Load Configurations +controllerblueprints.loadInitialData=true +controllerblueprints.loadBluePrint=false +controllerblueprints.loadBluePrintPaths=./../../../components/model-catalog/blueprint-model/test-blueprint +controllerblueprints.loadModelType=true +controllerblueprints.loadModeTypePaths=./../../../components/model-catalog/definition-type/starter-type +controllerblueprints.loadResourceDictionary=true +controllerblueprints.loadResourceDictionaryPaths=./../../../components/model-catalog/resource-dictionary/starter-dictionary + +# CBA file extension +controllerblueprints.loadCbaExtension=zip + +# Web server config +server.port=8080
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/resources/application.properties b/ms/controllerblueprints/application/src/main/resources/application.properties new file mode 100755 index 000000000..8789c24ec --- /dev/null +++ b/ms/controllerblueprints/application/src/main/resources/application.properties @@ -0,0 +1,75 @@ +# +# Copyright © 2017-2018 AT&T Intellectual Property. +# Modifications Copyright © 2018 IBM. +# Modifications Copyright © 2019 Bell Canada. +# +# 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. +# +appName=ControllerBluePrints +ms_name=org.onap.ccsdk.apps.controllerblueprints +appVersion=1.0.0 + +# Basic Authentication +basic-auth.user-name=ccsdkapps +basic-auth.hashed-pwd={bcrypt}$2a$10$MJxhNiOAffxbyrV9.rrOUewP9Q/ASg5Nit2cmP.yBaXGsVXo8BW3y + +#logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex + +logging.level.org.springframework.web=INFO +logging.level.org.hibernate.SQL=warn +logging.level.org.hibernate.type.descriptor.sql=debug + +#To Remove Null in JSON API Response +spring.jackson.default-property-inclusion=non_null + +#Swagger Configuration +swagger.contact.name=CCSDK team +swagger.contact.url=www.onap.org +swagger.contact.email=onap-discuss@lists.onap.org + +spring.jpa.properties.hibernate.show_sql=true +spring.jpa.properties.hibernate.use_sql_comments=true +spring.jpa.properties.hibernate.format_sql=true + +# spring.datasource.url, spring.datasource.username,spring.datasource.password may be overridden by ENV variables +spring.datasource.url=jdbc:mysql://db:3306/sdnctl +spring.datasource.username=sdnctl +spring.datasource.password=sdnctl +spring.datasource.driver-class-name=org.mariadb.jdbc.Driver +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto=none +spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect + +# Load Resource Source Mappings +resourceSourceMappings=processor-db=source-processor-db,input=source-input,default=source-default,primary-config-data=source-rest,capability=source-capability + +# Controller Blueprints Core Configuration +controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy +controllerblueprints.blueprintArchivePath=/etc/blueprints/archive +controllerblueprints.blueprintEnrichmentPath=/etc/blueprints/enrichment +# Controller Blueprint Load Configurations +# blueprints.load.initial-data may be overridden by ENV variables +controllerblueprints.loadInitialData=true +controllerblueprints.loadBluePrint=true +controllerblueprints.loadBluePrintPaths=/opt/app/onap//model-catalog/blueprint-model/service-blueprint +controllerblueprints.loadModelType=true +controllerblueprints.loadModeTypePaths=/opt/app/onap//model-catalog/definition-type/starter-type +controllerblueprints.loadResourceDictionary=true +controllerblueprints.loadResourceDictionaryPaths=/opt/app/onap//model-catalog/resource-dictionary/starter-dictionary + +# CBA file extension +controllerblueprints.loadCbaExtension=zip + +# Web server config +server.port=8080
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/resources/logback.xml b/ms/controllerblueprints/application/src/main/resources/logback.xml new file mode 100644 index 000000000..2db82a128 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/resources/logback.xml @@ -0,0 +1,44 @@ +<!-- + ~ 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. + --> + +<configuration> + + <property name="localPattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{100} - %msg%n" /> + + <property name="defaultPattern" value="%date{ISO8601,UTC}|%X{RequestID}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}| %msg%n" /> + + <property name="debugLoggerPattern" value="%date{ISO8601,UTC}|%X{RequestID}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}|[%caller{3}]| %msg%n" /> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + + <logger name="org.springframework" level="info"/> + <logger name="org.springframework.web" level="info"/> + <logger name="org.springframework.security.web.authentication" level="warn"/> + <logger name="org.hibernate" level="error"/> + <logger name="org.onap.ccsdk.apps" level="info"/> + + <root level="warn"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/controllerblueprints/application/src/main/resources/sql/data.sql b/ms/controllerblueprints/application/src/main/resources/sql/data.sql new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ms/controllerblueprints/application/src/main/resources/sql/data.sql diff --git a/ms/controllerblueprints/application/src/main/resources/sql/schema-local.sql b/ms/controllerblueprints/application/src/main/resources/sql/schema-local.sql new file mode 100644 index 000000000..47e0cce7a --- /dev/null +++ b/ms/controllerblueprints/application/src/main/resources/sql/schema-local.sql @@ -0,0 +1,83 @@ +-- drop table sdnctl.MODEL_TYPE;
+-- drop table sdnctl.RESOURCE_DICTIONARY;
+-- drop table sdnctl.CONFIG_MODEL_CONTENT;
+-- drop table sdnctl.CONFIG_MODEL;
+
+-- -----------------------------------------------------
+-- table CONFIG_MODEL
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL (
+ config_model_id INT(11) NOT NULL AUTO_INCREMENT,
+ service_uuid VARCHAR(50) NULL DEFAULT NULL,
+ distribution_id VARCHAR(50) NULL DEFAULT NULL,
+ service_name VARCHAR(255) NULL DEFAULT NULL,
+ service_description VARCHAR(255) NULL DEFAULT NULL,
+ resource_uuid VARCHAR(255) NULL DEFAULT NULL,
+ resource_instance_name VARCHAR(255) NULL DEFAULT NULL,
+ resource_name varchar(255) null default null,
+ resource_version varchar(50) null default null,
+ resource_type varchar(50) null default null,
+ artifact_uuid varchar(50) null default null,
+ artifact_type varchar(50) not null,
+ artifact_version varchar(25) not null,
+ artifact_description longtext null default null,
+ internal_version int(11) null default null,
+ creation_date datetime not null default current_timestamp,
+ artifact_name varchar(100) not null,
+ published varchar(1) not null,
+ updated_by varchar(100) not null,
+ tags longtext null default null,
+ primary key PK_CONFIG_MODEL (config_model_id),
+ UNIQUE KEY UK_CONFIG_MODEL (artifact_name , artifact_version)
+) ENGINE=InnoDB;
+
+
+-- -----------------------------------------------------
+-- table CONFIG_MODEL_CONTENT
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL_CONTENT (
+ config_model_content_id INT(11) NOT NULL AUTO_INCREMENT,
+ config_model_id INT NOT NULL,
+ name VARCHAR(100) NOT NULL,
+ content_type VARCHAR(50) NOT NULL,
+ description LONGTEXT NULL DEFAULT NULL,
+ updated_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ content LONGTEXT NULL DEFAULT NULL,
+ PRIMARY KEY PK_CONFIG_MODEL_CONTENT (config_model_content_id),
+ UNIQUE KEY UK_CONFIG_MODEL_CONTENT (config_model_id, name, content_type),
+ FOREIGN KEY FK_CONFIG_MODEL_CONTENT (config_model_id) REFERENCES sdnctl.CONFIG_MODEL(config_model_id) ON DELETE CASCADE
+) ENGINE=InnoDB;
+
+-- -----------------------------------------------------
+-- table MODEL_TYPE
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS sdnctl.MODEL_TYPE (
+ model_name VARCHAR(100) NOT NULL,
+ derived_from VARCHAR(100) NOT NULL,
+ definition_type VARCHAR(100) NOT NULL,
+ definition LONGTEXT NOT NULL,
+ version VARCHAR(10) NOT NULL,
+ description LONGTEXT NOT NULL,
+ tags LONGTEXT NULL DEFAULT NULL,
+ creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_by VARCHAR(100) NOT NULL,
+ PRIMARY KEY PK_MODEL_TYPE (model_name),
+ INDEX IX_MODEL_TYPE (model_name)
+) ENGINE=InnoDB;
+
+
+-- -----------------------------------------------------
+-- table RESOURCE_DICTIONARY
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS sdnctl.RESOURCE_DICTIONARY (
+ name VARCHAR(100) NOT NULL,
+ data_type VARCHAR(100) NOT NULL,
+ entry_schema VARCHAR(100) NULL DEFAULT NULL,
+ definition LONGTEXT NOT NULL,
+ description LONGTEXT NOT NULL,
+ tags LONGTEXT NOT NULL,
+ creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_by VARCHAR(100) NOT NULL,
+ primary key PK_RESOURCE_DICTIONARY (name),
+ INDEX IX_RESOURCE_DICTIONARY (name)
+) ENGINE=InnoDB;
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/resources/sql/schema.sql b/ms/controllerblueprints/application/src/main/resources/sql/schema.sql new file mode 100644 index 000000000..9c38bec0b --- /dev/null +++ b/ms/controllerblueprints/application/src/main/resources/sql/schema.sql @@ -0,0 +1,78 @@ +-- -----------------------------------------------------
+-- table CONFIG_MODEL
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL (
+ config_model_id INT(11) NOT NULL AUTO_INCREMENT,
+ service_uuid VARCHAR(50) NULL DEFAULT NULL,
+ distribution_id VARCHAR(50) NULL DEFAULT NULL,
+ service_name VARCHAR(255) NULL DEFAULT NULL,
+ service_description VARCHAR(255) NULL DEFAULT NULL,
+ resource_uuid VARCHAR(255) NULL DEFAULT NULL,
+ resource_instance_name VARCHAR(255) NULL DEFAULT NULL,
+ resource_name varchar(255) null default null,
+ resource_version varchar(50) null default null,
+ resource_type varchar(50) null default null,
+ artifact_uuid varchar(50) null default null,
+ artifact_type varchar(50) not null,
+ artifact_version varchar(25) not null,
+ artifact_description longtext null default null,
+ internal_version int(11) null default null,
+ creation_date datetime not null default current_timestamp,
+ artifact_name varchar(100) not null,
+ published varchar(1) not null,
+ updated_by varchar(100) not null,
+ tags longtext null default null,
+ primary key PK_CONFIG_MODEL (config_model_id),
+ UNIQUE KEY UK_CONFIG_MODEL (artifact_name , artifact_version)
+) ENGINE=InnoDB;
+
+
+-- -----------------------------------------------------
+-- table CONFIG_MODEL_CONTENT
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL_CONTENT (
+ config_model_content_id INT(11) NOT NULL AUTO_INCREMENT,
+ config_model_id INT NOT NULL,
+ name VARCHAR(100) NOT NULL,
+ content_type VARCHAR(50) NOT NULL,
+ description LONGTEXT NULL DEFAULT NULL,
+ updated_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ content LONGTEXT NULL DEFAULT NULL,
+ PRIMARY KEY PK_CONFIG_MODEL_CONTENT (config_model_content_id),
+ UNIQUE KEY UK_CONFIG_MODEL_CONTENT (config_model_id, name, content_type),
+ FOREIGN KEY FK_CONFIG_MODEL_CONTENT (config_model_id) REFERENCES configurator.CONFIG_MODEL(config_model_id) ON DELETE CASCADE
+) ENGINE=InnoDB;
+
+-- -----------------------------------------------------
+-- table MODEL_TYPE
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS configurator.MODEL_TYPE (
+ model_name VARCHAR(100) NOT NULL,
+ derived_from VARCHAR(100) NOT NULL,
+ definition_type VARCHAR(100) NOT NULL,
+ definition LONGTEXT NOT NULL,
+ version VARCHAR(10) NOT NULL,
+ description LONGTEXT NOT NULL,
+ tags LONGTEXT NULL DEFAULT NULL,
+ creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_by VARCHAR(100) NOT NULL,
+ PRIMARY KEY PK_MODEL_TYPE (model_name),
+ INDEX IX_MODEL_TYPE (model_name)
+) ENGINE=InnoDB;
+
+
+-- -----------------------------------------------------
+-- table RESOURCE_DICTIONARY
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS configurator.RESOURCE_DICTIONARY (
+ name VARCHAR(100) NOT NULL,
+ data_type VARCHAR(100) NOT NULL,
+ entry_schema VARCHAR(100) NULL DEFAULT NULL,
+ definition LONGTEXT NOT NULL,
+ description LONGTEXT NOT NULL,
+ tags LONGTEXT NOT NULL,
+ creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_by VARCHAR(100) NOT NULL,
+ primary key PK_RESOURCE_DICTIONARY (name),
+ INDEX IX_RESOURCE_DICTIONARY (name)
+) ENGINE=InnoDB;
|