aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java')
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java164
1 files changed, 81 insertions, 83 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java
index de39948..265d0f3 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java
@@ -21,13 +21,10 @@
* 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 at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse;
-import at.gv.egovernment.moaspss.util.Constants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -38,137 +35,138 @@ import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponseElemen
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;
+import at.gv.egovernment.moaspss.util.Constants;
/**
- * 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 VerifyCMSSignatureResponseBuilder {
/** The XML document containing the response element. */
- private Document responseDoc;
+ private final Document responseDoc;
/** The response <code>VerifyCMSSignatureResponse</code> DOM element. */
- private Element responseElem;
+ private final Element responseElem;
private boolean includeSigningTime = false;
/**
* 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 VerifyCMSSignatureResponseBuilder() throws MOASystemException {
responseDoc =
- ResponseBuilderUtils.createResponse("VerifyCMSSignatureResponse");
+ ResponseBuilderUtils.createResponse("VerifyCMSSignatureResponse");
responseElem = responseDoc.getDocumentElement();
}
- public VerifyCMSSignatureResponseBuilder(Document responseDoc, String name, boolean includeSigningTime) throws MOASystemException {
- this.responseDoc = responseDoc;
- responseElem = responseDoc.createElementNS(Constants.MOA_NS_URI, name);
- this.includeSigningTime = includeSigningTime;
- }
+ public VerifyCMSSignatureResponseBuilder(Document responseDoc, String name, boolean includeSigningTime)
+ throws MOASystemException {
+ this.responseDoc = responseDoc;
+ responseElem = responseDoc.createElementNS(Constants.MOA_NS_URI, name);
+ this.includeSigningTime = includeSigningTime;
+ }
+
+ public Element buildElement(VerifyCMSSignatureResponse response) throws MOAApplicationException {
+ this.build(response);
+ return responseElem;
+ }
- public Element buildElement(VerifyCMSSignatureResponse response) throws MOAApplicationException {
- this.build(response);
- return responseElem;
- }
-
/**
- * 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();
+ final 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 {
+ 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());
-
- if(this.includeSigningTime) {
+ responseDoc,
+ responseElem,
+ signerInfo.getSignerCertificate(),
+ signerInfo.isQualifiedCertificate(),
+ signerInfo.getQCSource(),
+ signerInfo.isPublicAuthority(),
+ signerInfo.getPublicAuhtorityID(),
+ signerInfo.isSSCD(),
+ signerInfo.getSSCDSource(),
+ signerInfo.getIssuerCountryCode(),
+ signerInfo.getTslInfos());
+
+ if (this.includeSigningTime) {
ResponseBuilderUtils.addSigningTime(responseDoc,
- responseElem, signerInfo.getSigningTime());
+ responseElem, signerInfo.getSigningTime());
}
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());
+ }
+
}
}