summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/main
diff options
context:
space:
mode:
authorBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2020-12-08 09:52:24 +0100
committerBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2020-12-10 09:26:40 +0100
commita2068b518a880600b18ce1ca29540fa680fa86f2 (patch)
tree68fa939219be62e4d5eaa8adbd584df22eb15c06 /csarvalidation/src/main
parentaedd6d19874b046f1e72026dd4a9cdc0aad39172 (diff)
Add fields for signature and certificate in source model.
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> Change-Id: I0783dd9f78c0138fba871d0977e4cd8305891872 Issue-ID: VNFSDK-714
Diffstat (limited to 'csarvalidation/src/main')
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/parser/ManifestConsts.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/parser/SourcesParser.java79
2 files changed, 64 insertions, 17 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/ManifestConsts.java b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/ManifestConsts.java
index afa0e2d..59131de 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/ManifestConsts.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/ManifestConsts.java
@@ -24,6 +24,8 @@ final class ManifestConsts {
static final String SOURCE_TAG_SECTION = "source";
static final String ALGORITHM = "algorithm";
static final String HASH = "hash";
+ static final String SIGNATURE = "signature";
+ static final String CERTIFICATE = "certificate";
static final String NON_MANO_ARTIFACT_SETS_TAG_SECTION = "non_mano_artifact_sets";
static final String PRODUCT_NAME = "pnfd_name";
static final String PROVIDER_ID = "pnfd_provider";
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/SourcesParser.java b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/SourcesParser.java
index 9cbef8a..b25fc40 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/SourcesParser.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/SourcesParser.java
@@ -54,6 +54,10 @@ public class SourcesParser {
handleAlgorithmLine(errors, source, lineNumber, manifestLine);
} else if (!isSpecialTagReached && manifestLine.startsWith(HASH)) {
handleHashLine(errors, source, lineNumber, manifestLine);
+ } else if (!isSpecialTagReached && manifestLine.startsWith(SIGNATURE)) {
+ handleSignatureLine(errors, source, lineNumber, manifestLine);
+ } else if (!isSpecialTagReached && manifestLine.startsWith(CERTIFICATE)) {
+ handleCertificateLine(errors, source, lineNumber, manifestLine);
}
}
@@ -62,8 +66,8 @@ public class SourcesParser {
private boolean isContainSpecialTag(String line, ManifestLine manifestLine) {
return manifestLine.startsWith(METADATA_SECTION_TAG_SECTION)
- || manifestLine.startsWith(NON_MANO_ARTIFACT_SETS_TAG_SECTION)
- || line.contains(CMS);
+ || manifestLine.startsWith(NON_MANO_ARTIFACT_SETS_TAG_SECTION)
+ || line.contains(CMS);
}
private Source handleSourceLine(List<Source> sources, List<CSARArchive.CSARError> errors, int lineNumber, ManifestLine manifestLine) {
@@ -80,14 +84,30 @@ public class SourcesParser {
private void handleAlgorithmLine(List<CSARArchive.CSARError> errors, Source source, int lineNumber, ManifestLine manifestLine) {
String algorithm = parseSourceSectionLine(manifestLine, lineNumber, errors);
- if (source != null)
+ if (source != null) {
source.setAlgorithm(algorithm);
+ }
}
private void handleHashLine(List<CSARArchive.CSARError> errors, Source source, int lineNumber, ManifestLine manifestLine) {
String hash = parseSourceSectionLine(manifestLine, lineNumber, errors);
- if (source != null)
+ if (source != null) {
source.setHash(hash);
+ }
+ }
+
+ private void handleSignatureLine(List<CSARArchive.CSARError> errors, Source source, int lineNumber, ManifestLine manifestLine) {
+ String signature = parseSourceSectionLine(manifestLine, lineNumber, errors);
+ if (source != null) {
+ source.setSignature(signature);
+ }
+ }
+
+ private void handleCertificateLine(List<CSARArchive.CSARError> errors, Source source, int lineNumber, ManifestLine manifestLine) {
+ String certificate = parseSourceSectionLine(manifestLine, lineNumber, errors);
+ if (source != null) {
+ source.setCertificate(certificate);
+ }
}
private String parseSourceSectionLine(ManifestLine line, int lineNumber, List<CSARArchive.CSARError> errors) {
@@ -110,12 +130,19 @@ public class SourcesParser {
private final String value;
private String algorithm;
private String hash;
+ private String signature;
+ private String certificate;
- public Source(String value, String algorithm, String hash) {
-
+ public Source(String value, String algorithm, String hash, String signature, String certificate) {
this.value = value;
this.algorithm = algorithm;
this.hash = hash;
+ this.signature = signature;
+ this.certificate = certificate;
+ }
+
+ public Source(String source, String algorithm, String hash) {
+ this(source, algorithm, hash, "", "");
}
public Source(String source) {
@@ -142,34 +169,52 @@ public class SourcesParser {
this.hash = hash;
}
+ public String getSignature() {
+ return signature;
+ }
+
+ public void setSignature(String signature) {
+ this.signature = signature;
+ }
+
+ public String getCertificate() {
+ return certificate;
+ }
+
+ public void setCertificate(String certificate) {
+ this.certificate = certificate;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
-
if (o == null || getClass() != o.getClass()) {
return false;
}
-
- Source source1 = (Source) o;
- return Objects.equals(value, source1.value) &&
- Objects.equals(algorithm, source1.algorithm) &&
- Objects.equals(hash, source1.hash);
+ Source source = (Source) o;
+ return Objects.equals(value, source.value) &&
+ Objects.equals(algorithm, source.algorithm) &&
+ Objects.equals(hash, source.hash) &&
+ Objects.equals(signature, source.signature) &&
+ Objects.equals(certificate, source.certificate);
}
@Override
public int hashCode() {
- return Objects.hash(value, algorithm, hash);
+ return Objects.hash(value, algorithm, hash, signature, certificate);
}
@Override
public String toString() {
return "Source{" +
- "value='" + value + '\'' +
- ", algorithm='" + algorithm + '\'' +
- ", hash='" + hash + '\'' +
- '}';
+ "value='" + value + '\'' +
+ ", algorithm='" + algorithm + '\'' +
+ ", hash='" + hash + '\'' +
+ ", signature='" + signature + '\'' +
+ ", certificate='" + certificate + '\'' +
+ '}';
}
}
}