aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2019-08-30 18:20:32 +0100
committerOren Kleks <orenkle@amdocs.com>2019-10-24 06:15:28 +0000
commit78f88751aa64fb72fd6321346929bd1d94f716a9 (patch)
tree58cabd13dcfbad357729ef338c8e2dca3255f1fb /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main
parent105ce0729d5333cc095ef5bd8104a6c5b90cc9f0 (diff)
Fix and refactor manifest parsing
Fix a CMS signature reading expected token. Fix the necessity of a empty line in the end of the manifest. Implement CMS signature, Source checksum algorithm and digest reading. Indicate the line number and content when a manifest error occurs. Remove unnecessary recursive reading. Centralize manifest tokens. Improve tests by checking the expected error. Document the code. Change-Id: I7d12020d8922fc5d4c8d9f238557dfbcc0b65757 Issue-ID: SDC-2563 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java27
1 files changed, 16 insertions, 11 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java
index c7fd225c76..eff1fb31cd 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java
@@ -19,12 +19,17 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ALGORITHM;
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.HASH;
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.METADATA;
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.NON_MANO_ARTIFACT_SETS;
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.SOURCE;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
-import org.openecomp.sdc.tosca.csar.CSARConstants;
/**
* Builds SOL0004 manifest file as a String.
@@ -73,8 +78,8 @@ public class ManifestBuilder {
*/
public ManifestBuilder withSignedSource(final String sourcePath, final String hashAlgorithm, final String hash) {
TreeMap<String, String> sourcePropertiesMap = new TreeMap<>();
- sourcePropertiesMap.put(CSARConstants.ALGORITHM_MF_ATTRIBUTE, hashAlgorithm);
- sourcePropertiesMap.put(CSARConstants.HASH_MF_ATTRIBUTE, hash);
+ sourcePropertiesMap.put(ALGORITHM.getToken(), hashAlgorithm);
+ sourcePropertiesMap.put(HASH.getToken(), hash);
sourceWithPropertiesMap.put(sourcePath, sourcePropertiesMap);
return this;
}
@@ -119,7 +124,7 @@ public class ManifestBuilder {
private String buildMetadata() {
final StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append(String.format(SECTION_FORMAT, CSARConstants.METADATA_MF_ATTRIBUTE));
+ stringBuilder.append(String.format(SECTION_FORMAT, METADATA.getToken()));
for (Entry<String, String> metadataAndValue : metadataMap.entrySet()) {
stringBuilder.append("\t");
stringBuilder.append(String.format(PROPERTY_FORMAT, metadataAndValue.getKey(), metadataAndValue.getValue()));
@@ -131,17 +136,17 @@ public class ManifestBuilder {
private String buildSource() {
final StringBuilder stringBuilder = new StringBuilder();
for (final Entry<String, Map<String, String>> signedSourceMap : sourceWithPropertiesMap.entrySet()) {
- stringBuilder.append(String.format(PROPERTY_FORMAT, CSARConstants.SOURCE_MF_ATTRIBUTE, signedSourceMap.getKey()));
+ stringBuilder.append(String.format(PROPERTY_FORMAT, SOURCE.getToken(), signedSourceMap.getKey()));
final Map<String, String> propertiesMap = signedSourceMap.getValue();
if (propertiesMap != null && !propertiesMap.isEmpty()) {
- final String algorithm = propertiesMap.get(CSARConstants.ALGORITHM_MF_ATTRIBUTE);
+ final String algorithm = propertiesMap.get(ALGORITHM.getToken());
if (algorithm != null) {
- stringBuilder.append(String.format(PROPERTY_FORMAT, CSARConstants.ALGORITHM_MF_ATTRIBUTE, algorithm));
+ stringBuilder.append(String.format(PROPERTY_FORMAT, ALGORITHM.getToken(), algorithm));
}
- final String hash = propertiesMap.get(CSARConstants.HASH_MF_ATTRIBUTE);
+ final String hash = propertiesMap.get(HASH.getToken());
if (hash != null) {
- stringBuilder.append(String.format(PROPERTY_FORMAT, CSARConstants.HASH_MF_ATTRIBUTE, hash));
+ stringBuilder.append(String.format(PROPERTY_FORMAT, HASH.getToken(), hash));
}
}
}
@@ -151,13 +156,13 @@ public class ManifestBuilder {
private String buildNonManoArtifact() {
final StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append(String.format(SECTION_FORMAT, CSARConstants.NON_MANO_MF_ATTRIBUTE));
+ stringBuilder.append(String.format(SECTION_FORMAT, NON_MANO_ARTIFACT_SETS.getToken()));
for (Entry<String, List<String>> artifactTypeAndSourcesEntry : nonManoArtifactMap.entrySet()) {
stringBuilder.append("\t");
stringBuilder.append(String.format(SECTION_FORMAT, artifactTypeAndSourcesEntry.getKey()));
for (String source : artifactTypeAndSourcesEntry.getValue()) {
stringBuilder.append("\t\t");
- stringBuilder.append(String.format(PROPERTY_FORMAT, CSARConstants.SOURCE_MF_ATTRIBUTE, source));
+ stringBuilder.append(String.format(PROPERTY_FORMAT, SOURCE.getToken(), source));
}
}
return stringBuilder.toString();