Skip to content

Commit

Permalink
DSS-3372 : improve messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bsanchezb committed Jul 10, 2024
1 parent cab3adb commit 48c50c3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public enum MessageTag {
BBB_CV_ER_ATSSRI_ANS,
BBB_CV_ISMEC,
BBB_CV_ISMEC_ANS,
BBB_CV_ISMEC_ANS_2,
BBB_CV_AAMEF,
BBB_CV_AAMEF_ANS,
BBB_CV_ER_TST_RN,
Expand Down
3 changes: 2 additions & 1 deletion dss-i18n/src/main/resources/dss-messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ BBB_CV_ER_ATSSRI=Is the previous archive time-stamp sequence reference intact?
BBB_CV_ER_ATSSRI_ANS=The previous archive time-stamp sequence reference is not intact!
BBB_CV_ISMEC=Is the validation of manifest entries performed?
BBB_CV_ISMEC_ANS=The validation of manifest entries is not performed!
BBB_CV_ISMEC_ANS_2=None of the manifest entries have been found!
BBB_CV_AAMEF=Have all manifest entries been found?
BBB_CV_AAMEF_ANS=Not all manifest entries have been found!
BBB_CV_AAMEF_ANS=Some manifest entries have not been found!
BBB_CV_ER_TST_RN=Is the validation of hashtree renewal time-stamp conclusive?
BBB_CV_ER_TST_RN_ANS_1=The hashtree renewal time-stamp does not cover all original archive data objects!
BBB_CV_ER_TST_RN_ANS_2=Digest value(s) found in the hashtree renewal time-stamp does not match original archive data objects!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private boolean containsManifest(List<XmlDigestMatcher> digestMatchers) {
}

private boolean containsManifestEntries(List<XmlDigestMatcher> digestMatchers) {
return digestMatchers.stream().anyMatch(d -> DigestMatcherType.MANIFEST_ENTRY == d.getType());
return digestMatchers.stream().anyMatch(d -> DigestMatcherType.MANIFEST_ENTRY == d.getType() && d.isDataFound());
}

private ChainItem<XmlCV> referenceDataFound(XmlDigestMatcher digestMatcher) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
import eu.europa.esig.dss.i18n.I18nProvider;
import eu.europa.esig.dss.i18n.MessageTag;
import eu.europa.esig.dss.policy.jaxb.LevelConstraint;
import eu.europa.esig.dss.utils.Utils;
import eu.europa.esig.dss.validation.process.ChainItem;

import java.util.List;
import java.util.stream.Collectors;

/**
* Checks if at least one manifest entry is present
Expand Down Expand Up @@ -72,6 +74,10 @@ protected MessageTag getMessageTag() {

@Override
protected MessageTag getErrorMessageTag() {
List<XmlDigestMatcher> manifestEntries = digestMatchers.stream().filter(d -> DigestMatcherType.MANIFEST_ENTRY == d.getType()).collect(Collectors.toList());
if (Utils.isCollectionNotEmpty(manifestEntries) && manifestEntries.stream().noneMatch(XmlDigestMatcher::isDataFound)) {
return MessageTag.BBB_CV_ISMEC_ANS_2;
}
return MessageTag.BBB_CV_ISMEC_ANS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ void manifestValidationAllStrictNoFoundAll() throws Exception {
assertEquals(Indication.INDETERMINATE, simpleReport.getIndication(simpleReport.getFirstSignatureId()));
assertEquals(SubIndication.SIGNED_DATA_NOT_FOUND, simpleReport.getSubIndication(simpleReport.getFirstSignatureId()));
assertTrue(checkMessageValuePresence(simpleReport.getAdESValidationErrors(simpleReport.getFirstSignatureId()),
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS)));
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS_2)));

DetailedReport detailedReport = reports.getDetailedReport();
XmlBasicBuildingBlocks signatureBBB = detailedReport.getBasicBuildingBlockById(detailedReport.getFirstSignatureId());
Expand All @@ -599,7 +599,7 @@ void manifestValidationAllStrictNoFoundAll() throws Exception {
for (XmlConstraint constraint : cv.getConstraint()) {
if (MessageTag.BBB_CV_ISMEC.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.NOT_OK, constraint.getStatus());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS.getId(), constraint.getError().getKey());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS_2.getId(), constraint.getError().getKey());
++digestMatcherValidationPerformedCounter;
} else if (MessageTag.BBB_CV_AAMEF.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.OK, constraint.getStatus());
Expand Down Expand Up @@ -1029,7 +1029,7 @@ void manifestValidationAllLaxNoFoundAll() throws Exception {
assertEquals(Indication.INDETERMINATE, simpleReport.getIndication(simpleReport.getFirstSignatureId()));
assertEquals(SubIndication.SIGNED_DATA_NOT_FOUND, simpleReport.getSubIndication(simpleReport.getFirstSignatureId()));
assertTrue(checkMessageValuePresence(simpleReport.getAdESValidationErrors(simpleReport.getFirstSignatureId()),
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS)));
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS_2)));

DetailedReport detailedReport = reports.getDetailedReport();
XmlBasicBuildingBlocks signatureBBB = detailedReport.getBasicBuildingBlockById(detailedReport.getFirstSignatureId());
Expand All @@ -1048,7 +1048,7 @@ void manifestValidationAllLaxNoFoundAll() throws Exception {
for (XmlConstraint constraint : cv.getConstraint()) {
if (MessageTag.BBB_CV_ISMEC.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.NOT_OK, constraint.getStatus());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS.getId(), constraint.getError().getKey());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS_2.getId(), constraint.getError().getKey());
++digestMatcherValidationPerformedCounter;
} else if (MessageTag.BBB_CV_AAMEF.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.OK, constraint.getStatus());
Expand Down Expand Up @@ -1486,7 +1486,7 @@ void manifestValidationPartialStrictNoFoundAll() throws Exception {
assertEquals(Indication.INDETERMINATE, simpleReport.getIndication(simpleReport.getFirstSignatureId()));
assertEquals(SubIndication.SIGNED_DATA_NOT_FOUND, simpleReport.getSubIndication(simpleReport.getFirstSignatureId()));
assertTrue(checkMessageValuePresence(simpleReport.getAdESValidationErrors(simpleReport.getFirstSignatureId()),
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS)));
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS_2)));

DetailedReport detailedReport = reports.getDetailedReport();
XmlBasicBuildingBlocks signatureBBB = detailedReport.getBasicBuildingBlockById(detailedReport.getFirstSignatureId());
Expand All @@ -1505,7 +1505,7 @@ void manifestValidationPartialStrictNoFoundAll() throws Exception {
for (XmlConstraint constraint : cv.getConstraint()) {
if (MessageTag.BBB_CV_ISMEC.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.NOT_OK, constraint.getStatus());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS.getId(), constraint.getError().getKey());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS_2.getId(), constraint.getError().getKey());
++digestMatcherValidationPerformedCounter;
} else if (MessageTag.BBB_CV_AAMEF.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.OK, constraint.getStatus());
Expand Down Expand Up @@ -1936,7 +1936,7 @@ void manifestValidationPartialLaxNoFoundAll() throws Exception {
assertEquals(Indication.INDETERMINATE, simpleReport.getIndication(simpleReport.getFirstSignatureId()));
assertEquals(SubIndication.SIGNED_DATA_NOT_FOUND, simpleReport.getSubIndication(simpleReport.getFirstSignatureId()));
assertTrue(checkMessageValuePresence(simpleReport.getAdESValidationErrors(simpleReport.getFirstSignatureId()),
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS)));
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS_2)));

DetailedReport detailedReport = reports.getDetailedReport();
XmlBasicBuildingBlocks signatureBBB = detailedReport.getBasicBuildingBlockById(detailedReport.getFirstSignatureId());
Expand All @@ -1955,7 +1955,7 @@ void manifestValidationPartialLaxNoFoundAll() throws Exception {
for (XmlConstraint constraint : cv.getConstraint()) {
if (MessageTag.BBB_CV_ISMEC.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.NOT_OK, constraint.getStatus());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS.getId(), constraint.getError().getKey());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS_2.getId(), constraint.getError().getKey());
++digestMatcherValidationPerformedCounter;
} else if (MessageTag.BBB_CV_AAMEF.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.OK, constraint.getStatus());
Expand Down Expand Up @@ -2384,7 +2384,7 @@ void manifestValidationIgnoreIfNotFoundNoFoundAll() throws Exception {
SimpleReport simpleReport = reports.getSimpleReport();
assertEquals(Indication.TOTAL_PASSED, simpleReport.getIndication(simpleReport.getFirstSignatureId()));
assertTrue(checkMessageValuePresence(simpleReport.getAdESValidationWarnings(simpleReport.getFirstSignatureId()),
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS)));
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS_2)));

DetailedReport detailedReport = reports.getDetailedReport();
XmlBasicBuildingBlocks signatureBBB = detailedReport.getBasicBuildingBlockById(detailedReport.getFirstSignatureId());
Expand All @@ -2401,7 +2401,7 @@ void manifestValidationIgnoreIfNotFoundNoFoundAll() throws Exception {
for (XmlConstraint constraint : cv.getConstraint()) {
if (MessageTag.BBB_CV_ISMEC.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.WARNING, constraint.getStatus());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS.getId(), constraint.getWarning().getKey());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS_2.getId(), constraint.getWarning().getKey());
++digestMatcherValidationPerformedCounter;
} else if (MessageTag.BBB_CV_AAMEF.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.WARNING, constraint.getStatus());
Expand All @@ -2415,7 +2415,7 @@ void manifestValidationIgnoreIfNotFoundNoFoundAll() throws Exception {
}
}
assertEquals(1, digestMatcherValidationPerformedCounter);
assertEquals(1, allDigestMatcherFoundCounter);
assertEquals(0, allDigestMatcherFoundCounter);
assertEquals(0, digestMatcherIntactCounter);
assertEquals(0, digestMatcherNameCounter);

Expand Down Expand Up @@ -2809,7 +2809,7 @@ void manifestValidationIgnoreAllNotFoundAll() throws Exception {
SimpleReport simpleReport = reports.getSimpleReport();
assertEquals(Indication.TOTAL_PASSED, simpleReport.getIndication(simpleReport.getFirstSignatureId()));
assertTrue(checkMessageValuePresence(simpleReport.getAdESValidationWarnings(simpleReport.getFirstSignatureId()),
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS)));
i18nProvider.getMessage(MessageTag.BBB_CV_ISMEC_ANS_2)));

DetailedReport detailedReport = reports.getDetailedReport();
XmlBasicBuildingBlocks signatureBBB = detailedReport.getBasicBuildingBlockById(detailedReport.getFirstSignatureId());
Expand All @@ -2826,7 +2826,7 @@ void manifestValidationIgnoreAllNotFoundAll() throws Exception {
for (XmlConstraint constraint : cv.getConstraint()) {
if (MessageTag.BBB_CV_ISMEC.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.WARNING, constraint.getStatus());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS.getId(), constraint.getWarning().getKey());
assertEquals(MessageTag.BBB_CV_ISMEC_ANS_2.getId(), constraint.getWarning().getKey());
++digestMatcherValidationPerformedCounter;
} else if (MessageTag.BBB_CV_AAMEF.getId().equals(constraint.getName().getKey())) {
assertEquals(XmlStatus.WARNING, constraint.getStatus());
Expand All @@ -2840,7 +2840,7 @@ void manifestValidationIgnoreAllNotFoundAll() throws Exception {
}
}
assertEquals(1, digestMatcherValidationPerformedCounter);
assertEquals(1, allDigestMatcherFoundCounter);
assertEquals(0, allDigestMatcherFoundCounter);
assertEquals(0, digestMatcherIntactCounter);
assertEquals(0, digestMatcherNameCounter);

Expand Down

0 comments on commit 48c50c3

Please sign in to comment.