aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/AdESResultUtils.java
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-06-15 08:41:10 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-06-15 08:41:10 +0200
commitacf1b849ab835bc6797adfb91f8ab4fa88f0aff5 (patch)
tree825c5c033f0a104dad27abc25cf3be3a481a8dd8 /moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/AdESResultUtils.java
parent606fd125e82b532f2e75dc787edb1f535dacfae9 (diff)
downloadmoa-sig-acf1b849ab835bc6797adfb91f8ab4fa88f0aff5.tar.gz
moa-sig-acf1b849ab835bc6797adfb91f8ab4fa88f0aff5.tar.bz2
moa-sig-acf1b849ab835bc6797adfb91f8ab4fa88f0aff5.zip
extended validation result
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/AdESResultUtils.java')
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/AdESResultUtils.java159
1 files changed, 142 insertions, 17 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/AdESResultUtils.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/AdESResultUtils.java
index 90722b8..4903391 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/AdESResultUtils.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/AdESResultUtils.java
@@ -1,15 +1,20 @@
package at.gv.egovernment.moa.spss.util;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import at.gv.egovernment.moa.spss.api.common.ExtendedCertificateCheckResult;
import at.gv.egovernment.moa.spss.api.impl.AdESFormResultsImpl;
+import at.gv.egovernment.moa.spss.api.impl.ExtendedCertificateCheckResultImpl;
import at.gv.egovernment.moaspss.logging.Logger;
import iaik.esi.sva.validation.ValidationReport;
import iaik.server.ConfigurationException;
+import iaik.server.modules.AdESVerificationResult;
import iaik.server.modules.ResultCode;
import iaik.server.modules.ResultCodeInvalid;
import iaik.server.modules.ResultCodeValid;
+import iaik.server.modules.SignatureVerificationProfile;
import iaik.server.modules.SignatureVerificationResult;
public class AdESResultUtils {
@@ -17,39 +22,159 @@ public class AdESResultUtils {
public static Integer getResultCode(Integer adesCode) {
return adesCode;
}
-
- public static void buildResult(ValidationReport report, List adesList) {
+
+ public static ExtendedCertificateCheckResult getExtendedResult(iaik.server.modules.ResultCode resultCode) {
+ ExtendedCertificateCheckResult check = null;
+
+ int majorCode = -1;
+ String majorInfo = "";
+ int minorCode = -1;
+ String minorInfo = "";
+
+ Logger.debug("Generating extendend validation result: " + resultCode.toString());
- if(report == null) {
+ if (resultCode instanceof ResultCodeValid) {
+ majorCode = SignatureVerificationResult.VALID;
+ majorInfo = "VALID";
+ } else if (resultCode instanceof ResultCodeInvalid) {
+ majorCode = SignatureVerificationResult.INVALID;
+ majorInfo = "INVALID";
+ } else {
+ majorCode = SignatureVerificationResult.INDETERMINATE;
+ majorInfo = "INDETERMINATE";
+ }
+
+ if (resultCode.getCode() != null) {
+ minorCode = resultCode.getCode();
+ if (resultCode.getCode().equals(ResultCode.CODE_CHAIN_CONSTRAINTS_FAILURE)) {
+ minorInfo = "CHAIN_CONSTRAINTS_FAILURE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_CRYPTO_CONSTRAINTS_FAILURE)) {
+ minorInfo = "CRYPTO_CONSTRAINTS_FAILURE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_CRYPTO_CONSTRAINTS_FAILURE_NO_POE)) {
+ minorInfo = "CRYPTO_CONSTRAINTS_FAILURE_NO_POE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_EXPIRED)) {
+ minorInfo = "EXPIRED";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_FORMAT_FAILURE)) {
+ minorInfo = "FORMAT_FAILURE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_GENERIC)) {
+ minorInfo = "GENERIC";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_HASH_FAILURE)) {
+ minorInfo = "HASH_FAILURE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_NO_CERTIFICATE_CHAIN_FOUND)) {
+ minorInfo = "NO_CERTIFICATE_CHAIN_FOUND";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_NO_POE)) {
+ minorInfo = "NO_POE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_NO_POLICY)) {
+ minorInfo = "NO_POLICY";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_NOT_YET_VALID)) {
+ minorInfo = "NOT_YET_VALID";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_OUT_OF_BOUNDS_NO_POE)) {
+ minorInfo = "OUT_OF_BOUNDS_NO_POE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_POLICY_PROCESSING_ERROR)) {
+ minorInfo = "POLICY_PROCESSING_ERROR";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_REVOKED)) {
+ minorInfo = "REVOKED";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_REVOKED_CA_NO_POE)) {
+ minorInfo = "REVOKED_CA_NO_POE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_REVOKED_NO_POE)) {
+ minorInfo = "REVOKED_NO_POE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_SIG_CONSTRAINTS_FAILURE)) {
+ minorInfo = "SIG_CONSTRAINTS_FAILURE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_SIG_CRYPTO_FAILURE)) {
+ minorInfo = "SIG_CRYPTO_FAILURE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_SIGNED_DATA_NOT_FOUND)) {
+ minorInfo = "SIGNED_DATA_NOT_FOUND";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_TIMESTAMP_ORDER_FAILURE)) {
+ minorInfo = "TIMESTAMP_ORDER_FAILURE";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_TRY_LATER)) {
+ minorInfo = "TRY_LATER";
+ } else if (resultCode.getCode().equals(ResultCode.CODE_UNKNOWN_COMMITMENT_TYPE)) {
+ minorInfo = "UNKNOWN_COMMITMENT_TYPE";
+ } else if (resultCode.getCode().equals(ResultCode.SUCCESS)) {
+ minorInfo = "SUCCESS";
+ }
+ }
+
+ check = new ExtendedCertificateCheckResultImpl(majorCode, majorInfo, minorCode,
+ minorInfo);
+
+ return check;
+
+ }
+
+ public static List getAdESResult(iaik.server.modules.AdESFormVerificationResult adesFormVerification) {
+ if (adesFormVerification == null) {
+ // no form information
+ return null;
+ }
+
+ List adesList = new ArrayList();
+
+ checkSubResult(adesFormVerification.getSubResult(SignatureVerificationProfile.LEVEL_LTA),
+ SignatureVerificationProfile.LEVEL_LTA, adesList);
+ checkSubResult(adesFormVerification.getSubResult(SignatureVerificationProfile.LEVEL_LT),
+ SignatureVerificationProfile.LEVEL_LT, adesList);
+ checkSubResult(adesFormVerification.getSubResult(SignatureVerificationProfile.LEVEL_T),
+ SignatureVerificationProfile.LEVEL_T, adesList);
+ checkSubResult(adesFormVerification.getSubResult(SignatureVerificationProfile.LEVEL_B),
+ SignatureVerificationProfile.LEVEL_B, adesList);
+
+ return adesList;
+ }
+
+ public static void buildResult(ValidationReport report, List adesList) {
+
+ if (report == null) {
return;
}
-
- AdESFormResultsImpl adESFormResultsImpl = new AdESFormResultsImpl();
+
+ AdESFormResultsImpl adESFormResultsImpl = new AdESFormResultsImpl();
adESFormResultsImpl.setCode(report.getStatus().ordinal());
adESFormResultsImpl.setInfo(report.getLongText());
adESFormResultsImpl.setName(report.getValidationName());
adesList.add(adESFormResultsImpl);
-
- if(report.getSubValidationReports() != null && !report.getSubValidationReports().isEmpty()) {
+
+ if (report.getSubValidationReports() != null && !report.getSubValidationReports().isEmpty()) {
Iterator<ValidationReport> reportIt = report.getSubValidationReports().iterator();
- while(reportIt.hasNext()) {
+ while (reportIt.hasNext()) {
buildResult(reportIt.next(), adesList);
}
}
-
+
+ }
+
+ public static void checkSubResult(AdESVerificationResult subResult, String level, List adesList) {
+ if (subResult != null) {
+ Logger.info("Checking Level: " + level);
+ try {
+
+ AdESFormResultsImpl adESFormResultsImpl = new AdESFormResultsImpl();
+ adESFormResultsImpl.setCode(subResult.getResultCode());
+ Logger.info("RESULT: " + String.valueOf(subResult.getResultCode()));
+ adESFormResultsImpl.setInfo(subResult.getInfo());
+ adESFormResultsImpl.setName(level);
+
+ adesList.add(adESFormResultsImpl);
+ } catch (NullPointerException e) {
+ Logger.warn("Catching NullPointer Exception, of invalid Form Results", e);
+ }
+ } else {
+ Logger.info("Subresult Level: " + level + " not available");
+ }
}
-
- public static void checkSubResult(SignatureVerificationResult subResult, String level, List adesList) throws ConfigurationException {
+
+ public static void checkSubResult(SignatureVerificationResult subResult, String level, List adesList)
+ throws ConfigurationException {
if (subResult != null) {
Logger.info("Checking Level: " + level);
try {
-
- AdESFormResultsImpl adESFormResultsImpl = new AdESFormResultsImpl();
+
+ AdESFormResultsImpl adESFormResultsImpl = new AdESFormResultsImpl();
ResultCode resultCode = subResult.getResultCode();
- if(resultCode instanceof ResultCodeValid) {
- adESFormResultsImpl.setCode(SignatureVerificationResult.VALID);//.getResultCode().getCode()));
- } else if(resultCode instanceof ResultCodeInvalid) {
+ if (resultCode instanceof ResultCodeValid) {
+ adESFormResultsImpl.setCode(SignatureVerificationResult.VALID);// .getResultCode().getCode()));
+ } else if (resultCode instanceof ResultCodeInvalid) {
adESFormResultsImpl.setCode(SignatureVerificationResult.INVALID);
} else {
adESFormResultsImpl.setCode(SignatureVerificationResult.INDETERMINATE);
@@ -66,5 +191,5 @@ public class AdESResultUtils {
Logger.info("Subresult Level: " + level + " not available");
}
}
-
+
}