diff options
author | andre.schmid <andre.schmid@est.tech> | 2019-09-30 17:47:27 +0100 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2019-11-03 16:44:13 +0000 |
commit | f34e28d521b71be501dc85e75c5efa411c3194f1 (patch) | |
tree | 461dba7844dda13f0aad36c660c64cade0833cdf /openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src | |
parent | 608be265c8491686f269ed12d5d48654ddb090b5 (diff) |
Validate artifacts signature in SOL004 package
Change-Id: Ib048f4501fd8a81cdf11fab19f149350011f772e
Issue-ID: SDC-2632
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src')
2 files changed, 34 insertions, 39 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java index 0b0c6e42f9..fa1de6751c 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java @@ -22,6 +22,27 @@ package org.openecomp.core.impl; +import static org.openecomp.core.converter.datatypes.Constants.ONAP_INDEX; +import static org.openecomp.core.converter.datatypes.Constants.definitionsDir; +import static org.openecomp.core.converter.datatypes.Constants.globalStName; +import static org.openecomp.core.converter.datatypes.Constants.globalSubstitution; +import static org.openecomp.core.converter.datatypes.Constants.mainStName; +import static org.openecomp.core.converter.datatypes.Constants.openecompHeatIndex; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.HEAT_INDEX_IMPORT_FILE; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.ONAP_INDEX_IMPORT_FILE; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_PATH_FILE_NAME; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.regex.Pattern; import org.apache.commons.collections.MapUtils; import org.onap.sdc.tosca.datatypes.model.Import; import org.onap.sdc.tosca.datatypes.model.NodeType; @@ -41,39 +62,13 @@ import org.openecomp.sdc.tosca.services.ToscaUtil; import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator; import org.yaml.snakeyaml.error.YAMLException; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.regex.Pattern; - -import static org.openecomp.core.converter.datatypes.Constants.ONAP_INDEX; -import static org.openecomp.core.converter.datatypes.Constants.definitionsDir; -import static org.openecomp.core.converter.datatypes.Constants.globalStName; -import static org.openecomp.core.converter.datatypes.Constants.globalSubstitution; -import static org.openecomp.core.converter.datatypes.Constants.mainStName; -import static org.openecomp.core.converter.datatypes.Constants.openecompHeatIndex; -import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME; -import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.HEAT_INDEX_IMPORT_FILE; -import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.ONAP_INDEX_IMPORT_FILE; -import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME; -import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME; - public abstract class AbstractToscaConverter implements ToscaConverter { - @Override - public abstract ToscaServiceModel convert(FileContentHandler fileContentHandler) throws IOException; - public abstract void convertTopologyTemplate(ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService); protected void handleMetadataFile(Map<String, byte[]> csarFiles) { - byte[] bytes = csarFiles.remove(TOSCA_META_PATH_FILE_NAME); + byte[] bytes = csarFiles.remove(TOSCA_META_PATH_FILE_NAME.getName()); if (bytes != null) { csarFiles.put(TOSCA_META_ORIG_PATH_FILE_NAME, bytes); } @@ -251,7 +246,7 @@ public abstract class AbstractToscaConverter implements ToscaConverter { } protected boolean isMetadataFile(String fileName) { - return fileName.equals(TOSCA_META_PATH_FILE_NAME); + return fileName.equals(TOSCA_META_PATH_FILE_NAME.getName()); } protected boolean isGlobalServiceTemplate(String fileName) { diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java index ce7024015b..4be9379c1e 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java @@ -22,6 +22,15 @@ package org.openecomp.core.impl; +import static org.openecomp.core.converter.datatypes.Constants.globalStName; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_PATH_FILE_NAME; + +import java.io.IOException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import org.onap.sdc.tosca.datatypes.model.ServiceTemplate; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.sdc.logging.api.Logger; @@ -30,15 +39,6 @@ import org.openecomp.sdc.tosca.csar.OnboardingToscaMetadata; import org.openecomp.sdc.tosca.csar.ToscaMetadata; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; -import java.io.IOException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import static org.openecomp.core.converter.datatypes.Constants.globalStName; -import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_DEFINITIONS; -import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME; public abstract class AbstractToscaSolConverter extends AbstractToscaConverter { @@ -96,8 +96,8 @@ public abstract class AbstractToscaSolConverter extends AbstractToscaConverter { private String getMainServiceDefinitionFileName(FileContentHandler contentHandler) throws IOException { try { ToscaMetadata toscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile( - contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME)); - return toscaMetadata.getMetaEntries().get(TOSCA_META_ENTRY_DEFINITIONS); + contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME.getName())); + return toscaMetadata.getMetaEntries().get(ENTRY_DEFINITIONS.getName()); } catch (IOException e) { LOGGER.error(e.getMessage(), e); throw new IOException(e.getMessage()); |