diff options
author | Thomas <> | 2021-04-08 10:48:50 +0200 |
---|---|---|
committer | Thomas <> | 2021-04-08 10:48:50 +0200 |
commit | 458817bd97058c5a975006dca45cdfe6eead07b5 (patch) | |
tree | d6cade442dabafe2e645a5a36a95502e5fc103b9 /eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data | |
parent | b28e12c77d655ec0d9c6c879025426c594bef7f2 (diff) | |
download | EAAF-Components-458817bd97058c5a975006dca45cdfe6eead07b5.tar.gz EAAF-Components-458817bd97058c5a975006dca45cdfe6eead07b5.tar.bz2 EAAF-Components-458817bd97058c5a975006dca45cdfe6eead07b5.zip |
add new verification methods into MOA-Sig module to verify PAdES documents and to perform extended validation
Diffstat (limited to 'eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data')
4 files changed, 134 insertions, 134 deletions
diff --git a/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/GenericSignatureVerificationResponse.java b/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/GenericSignatureVerificationResponse.java index 52fedb62..28501c54 100644 --- a/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/GenericSignatureVerificationResponse.java +++ b/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/GenericSignatureVerificationResponse.java @@ -2,23 +2,30 @@ package at.gv.egiz.eaaf.modules.sigverify.moasig.impl.data; import java.io.Serializable; import java.security.cert.CertificateException; +import java.util.ArrayList; import java.util.Date; +import java.util.List; import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import at.gv.egiz.eaaf.modules.sigverify.moasig.api.data.IGenericSignatureVerificationResponse; import at.gv.egiz.eaaf.modules.sigverify.moasig.exceptions.MoaSigServiceException; import at.gv.egiz.eaaf.modules.sigverify.moasig.exceptions.MoaSigServiceParserException; +import at.gv.egovernment.moa.spss.api.common.ExtendedCertificateCheckResult; +import at.gv.egovernment.moa.spss.api.xmlverify.AdESFormResults; import iaik.x509.X509Certificate; - +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Getter +@Setter public class GenericSignatureVerificationResponse implements IGenericSignatureVerificationResponse, Serializable { private static final long serialVersionUID = -7751001050689401118L; - private static final Logger log = - LoggerFactory.getLogger(GenericSignatureVerificationResponse.class); /** The signing time. */ private Date signingDateTime; @@ -39,7 +46,16 @@ public class GenericSignatureVerificationResponse private boolean qualifiedCertificate; private byte[] x509CertificateEncoded; - + + /** + * Identifier of the signing algorithm. + */ + private String signatureAlgorithmIdentifier; + + private ExtendedCertificateValidation extendedCertificateValidation; + + private List<ExtendedResult> formValidationResults = new ArrayList<>(); + @Override public Date getSigningDateTime() { if (this.signingDateTime != null) { @@ -50,24 +66,6 @@ public class GenericSignatureVerificationResponse } @Override - public int getSignatureCheckCode() { - return this.signatureCheckCode; - - } - - @Override - public int getCertificateCheckCode() { - return this.certificateCheckCode; - - } - - @Override - public boolean isQualifiedCertificate() { - return this.qualifiedCertificate; - - } - - @Override public X509Certificate getX509Certificate() throws MoaSigServiceException { if (x509CertificateEncoded != null) { try { @@ -96,12 +94,6 @@ public class GenericSignatureVerificationResponse } @Override - public boolean isPublicAuthority() { - return this.publicAuthority; - - } - - @Override public String getPublicAuthorityCode() { if (StringUtils.isNotEmpty(this.publicAuthorityCode)) { return this.publicAuthorityCode; @@ -124,26 +116,6 @@ public class GenericSignatureVerificationResponse } } - public void setSignatureCheckCode(final int signatureCheckCode) { - this.signatureCheckCode = signatureCheckCode; - } - - public void setCertificateCheckCode(final int certificateCheckCode) { - this.certificateCheckCode = certificateCheckCode; - } - - public void setPublicAuthority(final boolean publicAuthority) { - this.publicAuthority = publicAuthority; - } - - public void setPublicAuthorityCode(final String publicAuthorityCode) { - this.publicAuthorityCode = publicAuthorityCode; - } - - public void setQualifiedCertificate(final boolean qualifiedCertificate) { - this.qualifiedCertificate = qualifiedCertificate; - } - /** * Set encoded signer certificate. * @@ -156,4 +128,78 @@ public class GenericSignatureVerificationResponse } } + /** + * Set extended certificate-validation result. + * + * @param extendedCertificateCheck Extended result from MOA-Sig + */ + public void setExtendedCertificateCheckResult(ExtendedCertificateCheckResult extendedCertificateCheck) { + if (extendedCertificateCheck != null) { + this.extendedCertificateValidation = ExtendedCertificateValidation.builder() + .majorResult(ExtendedResult.builder() + .code(extendedCertificateCheck.getMajorCode()) + .info(extendedCertificateCheck.getMajorInfo()) + .build()) + .minorResult(ExtendedResult.builder() + .code(extendedCertificateCheck.getMinorCode()) + .info(extendedCertificateCheck.getMinorInfo()) + .build()) + .build(); + + } else { + log.debug("No extended verification-result. Skipping certificate-result extraction ... "); + + } + } + + /** + * Set form-validation result. + * + * @param formCheckResult Extended form-validation result from MOA-Sig + */ + public void setFormValidationResults(List<?> formCheckResult) { + if (formCheckResult != null) { + for (Object elObj : formCheckResult) { + if (elObj instanceof AdESFormResults) { + AdESFormResults el = (AdESFormResults)elObj; + formValidationResults.add(ExtendedResult.builder() + .code(el.getCode()) + .info(el.getName()) + .build()); + + } else { + log.warn("Skip unknown form-validation result of type: {}", elObj.getClass().getName()); + + } + } + + } else { + log.debug("No extended verification-result. Skipping form-validation result extraction ... "); + + } + + } + + @Getter + @Builder + public static class ExtendedCertificateValidation implements Serializable { + + private static final long serialVersionUID = -7800026008655393276L; + + private ExtendedResult majorResult; + private ExtendedResult minorResult; + + } + + @Getter + @Builder + public static class ExtendedResult implements Serializable { + + private static final long serialVersionUID = 8523769744476971010L; + + private int code; + private String info; + + } + } diff --git a/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/VerifyCmsSignatureResponse.java b/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/VerifyCmsSignatureResponse.java index 244aa223..a812db56 100644 --- a/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/VerifyCmsSignatureResponse.java +++ b/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/VerifyCmsSignatureResponse.java @@ -1,7 +1,11 @@ package at.gv.egiz.eaaf.modules.sigverify.moasig.impl.data; import at.gv.egiz.eaaf.modules.sigverify.moasig.api.data.ICmsSignatureVerificationResponse; +import lombok.Getter; +import lombok.Setter; +@Getter +@Setter public class VerifyCmsSignatureResponse extends GenericSignatureVerificationResponse implements ICmsSignatureVerificationResponse { diff --git a/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/VerifyPdfSignatureResponse.java b/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/VerifyPdfSignatureResponse.java new file mode 100644 index 00000000..740ac55a --- /dev/null +++ b/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/VerifyPdfSignatureResponse.java @@ -0,0 +1,30 @@ +package at.gv.egiz.eaaf.modules.sigverify.moasig.impl.data; + +import java.util.List; + +import at.gv.egiz.eaaf.core.impl.data.Pair; +import at.gv.egiz.eaaf.modules.sigverify.moasig.api.data.IPdfSignatureVerificationResponse; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class VerifyPdfSignatureResponse extends VerifyCmsSignatureResponse + implements IPdfSignatureVerificationResponse { + + private static final long serialVersionUID = 1835687958341837826L; + + /** + * Flag if signature covers the full pdf-document. + */ + private CoversFullDocument signatureCoversFullDocument = CoversFullDocument.UNKNOWN; + + /** + * PDF signing ranges as {@link List} of {@link Pair} of starting-byte and byte-length. + */ + private List<Pair<Integer, Integer>> byteRange; + + + public enum CoversFullDocument { YES, NO, UNKNOWN } + +} diff --git a/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/VerifyXmlSignatureResponse.java b/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/VerifyXmlSignatureResponse.java index cbce53b7..4021a90b 100644 --- a/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/VerifyXmlSignatureResponse.java +++ b/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/VerifyXmlSignatureResponse.java @@ -1,6 +1,8 @@ package at.gv.egiz.eaaf.modules.sigverify.moasig.impl.data; import at.gv.egiz.eaaf.modules.sigverify.moasig.api.data.IXmlSignatureVerificationResponse; +import lombok.Getter; +import lombok.Setter; /** * MOA-Sig signature verification response for XML based signatures. @@ -9,6 +11,8 @@ import at.gv.egiz.eaaf.modules.sigverify.moasig.api.data.IXmlSignatureVerificati * */ +@Getter +@Setter public class VerifyXmlSignatureResponse extends GenericSignatureVerificationResponse implements IXmlSignatureVerificationResponse { @@ -28,88 +32,4 @@ public class VerifyXmlSignatureResponse extends GenericSignatureVerificationResp */ private int signatureManifestCheckCode = -1; - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IVerifiyXMLSignatureResponse# - * getXmlDSIGManifestCheckCode() - */ - @Override - public int getXmlDsigManifestCheckCode() { - return xmlDsigManifestCheckCode; - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IVerifiyXMLSignatureResponse# - * getXmlDsigSubjectName() - */ - @Override - public String getXmlDsigSubjectName() { - return xmlDsigSubjectName; - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IVerifiyXMLSignatureResponse# - * setXmlDSIGManifestCheckCode( int) - */ - public void setXmlDsigManifestCheckCode(final int xmlDsigManifestCheckCode) { - this.xmlDsigManifestCheckCode = xmlDsigManifestCheckCode; - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IVerifiyXMLSignatureResponse# - * setXmlDsigSubjectName(java.lang .String) - */ - public void setXmlDsigSubjectName(final String xmlDsigSubjectName) { - this.xmlDsigSubjectName = xmlDsigSubjectName; - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IVerifiyXMLSignatureResponse# - * isXmlDSIGManigest() - */ - @Override - public boolean isXmlDsigManigest() { - return xmlDsigManigest; - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IVerifiyXMLSignatureResponse# - * setXmlDSIGManigest(boolean) - */ - public void setXmlDsigManigest(final boolean xmlDsigManigest) { - this.xmlDsigManigest = xmlDsigManigest; - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IVerifiyXMLSignatureResponse# - * getSignatureManifestCheckCode() - */ - @Override - public int getSignatureManifestCheckCode() { - return signatureManifestCheckCode; - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IVerifiyXMLSignatureResponse# - * setSignatureManifestCheckCode( int) - */ - public void setSignatureManifestCheckCode(final int signatureManifestCheckCode) { - this.signatureManifestCheckCode = signatureManifestCheckCode; - } - } |