From 578ad0d6bc408edf9e6c875156054374f5fd8337 Mon Sep 17 00:00:00 2001
From: Thomas <>
Date: Mon, 22 Mar 2021 18:40:26 +0100
Subject: change to EGIZ codestyle
---
.../xmlbind/VerifyASICSignatureRequestParser.java | 79 ++++----
.../VerifyASICSignatureResponseBuilder.java | 206 +++++++++++----------
.../at/gv/egiz/asic/xmlbind/VerifyASiCRequest.java | 72 +++----
3 files changed, 177 insertions(+), 180 deletions(-)
(limited to 'moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind')
diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureRequestParser.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureRequestParser.java
index c06e30e..b152b6d 100644
--- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureRequestParser.java
+++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureRequestParser.java
@@ -21,31 +21,25 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egiz.asic.xmlbind;
+import java.io.InputStream;
+import java.util.Date;
+
+import org.w3c.dom.Element;
+
import at.gv.egiz.asic.api.ASiCFormat;
import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.api.SPSSFactory;
-import at.gv.egovernment.moa.spss.api.cmsverify.CMSContent;
-import at.gv.egovernment.moa.spss.api.cmsverify.CMSDataObject;
-import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest;
-import at.gv.egovernment.moa.spss.api.common.MetaInfo;
import at.gv.egovernment.moa.spss.api.xmlbind.RequestParserUtils;
-import at.gv.egovernment.moaspss.util.*;
-import org.w3c.dom.Element;
-
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.StringTokenizer;
+import at.gv.egovernment.moaspss.util.Base64Utils;
+import at.gv.egovernment.moaspss.util.Constants;
+import at.gv.egovernment.moaspss.util.XPathUtils;
/**
* A parser to parse VerifyCMSSignatureRequest
DOM trees into
* VerifyCMSSignatureRequest
API objects.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -61,48 +55,47 @@ public class VerifyASICSignatureRequestParser {
private static final String ASIC_EXTENSION_XPATH = MOA + "ASICExtension";
private static final String TRUST_PROFILE_ID_XPATH = MOA + "TrustProfileID";
-
/** The SPSSFactory
for creating new API objects. */
- private SPSSFactory factory = SPSSFactory.getInstance();
+ private final SPSSFactory factory = SPSSFactory.getInstance();
/**
- * Parse a VerifyCMSSignatureRequest
DOM element, as defined
- * by the MOA schema.
- *
+ * Parse a VerifyCMSSignatureRequest
DOM element, as defined by the
+ * MOA schema.
+ *
* @param requestElem The VerifyCMSSignatureRequest
to parse. The
- * request must have been successfully parsed against the schema for this
- * method to succeed.
- * @return A VerifyCMSSignatureRequest
API objects containing
- * the data from the DOM element.
+ * request must have been successfully parsed against the
+ * schema for this method to succeed.
+ * @return A VerifyCMSSignatureRequest
API objects containing the
+ * data from the DOM element.
* @throws MOAApplicationException An error occurred parsing the request.
*/
public VerifyASiCRequest parseASIC(Element requestElem)
- throws MOAApplicationException {
- Date dateTime =
- RequestParserUtils.parseDateTime(requestElem, DATE_TIME_XPATH);
+ throws MOAApplicationException {
+ final Date dateTime =
+ RequestParserUtils.parseDateTime(requestElem, DATE_TIME_XPATH);
+
+ final boolean extendedValidation =
+ RequestParserUtils.parseExtendedValidation(requestElem, EXTENDED_VALIDATION_XPATH, false);
- boolean extendedValidation =
- RequestParserUtils.parseExtendedValidation(requestElem, EXTENDED_VALIDATION_XPATH, false);
-
- String asicSignatureStr =
- XPathUtils.getElementValue(requestElem, ASIC_SIGNATURE_XPATH, "");
+ final String asicSignatureStr =
+ XPathUtils.getElementValue(requestElem, ASIC_SIGNATURE_XPATH, "");
- String asicExtensionStr =
- XPathUtils.getElementValue(requestElem, ASIC_EXTENSION_XPATH, "");
+ final String asicExtensionStr =
+ XPathUtils.getElementValue(requestElem, ASIC_EXTENSION_XPATH, "");
- String trustProfileID =
- XPathUtils.getElementValue(requestElem, TRUST_PROFILE_ID_XPATH, null);
- //Logger.info("CMSSignature: " + cmsSignatureStr);
- InputStream asicSignature =
- Base64Utils.decodeToStream(asicSignatureStr, true);
+ final String trustProfileID =
+ XPathUtils.getElementValue(requestElem, TRUST_PROFILE_ID_XPATH, null);
+ // Logger.info("CMSSignature: " + cmsSignatureStr);
+ final InputStream asicSignature =
+ Base64Utils.decodeToStream(asicSignatureStr, true);
ASiCFormat format = null;
- if("asics".equalsIgnoreCase(asicExtensionStr) || "scs".equalsIgnoreCase(asicExtensionStr)
- || "application/vnd.etsi.asic-s+zip".equalsIgnoreCase(asicExtensionStr)) {
+ if ("asics".equalsIgnoreCase(asicExtensionStr) || "scs".equalsIgnoreCase(asicExtensionStr)
+ || "application/vnd.etsi.asic-s+zip".equalsIgnoreCase(asicExtensionStr)) {
format = ASiCFormat.ASiCS;
- } else if("asice".equalsIgnoreCase(asicExtensionStr) || "sce".equalsIgnoreCase(asicExtensionStr)
- || "application/vnd.etsi.asic-e+zip".equalsIgnoreCase(asicExtensionStr)) {
+ } else if ("asice".equalsIgnoreCase(asicExtensionStr) || "sce".equalsIgnoreCase(asicExtensionStr)
+ || "application/vnd.etsi.asic-e+zip".equalsIgnoreCase(asicExtensionStr)) {
format = ASiCFormat.ASiCE;
}
diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureResponseBuilder.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureResponseBuilder.java
index 67d8b05..34744ef 100644
--- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureResponseBuilder.java
+++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureResponseBuilder.java
@@ -21,168 +21,172 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egiz.asic.xmlbind;
+import java.util.Iterator;
+import java.util.List;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
import at.gv.egiz.asic.api.ASiCVerificationResult;
import at.gv.egiz.asic.impl.AsicSignedFilesContainer;
import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.MOAException;
import at.gv.egovernment.moa.spss.MOASystemException;
-import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse;
import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponseElement;
import at.gv.egovernment.moa.spss.api.common.CheckResult;
import at.gv.egovernment.moa.spss.api.common.SignerInfo;
import at.gv.egovernment.moa.spss.api.xmlbind.ResponseBuilderUtils;
+import at.gv.egovernment.moa.spss.api.xmlbind.VerifyCMSSignatureResponseBuilder;
import at.gv.egovernment.moa.spss.api.xmlbind.VerifyXMLSignatureResponseBuilder;
import at.gv.egovernment.moa.spss.api.xmlverify.AdESFormResults;
-import at.gv.egovernment.moa.spss.api.xmlbind.VerifyCMSSignatureResponseBuilder;
import at.gv.egovernment.moaspss.util.Constants;
import at.gv.egovernment.moaspss.util.MiscUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import java.util.Iterator;
-import java.util.List;
-
/**
- * Convert a VerifyCMSSignatureResponse
API object into its
- * XML representation, according to the MOA XML schema.
- *
+ * Convert a VerifyCMSSignatureResponse
API object into its XML
+ * representation, according to the MOA XML schema.
+ *
* @author Patrick Peck
* @version $Id$
*/
public class VerifyASICSignatureResponseBuilder {
/** The XML document containing the response element. */
- private Document responseDoc;
+ private final Document responseDoc;
/** The response VerifyCMSSignatureResponse
DOM element. */
- private Element responseElem;
+ private final Element responseElem;
/**
* Create a new VerifyCMSSignatureResponseBuilder
:
*
- * @throws MOASystemException An error occurred setting up the resulting
- * XML document.
+ * @throws MOASystemException An error occurred setting up the resulting XML
+ * document.
*/
public VerifyASICSignatureResponseBuilder() throws MOASystemException {
responseDoc =
- ResponseBuilderUtils.createResponse("VerifyASICSignatureResponse");
+ ResponseBuilderUtils.createResponse("VerifyASICSignatureResponse");
responseElem = responseDoc.getDocumentElement();
}
-
+
/**
- * Build a document containing a VerifyCMSSignatureResponse
- * DOM element being the XML representation of the given
+ * Build a document containing a VerifyCMSSignatureResponse
DOM
+ * element being the XML representation of the given
* VerifyCMSSignatureResponse
API object.
- *
- * @param response The VerifyCMSSignatureResponse
to convert
- * to XML.
- * @return A document containing the VerifyCMSSignatureResponse
- * DOM element.
+ *
+ * @param response The VerifyCMSSignatureResponse
to convert to
+ * XML.
+ * @return A document containing the VerifyCMSSignatureResponse
DOM
+ * element.
* @throws MOAApplicationException An error occurred building the response.
*/
public Document build(List results)
- throws MOAException {
+ throws MOAException {
- Iterator iter = results.iterator();
+ final Iterator iter = results.iterator();
- while(iter.hasNext()) {
- ASiCVerificationResult aSiCVerificationResult = iter.next();
- addASiCResultElement(aSiCVerificationResult);
+ while (iter.hasNext()) {
+ final ASiCVerificationResult aSiCVerificationResult = iter.next();
+ addASiCResultElement(aSiCVerificationResult);
}
-
+
return responseDoc;
}
- private void addASiCResultElement(ASiCVerificationResult aSiCVerificationResult)
- throws MOAException {
- Element asiCSignatureResultElem = responseDoc.createElementNS(Constants.MOA_NS_URI, "ASiCSignatureResult");
-
- Iterator signedFiles = aSiCVerificationResult.getSignedFiles().iterator();
- while (signedFiles.hasNext()) {
- AsicSignedFilesContainer signedFile = signedFiles.next();
- Element signedFilesElem = responseDoc.createElementNS(Constants.MOA_NS_URI, "signedFiles");
- signedFilesElem.setTextContent(signedFile.getUri());
- if (MiscUtil.isNotEmpty(signedFile.getHashAlg()))
- signedFilesElem.setAttribute("hashAlgorithm", signedFile.getHashAlg());
-
- asiCSignatureResultElem.appendChild(signedFilesElem);
- }
-
- if(aSiCVerificationResult.getXmlResult() != null) {
- VerifyXMLSignatureResponseBuilder verifyXMLSignatureResponseBuilder = new VerifyXMLSignatureResponseBuilder(this.responseDoc, "XMLSignatureResult", true);
- asiCSignatureResultElem.appendChild(verifyXMLSignatureResponseBuilder.buildElement(aSiCVerificationResult.getXmlResult()));
- } else if(aSiCVerificationResult.getCmsResult() != null) {
- VerifyCMSSignatureResponseBuilder verifyCMSSignatureResponseBuilder = new VerifyCMSSignatureResponseBuilder(this.responseDoc, "CMSSignatureResult", true);
- asiCSignatureResultElem.appendChild(verifyCMSSignatureResponseBuilder.buildElement(aSiCVerificationResult.getCmsResult()));
- }
-
- responseElem.appendChild(asiCSignatureResultElem);
+ private void addASiCResultElement(ASiCVerificationResult aSiCVerificationResult)
+ throws MOAException {
+ final Element asiCSignatureResultElem = responseDoc.createElementNS(Constants.MOA_NS_URI,
+ "ASiCSignatureResult");
+
+ final Iterator signedFiles = aSiCVerificationResult.getSignedFiles().iterator();
+ while (signedFiles.hasNext()) {
+ final AsicSignedFilesContainer signedFile = signedFiles.next();
+ final Element signedFilesElem = responseDoc.createElementNS(Constants.MOA_NS_URI, "signedFiles");
+ signedFilesElem.setTextContent(signedFile.getUri());
+ if (MiscUtil.isNotEmpty(signedFile.getHashAlg())) {
+ signedFilesElem.setAttribute("hashAlgorithm", signedFile.getHashAlg());
+ }
+
+ asiCSignatureResultElem.appendChild(signedFilesElem);
+ }
+
+ if (aSiCVerificationResult.getXmlResult() != null) {
+ final VerifyXMLSignatureResponseBuilder verifyXMLSignatureResponseBuilder =
+ new VerifyXMLSignatureResponseBuilder(this.responseDoc, "XMLSignatureResult", true);
+ asiCSignatureResultElem.appendChild(verifyXMLSignatureResponseBuilder.buildElement(
+ aSiCVerificationResult.getXmlResult()));
+ } else if (aSiCVerificationResult.getCmsResult() != null) {
+ final VerifyCMSSignatureResponseBuilder verifyCMSSignatureResponseBuilder =
+ new VerifyCMSSignatureResponseBuilder(this.responseDoc, "CMSSignatureResult", true);
+ asiCSignatureResultElem.appendChild(verifyCMSSignatureResponseBuilder.buildElement(
+ aSiCVerificationResult.getCmsResult()));
}
+ responseElem.appendChild(asiCSignatureResultElem);
+ }
+
/**
* Add an element to the response.
- *
+ *
* @param responseElement The element to add to the response.
* @throws MOAApplicationException An error occurred adding the element.
*/
private void addResponseElement(VerifyCMSSignatureResponseElement responseElement)
- throws MOAApplicationException {
+ throws MOAApplicationException {
+
+ final SignerInfo signerInfo = responseElement.getSignerInfo();
+ final CheckResult signatureCheck = responseElement.getSignatureCheck();
+ final CheckResult certCheck = responseElement.getCertificateCheck();
- SignerInfo signerInfo = responseElement.getSignerInfo();
- CheckResult signatureCheck = responseElement.getSignatureCheck();
- CheckResult certCheck = responseElement.getCertificateCheck();
-
ResponseBuilderUtils.addSignerInfo(
- responseDoc,
- responseElem,
- signerInfo.getSignerCertificate(),
- signerInfo.isQualifiedCertificate(),
- signerInfo.getQCSource(),
- signerInfo.isPublicAuthority(),
- signerInfo.getPublicAuhtorityID(),
- signerInfo.isSSCD(),
- signerInfo.getSSCDSource(),
- signerInfo.getIssuerCountryCode(),
- signerInfo.getTslInfos());
+ responseDoc,
+ responseElem,
+ signerInfo.getSignerCertificate(),
+ signerInfo.isQualifiedCertificate(),
+ signerInfo.getQCSource(),
+ signerInfo.isPublicAuthority(),
+ signerInfo.getPublicAuhtorityID(),
+ signerInfo.isSSCD(),
+ signerInfo.getSSCDSource(),
+ signerInfo.getIssuerCountryCode(),
+ signerInfo.getTslInfos());
ResponseBuilderUtils.addSignatureAlgorithm(responseDoc,
- responseElem,
- responseElement.getSignatureAlgorithm());
-
+ responseElem,
+ responseElement.getSignatureAlgorithm());
+
ResponseBuilderUtils.addCodeInfoElement(
- responseDoc,
- responseElem,
- "SignatureCheck",
- signatureCheck.getCode(),
- signatureCheck.getInfo());
+ responseDoc,
+ responseElem,
+ "SignatureCheck",
+ signatureCheck.getCode(),
+ signatureCheck.getInfo());
ResponseBuilderUtils.addCodeInfoElement(
- responseDoc,
- responseElem,
- "CertificateCheck",
- certCheck.getCode(),
- certCheck.getInfo());
-
+ responseDoc,
+ responseElem,
+ "CertificateCheck",
+ certCheck.getCode(),
+ certCheck.getInfo());
if (responseElement.getAdESFormResults() != null) {
- Iterator formIterator = responseElement.getAdESFormResults().iterator();
-
- while (formIterator.hasNext()) {
- AdESFormResults adESFormResult = (AdESFormResults) formIterator.next();
- // add the CertificateCheck
- ResponseBuilderUtils.addFormCheckElement(responseDoc, responseElem, "FormCheckResult",
- adESFormResult.getCode().intValue(), adESFormResult.getName());
-
- }
- }
-
- if(responseElement.getExtendedCertificateCheck() != null) {
- ResponseBuilderUtils.addExtendendResult(responseDoc, responseElem, responseElement.getExtendedCertificateCheck());
- }
-
+ final Iterator formIterator = responseElement.getAdESFormResults().iterator();
+
+ while (formIterator.hasNext()) {
+ final AdESFormResults adESFormResult = (AdESFormResults) formIterator.next();
+ // add the CertificateCheck
+ ResponseBuilderUtils.addFormCheckElement(responseDoc, responseElem, "FormCheckResult",
+ adESFormResult.getCode().intValue(), adESFormResult.getName());
+
+ }
+ }
+
+ if (responseElement.getExtendedCertificateCheck() != null) {
+ ResponseBuilderUtils.addExtendendResult(responseDoc, responseElem, responseElement
+ .getExtendedCertificateCheck());
+ }
+
}
}
diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASiCRequest.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASiCRequest.java
index 37584a6..93218bc 100644
--- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASiCRequest.java
+++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASiCRequest.java
@@ -1,46 +1,46 @@
package at.gv.egiz.asic.xmlbind;
-import at.gv.egiz.asic.api.ASiCFormat;
-
import java.io.InputStream;
import java.util.Date;
+import at.gv.egiz.asic.api.ASiCFormat;
+
/**
* Created by Andreas Fitzek on 6/16/16.
*/
public class VerifyASiCRequest {
- private Date date;
- private InputStream asicInput;
- private String trustProfile;
- private ASiCFormat format;
- private boolean extendedValidation;
-
-
- public VerifyASiCRequest(ASiCFormat format, Date date, InputStream asicInput, String trustProfile, boolean extendedValidation) {
- this.format = format;
- this.date = date;
- this.asicInput = asicInput;
- this.trustProfile = trustProfile;
- this.extendedValidation = extendedValidation;
- }
-
- public Date getDate() {
- return date;
- }
-
- public InputStream getAsicInput() {
- return asicInput;
- }
-
- public String getTrustProfile() {
- return trustProfile;
- }
-
- public ASiCFormat getFormat() {
- return format;
- }
-
- public boolean isExtendedValidation() {
- return extendedValidation;
- }
+ private final Date date;
+ private final InputStream asicInput;
+ private final String trustProfile;
+ private final ASiCFormat format;
+ private final boolean extendedValidation;
+
+ public VerifyASiCRequest(ASiCFormat format, Date date, InputStream asicInput, String trustProfile,
+ boolean extendedValidation) {
+ this.format = format;
+ this.date = date;
+ this.asicInput = asicInput;
+ this.trustProfile = trustProfile;
+ this.extendedValidation = extendedValidation;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public InputStream getAsicInput() {
+ return asicInput;
+ }
+
+ public String getTrustProfile() {
+ return trustProfile;
+ }
+
+ public ASiCFormat getFormat() {
+ return format;
+ }
+
+ public boolean isExtendedValidation() {
+ return extendedValidation;
+ }
}
--
cgit v1.2.3