aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/main/java')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java2
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ManifestTokenType.java5
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java52
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SignatureData.java35
4 files changed, 91 insertions, 3 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java
index 326eb6a517..372517c5f9 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java
@@ -1,6 +1,7 @@
/*
* Copyright © 2016-2017 European Support Limited
* Modification Copyright (C) 2019 Nordix Foundation.
+ * Modification Copyright (C) 2021 Nokia.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,6 +47,7 @@ abstract class AbstractOnboardingManifest implements Manifest {
protected List<String> sources;
protected Map<String, List<String>> nonManoSources;
protected Map<String, AlgorithmDigest> sourceAndChecksumMap = new HashMap<>();
+ protected Map<String, SignatureData> sourceAndSignatureMap = new HashMap<>();
protected String cmsSignature;
protected List<String> errors;
protected boolean continueToProcess;
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ManifestTokenType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ManifestTokenType.java
index 68ad91d29a..2e073a431a 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ManifestTokenType.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ManifestTokenType.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation
+ * Modification Copyright (C) 2021 Nokia.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +39,9 @@ public enum ManifestTokenType {
PNFD_NAME("pnfd_name"),
PNFD_PROVIDER("pnfd_provider"),
PNFD_ARCHIVE_VERSION("pnfd_archive_version"),
- PNFD_RELEASE_DATE_TIME("pnfd_release_date_time");
+ PNFD_RELEASE_DATE_TIME("pnfd_release_date_time"),
+ SIGNATURE("Signature"),
+ CERTIFICATE("Certificate");
private final String token;
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java
index 8e67d7b5de..99ea9a5a13 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modification Copyright (C) 2021 Nokia.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -275,7 +276,9 @@ public class SOL004ManifestOnboarding extends AbstractOnboardingManifest {
return;
}
sources.add(sourcePath);
+ readNextNonEmptyLine();
readAlgorithmEntry(sourcePath);
+ readSignatureEntry(sourcePath);
}
/**
@@ -285,7 +288,7 @@ public class SOL004ManifestOnboarding extends AbstractOnboardingManifest {
* @param sourcePath the source path related to the algorithm entry.
*/
private void readAlgorithmEntry(final String sourcePath) {
- Optional<String> currentLine = readNextNonEmptyLine();
+ Optional<String> currentLine = getCurrentLine();
if (!currentLine.isPresent()) {
return;
}
@@ -324,4 +327,49 @@ public class SOL004ManifestOnboarding extends AbstractOnboardingManifest {
readNextNonEmptyLine();
}
-} \ No newline at end of file
+ /**
+ * Processes entries {@link ManifestTokenType#SIGNATURE} and {@link ManifestTokenType#CERTIFICATE} of a {@link
+ * ManifestTokenType#SOURCE} entry.
+ *
+ * @param sourcePath the source path related to the algorithm entry.
+ */
+ private void readSignatureEntry(final String sourcePath) {
+ Optional<String> currentLine = getCurrentLine();
+ if (!currentLine.isPresent()) {
+ return;
+ }
+ final ManifestTokenType manifestTokenType = detectLineEntry().orElse(null);
+ if (manifestTokenType == ManifestTokenType.CERTIFICATE) {
+ reportError(Messages.MANIFEST_EXPECTED_SIGNATURE_BEFORE_CERTIFICATE);
+ continueToProcess = false;
+ return;
+ }
+ if (manifestTokenType != ManifestTokenType.SIGNATURE) {
+ return;
+ }
+ final String signatureLine = currentLine.get();
+ final String signatureFile = readEntryValue(signatureLine).orElse(null);
+ if (signatureFile == null) {
+ reportError(Messages.MANIFEST_EXPECTED_SIGNATURE_VALUE);
+ continueToProcess = false;
+ return;
+ }
+
+ currentLine = readNextNonEmptyLine();
+ if (!currentLine.isPresent() || detectLineEntry().orElse(null) != ManifestTokenType.CERTIFICATE) {
+ sourceAndSignatureMap.put(sourcePath, new SignatureData(signatureFile, null));
+ return;
+ }
+
+ final String certLine = currentLine.get();
+ final String certFile = readEntryValue(certLine).orElse(null);
+ if (certFile == null) {
+ reportError(Messages.MANIFEST_EXPECTED_CERTIFICATE_VALUE);
+ continueToProcess = false;
+ return;
+ }
+ sourceAndSignatureMap.put(sourcePath, new SignatureData(signatureFile, certFile));
+ readNextNonEmptyLine();
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SignatureData.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SignatureData.java
new file mode 100644
index 0000000000..74277a627f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SignatureData.java
@@ -0,0 +1,35 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nokia
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.tosca.csar;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.springframework.lang.Nullable;
+
+/**
+ * Represents a manifest individual Signature and Certificate
+ */
+@Getter
+@AllArgsConstructor
+public class SignatureData {
+ private final String signatureFile;
+ @Nullable
+ private final String certificateFile;
+}