aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-03-14 16:29:03 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-03-14 16:29:03 +0100
commit84293bd12f63b59852026cab02035fc9ebee626a (patch)
tree6a118418f618af68f5d884e2eb7eac2fb660a136 /moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java
parent7510ab5173001711ecb5d6c8834878e7cce63ff9 (diff)
downloadmoa-sig-84293bd12f63b59852026cab02035fc9ebee626a.tar.gz
moa-sig-84293bd12f63b59852026cab02035fc9ebee626a.tar.bz2
moa-sig-84293bd12f63b59852026cab02035fc9ebee626a.zip
A lot of moa sig stuff
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java')
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java145
1 files changed, 145 insertions, 0 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java
new file mode 100644
index 0000000..cc44c29
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+package at.gv.egovernment.moa.spss.api.xmlbind;
+
+import java.util.Iterator;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import at.gv.egovernment.moa.spss.MOAApplicationException;
+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.xmlverify.AdESFormResults;
+
+/**
+ * Convert a <code>VerifyCMSSignatureResponse</code> API object into its
+ * XML representation, according to the MOA XML schema.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class VerifyPDFSignatureResponseBuilder {
+ /** The XML document containing the response element. */
+ private Document responseDoc;
+ /** The response <code>VerifyCMSSignatureResponse</code> DOM element. */
+ private Element responseElem;
+
+ /**
+ * Create a new <code>VerifyCMSSignatureResponseBuilder</code>:
+ *
+ * @throws MOASystemException An error occurred setting up the resulting
+ * XML document.
+ */
+ public VerifyPDFSignatureResponseBuilder() throws MOASystemException {
+ responseDoc =
+ ResponseBuilderUtils.createResponse("VerifyPDFSignatureResponse");
+ responseElem = responseDoc.getDocumentElement();
+ }
+
+ /**
+ * Build a document containing a <code>VerifyCMSSignatureResponse</code>
+ * DOM element being the XML representation of the given
+ * <code>VerifyCMSSignatureResponse</code> API object.
+ *
+ * @param response The <code>VerifyCMSSignatureResponse</code> to convert
+ * to XML.
+ * @return A document containing the <code>VerifyCMSSignatureResponse</code>
+ * DOM element.
+ * @throws MOAApplicationException An error occurred building the response.
+ */
+ public Document build(VerifyCMSSignatureResponse response)
+ throws MOAApplicationException {
+
+ Iterator iter;
+
+ for (iter = response.getResponseElements().iterator(); iter.hasNext();) {
+ VerifyCMSSignatureResponseElement responseElement =
+ (VerifyCMSSignatureResponseElement) iter.next();
+ addResponseElement(responseElement);
+ }
+
+ return responseDoc;
+ }
+
+ /**
+ * 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 {
+
+ 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());
+
+ ResponseBuilderUtils.addCodeInfoElement(
+ responseDoc,
+ responseElem,
+ "SignatureCheck",
+ signatureCheck.getCode(),
+ signatureCheck.getInfo());
+
+ ResponseBuilderUtils.addCodeInfoElement(
+ 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());
+
+ }
+ }
+
+ }
+
+}