diff options
author | 2024-11-29 10:22:33 +0100 | |
---|---|---|
committer | 2024-11-29 12:09:29 +0100 | |
commit | da71728895dc8b095f43ddf0d22b46ea96152e51 (patch) | |
tree | 123d624a511fc80134752f087667c41a52f7dab0 /src/main | |
parent | 02dacdfc3f1f47103044375a4adcbb5b18c93ee7 (diff) |
Make babel runnable locally via mvn spring-boot:run
- make it runnable mvn spring-boot:run
- remove certificate related config
Issue-ID: AAI-4073
Change-Id: Ie5762dd3d1e79312d72e0611c1d61ce6cfaeb1c2
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/bin/start.sh | 16 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/babel/BabelApplication.java | 6 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/babel/JerseyConfiguration.java | 6 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/babel/config/PropertyPasswordConfiguration.java | 90 | ||||
-rw-r--r-- | src/main/resources/babel-auth.properties | 2 | ||||
-rw-r--r-- | src/main/resources/logback.xml | 2 | ||||
-rw-r--r-- | src/main/resources/tosca-mappings.json | 193 |
7 files changed, 200 insertions, 115 deletions
diff --git a/src/main/bin/start.sh b/src/main/bin/start.sh index 4d9912d..ed27c5a 100644 --- a/src/main/bin/start.sh +++ b/src/main/bin/start.sh @@ -27,30 +27,16 @@ if [ -z "${CONFIG_HOME}" ]; then exit 1 fi -#Either keystore password or server certs location must be passed. Both cannot be null -if [ -z "${KEY_STORE_PASSWORD}" -a -z "${SERVER_CERTS_LOCATION}" ]; then - echo "KEY_STORE_PASSWORD or SERVER_CERTS_LOCATION must be set in order to start the process" - exit 1 -fi - PROPS="-DAPP_HOME=${APP_HOME}" PROPS="${PROPS} -DCONFIG_HOME=${CONFIG_HOME}" PROPS="${PROPS} -Dtosca.mappings.config=${CONFIG_HOME}/tosca-mappings.json" -if [ ! -z "$KEY_STORE_PASSWORD" ]; then - PROPS="${PROPS} -DKEY_STORE_PASSWORD=${KEY_STORE_PASSWORD}" -fi - PROPS="${PROPS} -Dlogging.config=${APP_HOME}/config/logback.xml" if [ ! -z "$REQUIRE_CLIENT_AUTH" ]; then PROPS="$PROPS -Dserver.ssl.client-auth=${REQUIRE_CLIENT_AUTH}" fi -if [ ! -z "$SERVER_CERTS_LOCATION" ]; then - PROPS="$PROPS -Dserver.certs.location=${SERVER_CERTS_LOCATION}" - PROPS="$PROPS -Dserver.ssl.key-store=${SERVER_CERTS_LOCATION}/${SERVER_KEY_STORE}" - PROPS="$PROPS -Dserver.ssl.trust-store=${SERVER_CERTS_LOCATION}/${SERVER_TRUST_STORE}" -fi + PROPS="${PROPS} -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE}" PROPS="${PROPS} -Daaf.cadi.file=${CONFIG_HOME}/cadi.properties" PROPS="${PROPS} -Daaf.cadi.file=${CONFIG_HOME}/cadi.properties" diff --git a/src/main/java/org/onap/aai/babel/BabelApplication.java b/src/main/java/org/onap/aai/babel/BabelApplication.java index 4f67b21..3270af5 100644 --- a/src/main/java/org/onap/aai/babel/BabelApplication.java +++ b/src/main/java/org/onap/aai/babel/BabelApplication.java @@ -21,7 +21,6 @@ package org.onap.aai.babel; -import org.onap.aai.babel.config.PropertyPasswordConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @@ -46,14 +45,9 @@ public class BabelApplication extends SpringBootServletInitializer { * main args (expected to be null) */ public static void main(String[] args) { - String keyStorePassword = System.getProperty("KEY_STORE_PASSWORD"); - if (keyStorePassword == null || keyStorePassword.isEmpty()) { - throw new IllegalArgumentException("Mandatory property KEY_STORE_PASSWORD not set"); - } SpringApplication app = new SpringApplication(BabelApplication.class); app.setLogStartupInfo(false); app.setRegisterShutdownHook(true); - app.addInitializers(new PropertyPasswordConfiguration()); context = app.run(args); } diff --git a/src/main/java/org/onap/aai/babel/JerseyConfiguration.java b/src/main/java/org/onap/aai/babel/JerseyConfiguration.java index 84cda4d..ff8c5bb 100644 --- a/src/main/java/org/onap/aai/babel/JerseyConfiguration.java +++ b/src/main/java/org/onap/aai/babel/JerseyConfiguration.java @@ -31,9 +31,9 @@ import org.springframework.context.annotation.Configuration; public class JerseyConfiguration extends ResourceConfig { public JerseyConfiguration() { - packages("org.onap.aai.babel"); - // register(GenerateArtifactsControllerImpl.class); - // register(InfoService.class); + // packages("org.onap.aai.babel"); + register(GenerateArtifactsControllerImpl.class); + register(InfoService.class); } } diff --git a/src/main/java/org/onap/aai/babel/config/PropertyPasswordConfiguration.java b/src/main/java/org/onap/aai/babel/config/PropertyPasswordConfiguration.java deleted file mode 100644 index 7539d41..0000000 --- a/src/main/java/org/onap/aai/babel/config/PropertyPasswordConfiguration.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 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.aai.babel.config; - -import java.nio.charset.StandardCharsets; -import org.eclipse.jetty.util.security.Password; -import org.springframework.context.ApplicationContextInitializer; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.MapPropertySource; -import org.springframework.core.env.PropertySource; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Properties; - -public class PropertyPasswordConfiguration implements ApplicationContextInitializer<ConfigurableApplicationContext> { - - private static final String PROP_KEY_STORE_PASS = "server.ssl.key-store-password"; - - @Override - public void initialize(ConfigurableApplicationContext applicationContext) { - - Map<String, Object> sslProps = new LinkedHashMap<>(); - ConfigurableEnvironment environment = applicationContext.getEnvironment(); - String certPath = environment.getProperty("server.certs.location"); - String keystorePassword = null; - String truststorePassword = null; - - if (certPath != null) { - try (InputStream passwordStream = new FileInputStream(certPath + ".password")) { - keystorePassword = new String(passwordStream.readAllBytes(), StandardCharsets.UTF_8); - keystorePassword = keystorePassword.trim(); - sslProps.put(PROP_KEY_STORE_PASS, keystorePassword); - } catch (IOException e) { - keystorePassword = null; - } - try (InputStream passphrasesStream = new FileInputStream(certPath + ".passphrases");) { - Properties passphrasesProps = new Properties(); - passphrasesProps.load(passphrasesStream); - truststorePassword = passphrasesProps.getProperty("cadi_truststore_password"); - if (truststorePassword != null) { - truststorePassword = truststorePassword.trim(); - } - sslProps.put("server.ssl.trust-store-password", truststorePassword); - } catch (IOException e) { - truststorePassword = null; - } - } - if (keystorePassword == null || keystorePassword.isEmpty()) { - keystorePassword = System.getProperty("KEY_STORE_PASSWORD"); - if (keystorePassword != null && (!keystorePassword.isEmpty()) ) { - System.setProperty(PROP_KEY_STORE_PASS, new Password(keystorePassword).toString()); - } - if (keystorePassword == null || keystorePassword.isEmpty()) { - throw new IllegalArgumentException("Mandatory property KEY_STORE_PASSWORD not set"); - } - } - else { - sslProps.put(PROP_KEY_STORE_PASS, keystorePassword); - } - if (truststorePassword != null && !truststorePassword.isEmpty()) { - sslProps.put("server.ssl.trust-store-password", truststorePassword); - } - if (!sslProps.isEmpty()) { - PropertySource<?> additionalProperties = new MapPropertySource("additionalProperties", sslProps); - environment.getPropertySources().addFirst(additionalProperties); - } - } -} diff --git a/src/main/resources/babel-auth.properties b/src/main/resources/babel-auth.properties new file mode 100644 index 0000000..ba4e13a --- /dev/null +++ b/src/main/resources/babel-auth.properties @@ -0,0 +1,2 @@ +auth.policy.file=/auth/auth_policy.json +auth.authentication.disable=true
\ No newline at end of file diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 74d2ae0..98c626b 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -23,7 +23,7 @@ To find main logging config please check `logging.config` in the application.pro <include resource="org/springframework/boot/logging/logback/base.xml" /> <property name="componentName" value="AAI-BAS" /> - <property name="logDirectory" value="/var/log/onap/${componentName}" /> + <property name="logDirectory" value="${LOG_DIRECTORY:-.}/${componentName}" /> <!-- default EELF log file names --> <property name="generalLogName" value="error" /> diff --git a/src/main/resources/tosca-mappings.json b/src/main/resources/tosca-mappings.json new file mode 100644 index 0000000..32491f6 --- /dev/null +++ b/src/main/resources/tosca-mappings.json @@ -0,0 +1,193 @@ +{ + "instanceGroupTypes": [ + "org.openecomp.groups.NetworkCollection", + "org.openecomp.groups.VfcInstanceGroup", + "org.openecomp.groups.ResourceInstanceGroup" + ], + "widgetTypes": [ + { + "type": "SERVICE", + "name": "service-instance", + "deleteFlag": true, + "modelInvariantId": "service-instance-invariant-id", + "modelVersionId": "service-instance-version-id" + }, + { + "type": "VF", + "name": "generic-vnf", + "deleteFlag": true, + "modelInvariantId": "generic-vnf-invariant-id", + "modelVersionId": "generic-vnf-version-id" + }, + { + "type": "VFC", + "name": "vnfc", + "deleteFlag": true, + "modelInvariantId": "vnfc-invariant-id", + "modelVersionId": "vnfc-version-id" + }, + { + "type": "VSERVER", + "name": "vserver", + "deleteFlag": true, + "modelInvariantId": "vserver-invariant-id", + "modelVersionId": "vserver-version-id" + }, + { + "type": "VOLUME", + "name": "volume", + "deleteFlag": true, + "modelInvariantId": "volume-invariant-id", + "modelVersionId": "volume-version-id" + }, + { + "type": "FLAVOR", + "name": "flavor", + "deleteFlag": false, + "modelInvariantId": "flavor-invariant-id", + "modelVersionId": "flavor-version-id" + }, + { + "type": "TENANT", + "name": "tenant", + "deleteFlag": false, + "modelInvariantId": "tenant-invariant-id", + "modelVersionId": "tenant-version-id" + }, + { + "type": "VOLUME_GROUP", + "name": "volume-group", + "deleteFlag": true, + "modelInvariantId": "volume-group-invariant-id", + "modelVersionId": "volume-group-version-id" + }, + { + "type": "LINT", + "name": "l-interface", + "deleteFlag": true, + "modelInvariantId": "l-interface-invariant-id", + "modelVersionId": "l-interface-version-id" + }, + { + "type": "L3_NET", + "name": "l3-network", + "deleteFlag": true, + "modelInvariantId": "l3-network-invariant-id", + "modelVersionId": "l3-network-version-id" + }, + { + "type": "VFMODULE", + "name": "vf-module", + "deleteFlag": true, + "modelInvariantId": "vf-module-invariant-id", + "modelVersionId": "vf-module-version-id" + }, + { + "type": "IMAGE", + "name": "image", + "deleteFlag": false, + "modelInvariantId": "image-invariant-id", + "modelVersionId": "image-version-id" + }, + { + "type": "OAM_NETWORK", + "name": "oam-network", + "deleteFlag": true, + "modelInvariantId": "oam-network-invariant-id", + "modelVersionId": "oam-network-version-id" + }, + { + "type": "ALLOTTED_RESOURCE", + "name": "allotted-resource", + "deleteFlag": true, + "modelInvariantId": "allotted-resource-invariant-id", + "modelVersionId": "allotted-resource-version-id" + }, + { + "type": "TUNNEL_XCONNECT", + "name": "tunnel-xconnect", + "deleteFlag": true, + "modelInvariantId": "tunnel-xconnect-invariant-id", + "modelVersionId": "tunnel-xconnect-version-id" + }, + { + "type": "CONFIGURATION", + "name": "configuration", + "deleteFlag": true, + "modelInvariantId": "configuration-invariant-id", + "modelVersionId": "configuration-version-id" + }, + { + "type": "CR", + "name": "cr", + "deleteFlag": true, + "modelInvariantId": "collection-resource-invariant-id", + "modelVersionId": "collection-resource-version-id" + }, + { + "type": "INSTANCE_GROUP", + "name": "instance-group", + "deleteFlag": true, + "modelInvariantId": "instance-group-invariant-id", + "modelVersionId": "instance-group-version-id" + }, + { + "type": "PNF", + "name": "pnf", + "deleteFlag": true, + "modelInvariantId": "pnf-instance-invariant-id", + "modelVersionId": "pnf-instance-version-id" + } + ], + "widgetMappings": [ + { + "prefix": "org.openecomp.resource.vfc", + "type": "widget", + "widget": "VSERVER", + "deleteFlag": true + }, + { + "prefix": "org.openecomp.resource.cp", + "type": "widget", + "widget": "LINT", + "deleteFlag": true + }, + { + "prefix": "org.openecomp.cp", + "type": "widget", + "widget": "LINT", + "deleteFlag": true + }, + { + "prefix": "org.openecomp.resource.vl", + "widget": "L3_NET", + "deleteFlag": false + }, + { + "prefix": "org.openecomp.resource.vf", + "widget": "VF", + "deleteFlag": true + }, + { + "prefix": "org.openecomp.groups.vfmodule", + "widget": "VFMODULE", + "deleteFlag": true + }, + { + "prefix": "org.openecomp.groups.VfModule", + "widget": "VFMODULE", + "deleteFlag": true + }, + { + "prefix": "org.openecomp.resource.vfc.nodes.heat.cinder", + "type": "widget", + "widget": "VOLUME", + "deleteFlag": true + }, + { + "prefix": "org.openecomp.resource.pnf", + "widget": "PNF", + "deleteFlag": true + } + ] +} |