diff options
author | Carsten Lund <lund@research.att.com> | 2017-06-09 16:33:47 +0000 |
---|---|---|
committer | Carsten Lund <lund@research.att.com> | 2017-06-09 16:33:47 +0000 |
commit | c4eb1d5671e95358b9864dc80d1fee4a3a2d49ad (patch) | |
tree | 327e99521a8cb0bd2b2499dbf6eb52b01a0d096f | |
parent | 4458bfeff660e31cb21fd8d2c9d4a78fc2f64d7d (diff) |
Change-Id: Ic808bf2a8b2a167b8dd62e75fafb46242c1fdb90
Signed-off-by: Carsten Lund <lund@research.att.com>
4 files changed, 43 insertions, 22 deletions
diff --git a/LICENSE.txt b/LICENSE.txt index 1183595..30471b5 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,13 +1,15 @@ -/* + +/*- * ============LICENSE_START========================================== + * OPENECOMP - DCAE * =================================================================== - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2017 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 + * 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, @@ -15,6 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * */ + +ECOMP and OpenECOMP are trademarks and service marks of AT&T Intellectual Property. diff --git a/operation-utils/src/main/java/org/openecomp/entity/EcompSubComponentInstance.java b/operation-utils/src/main/java/org/openecomp/entity/EcompSubComponentInstance.java index 2654dea..eece518 100644 --- a/operation-utils/src/main/java/org/openecomp/entity/EcompSubComponentInstance.java +++ b/operation-utils/src/main/java/org/openecomp/entity/EcompSubComponentInstance.java @@ -27,6 +27,8 @@ import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; +import org.openecomp.ncomp.utils.SecurityUtils; + public class EcompSubComponentInstance { private static final Logger logger = Logger.getLogger(EcompSubComponentInstance.class.getName()); @@ -51,10 +53,9 @@ public class EcompSubComponentInstance { uuid = instanceID; if (serverIP == null || serverName == null || ("").equals(serverIP) || ("").equals(serverName)) { try { - InetAddress server = InetAddress.getLocalHost(); - serverIP = server.getHostAddress(); - serverName = server.getCanonicalHostName(); - } catch (UnknownHostException e) { + serverIP = SecurityUtils.getHostAddress(); + serverName = SecurityUtils.getCanonicalHostName(); + } catch (Exception e) { logger.log(Level.SEVERE, "Could not get local hostname", e); serverIP = ""; serverName = ""; diff --git a/operation-utils/src/main/java/org/openecomp/utils/ConvertMessagePropertiesToYaml.java b/operation-utils/src/main/java/org/openecomp/utils/ConvertMessagePropertiesToYaml.java index 28026d6..aa4babf 100644 --- a/operation-utils/src/main/java/org/openecomp/utils/ConvertMessagePropertiesToYaml.java +++ b/operation-utils/src/main/java/org/openecomp/utils/ConvertMessagePropertiesToYaml.java @@ -40,7 +40,13 @@ public class ConvertMessagePropertiesToYaml { Properties props = new Properties(); String pname = "GenericMessages.properties"; String fname = "src/main/resources/GenericMessages.yaml"; - props.load(ConvertMessagePropertiesToYaml.class.getClassLoader().getResourceAsStream(pname)); + InputStream in = null; + try { + in = ConvertMessagePropertiesToYaml.class.getClassLoader().getResourceAsStream(pname); + props.load(in); + } finally { + if (in != null) in.close(); + } DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); Yaml y = new Yaml(options); diff --git a/operation-utils/src/main/java/org/openecomp/utils/YamlToJava.java b/operation-utils/src/main/java/org/openecomp/utils/YamlToJava.java index fb3b1f4..f21d951 100644 --- a/operation-utils/src/main/java/org/openecomp/utils/YamlToJava.java +++ b/operation-utils/src/main/java/org/openecomp/utils/YamlToJava.java @@ -18,7 +18,7 @@ * limitations under the License. * ============LICENSE_END============================================ */ - + package org.openecomp.utils; import java.io.ByteArrayOutputStream; @@ -39,6 +39,7 @@ import groovy.lang.Writable; import groovy.text.SimpleTemplateEngine; import org.openecomp.ncomp.utils.PropertyUtil; +import org.openecomp.ncomp.utils.SecurityUtils; import org.openecomp.ncomp.webservice.utils.FileUtils; public class YamlToJava { @@ -66,6 +67,7 @@ public class YamlToJava { String packageName) { try { System.out.println("Enterting YAML Convert)"); + yamlFileName = SecurityUtils.safeFileName(yamlFileName); if (!(new File(yamlFileName).exists())) { System.err.println(yamlFileName + " does not exists"); return; @@ -108,13 +110,19 @@ public class YamlToJava { } private static String getTemplate(String res) throws IOException { - InputStream in = YamlToJava.class.getClassLoader().getResourceAsStream(res); - if (in == null) { - throw new RuntimeException("Unable to find resource: " + res); + InputStream in = null; + try { + in = YamlToJava.class.getClassLoader().getResourceAsStream(res); + if (in == null) { + throw new RuntimeException("Unable to find resource: " + res); + } + ByteArrayOutputStream o = new ByteArrayOutputStream(); + FileUtils.copyStream(in, o); + return o.toString(); + } finally { + if (in != null) + in.close(); } - ByteArrayOutputStream o = new ByteArrayOutputStream(); - FileUtils.copyStream(in, o); - return o.toString(); } public static void main(String[] args) throws IOException { @@ -130,8 +138,10 @@ public class YamlToJava { String javaDest = (String) (m.containsKey("java-root") ? m.get("java-root") : "src/main/java-gen"); String resourcesDest = (String) (m.containsKey("resources-root") ? m.get("resources-root") : "src/main/resources-gen"); - if (! javaDest.startsWith("/")) javaDest = baseDir + "/" + javaDest; - if (! resourcesDest.startsWith("/")) resourcesDest = baseDir + "/" + resourcesDest; + if (!javaDest.startsWith("/")) + javaDest = baseDir + "/" + javaDest; + if (!resourcesDest.startsWith("/")) + resourcesDest = baseDir + "/" + resourcesDest; String packageName = (String) m.get("package-name"); if (packageName == null) { System.err.println("No package-name attribute in: " + args[0]); @@ -153,11 +163,12 @@ public class YamlToJava { } private static String findBaseDir(String filename) { - File f = new File(filename); + File f = new File(SecurityUtils.safeFileName(filename)); f = f.getParentFile(); while (f != null) { - File pom = new File(f,"pom.xml"); - if (pom.exists()) return f.getAbsolutePath(); + File pom = new File(f, "pom.xml"); + if (pom.exists()) + return f.getAbsolutePath(); f = f.getParentFile(); } return "."; @@ -165,6 +176,7 @@ public class YamlToJava { @SuppressWarnings("unchecked") private static Map<String, Object> file2yaml(String yamlFileName) { + yamlFileName = SecurityUtils.safeFileName(yamlFileName); if (!(new File(yamlFileName).exists())) { System.err.println(yamlFileName + " does not exists"); System.exit(2); |