aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java
diff options
context:
space:
mode:
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.java184
1 files changed, 91 insertions, 93 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
index 499f514..b9b7d26 100644
--- 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
@@ -21,7 +21,6 @@
* 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;
@@ -39,145 +38,144 @@ import at.gv.egovernment.moa.spss.api.xmlverify.AdESFormResults;
import at.gv.egovernment.moaspss.logging.Logger;
/**
- * Convert a <code>VerifyCMSSignatureResponse</code> API object into its
- * XML representation, according to the MOA XML schema.
- *
+ * 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;
+ private final Document responseDoc;
/** The response <code>VerifyCMSSignatureResponse</code> DOM element. */
- private Element responseRootElem;
+ private final Element responseRootElem;
/**
* Create a new <code>VerifyCMSSignatureResponseBuilder</code>:
- *
- * @throws MOASystemException An error occurred setting up the resulting
- * XML document.
+ *
+ * @throws MOASystemException An error occurred setting up the resulting XML
+ * document.
*/
public VerifyPDFSignatureResponseBuilder() throws MOASystemException {
responseDoc =
- ResponseBuilderUtils.createResponse("VerifyPDFSignatureResponse");
+ ResponseBuilderUtils.createResponse("VerifyPDFSignatureResponse");
responseRootElem = responseDoc.getDocumentElement();
}
-
+
/**
- * Build a document containing a <code>VerifyCMSSignatureResponse</code>
- * DOM element being the XML representation of the given
+ * 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.
+ *
+ * @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 {
+ throws MOAApplicationException {
Iterator iter;
-
for (iter = response.getResponseElements().iterator(); iter.hasNext();) {
- VerifyCMSSignatureResponseElement responseElement =
- (VerifyCMSSignatureResponseElement) iter.next();
- Element signatureResult = ResponseBuilderUtils.addChildElement("SignatureResult", responseDoc, responseRootElem);
+ final VerifyCMSSignatureResponseElement responseElement =
+ (VerifyCMSSignatureResponseElement) iter.next();
+ final Element signatureResult = ResponseBuilderUtils.addChildElement("SignatureResult", responseDoc,
+ responseRootElem);
addResponseElement(responseElement, signatureResult);
-
+
}
-
+
return responseDoc;
}
/**
* Add an element to the response.
- *
+ *
* @param responseElement The element to add to the response.
- * @param signatureResult
+ * @param signatureResult
* @throws MOAApplicationException An error occurred adding the element.
*/
private void addResponseElement(VerifyCMSSignatureResponseElement responseElement, Element responseElem)
- 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();
-
if (signerInfo != null) {
- ResponseBuilderUtils.addSignerInfo(
- responseDoc,
- responseElem,
- signerInfo.getSignerCertificate(),
- signerInfo.isQualifiedCertificate(),
- signerInfo.getQCSource(),
- signerInfo.isPublicAuthority(),
- signerInfo.getPublicAuhtorityID(),
- signerInfo.isSSCD(),
- signerInfo.getSSCDSource(),
- signerInfo.getIssuerCountryCode(),
- signerInfo.getTslInfos());
-
- ResponseBuilderUtils.addSigningTime(responseDoc,
- responseElem,
- signerInfo.getSigningTime());
-
-
+ ResponseBuilderUtils.addSignerInfo(
+ responseDoc,
+ responseElem,
+ signerInfo.getSignerCertificate(),
+ signerInfo.isQualifiedCertificate(),
+ signerInfo.getQCSource(),
+ signerInfo.isPublicAuthority(),
+ signerInfo.getPublicAuhtorityID(),
+ signerInfo.isSSCD(),
+ signerInfo.getSSCDSource(),
+ signerInfo.getIssuerCountryCode(),
+ signerInfo.getTslInfos());
+
+ ResponseBuilderUtils.addSigningTime(responseDoc,
+ responseElem,
+ signerInfo.getSigningTime());
+
} else {
- Logger.info("Find signature result with no 'SignerInfo'. Maybe a signature verification Failed");
-
+ Logger.info("Find signature result with no 'SignerInfo'. Maybe a signature verification Failed");
+
}
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());
- }
-
-
- //add additional PDF signature properteis
- if (responseElement.getCoversFullDocument() != null ||
- responseElement.getByteRangeOfSignature() != null) {
- Element pdfSigProps = ResponseBuilderUtils.createAndAddChildElement(responseDoc, responseElem, "SignatureProperties");
- ResponseBuilderUtils.addSignatureCoversFullPDF(responseDoc,
- pdfSigProps,
- responseElement.getCoversFullDocument());
- ResponseBuilderUtils.addSignatureByteRange(responseDoc,
- pdfSigProps,
- responseElement.getByteRangeOfSignature());
+ 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());
+ }
+
+ // add additional PDF signature properteis
+ if (responseElement.getCoversFullDocument() != null ||
+ responseElement.getByteRangeOfSignature() != null) {
+ final Element pdfSigProps = ResponseBuilderUtils.createAndAddChildElement(responseDoc, responseElem,
+ "SignatureProperties");
+ ResponseBuilderUtils.addSignatureCoversFullPDF(responseDoc,
+ pdfSigProps,
+ responseElement.getCoversFullDocument());
+ ResponseBuilderUtils.addSignatureByteRange(responseDoc,
+ pdfSigProps,
+ responseElement.getByteRangeOfSignature());
}
-
+
}
}