diff options
Diffstat (limited to 'spss.server/src/at/gv/egovernment/moa/spss/api')
5 files changed, 284 insertions, 17 deletions
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/InputData.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/InputData.java new file mode 100644 index 000000000..1ecce90e7 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/InputData.java @@ -0,0 +1,52 @@ +package at.gv.egovernment.moa.spss.api.common; + +/** + * Interface specifying accessors for two attributes needed for returning + * <code>HashInputData</code> and <code>ReferenceInputData</code> information + * as part of <code>VerifyXMLSignatureResponse</code>. + * + * @author Gregor Karlinger + * + * @version $Id$ + */ +public interface InputData extends Content +{ + /** + * Possible value returned by {@link getPartOf}. + */ + public static String CONTAINER_SIGNEDINFO_ = "SignedInfo"; + + /** + * Possible value returned by {@link getPartOf}. + */ + public static String CONTAINER_XMLDSIGMANIFEST_ = "XMLDSIGManifest"; + + /** + * Possible value returned by {@link getPartOf}. + */ + public static String CONTAINER_SIGNATUREMANIFEST_ = "SignatureManifest"; + + /** + * Value returned by {link getReferringReferenceNumber}, signalling that the + * attribute is not used. + */ + public static int REFERER_NONE_ = -1; + + /** + * Returns a <code>String</code> signalling what kind of container the + * XMLDSIG <code>Reference</code> this <code>InputData</code> belongs + * to is part of. + * + * @return the kind of container. + */ + public String getPartOf(); + + /** + * If this <code>InputData</code> belongs to an XMLDSIG <code>Reference</code> + * being part of either a XMLDSIGManifest or a SignatureManifest, this method + * returns a positive int value signalling the particular <code>Reference</code> + * of the XMLDSIG <code>SignedInfo</code> referring to the XMLDSIGManifest or + * SignatureManifest respectively. + */ + public int getReferringReferenceNumber(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/InputDataBinaryImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/InputDataBinaryImpl.java new file mode 100644 index 000000000..42d61559e --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/InputDataBinaryImpl.java @@ -0,0 +1,99 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.io.InputStream; + +import at.gv.egovernment.moa.spss.MOARuntimeException; +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.common.ContentBinary; +import at.gv.egovernment.moa.spss.api.common.InputData; + +/** + * Content wrapper decorating a binary content with two additional attributes + * needed for returning <code>HashInputData</code> and <code>ReferenceInputData + * </code> information as part of <code>VerifyXMLSignatureResponse</code>. + * + * @author Gregor Karlinger + * + * @version $Id$ + */ +public class InputDataBinaryImpl implements ContentBinary, InputData +{ + /** + * The wrapped <code>Content</code>. + */ + protected ContentBinary wrapped_; + + /** + * This attribute signals what kind of container the XMLDSIG <code>Reference</code> + * this <code>InputData</code> belongs to is part of. + */ + protected String partOf_; + + /** + * If this <code>InputData</code> belongs to an XMLDSIG <code>Reference</code> + * being part of either a XMLDSIGManifest or a SignatureManifest, this attribute + * (a positive int) signals the particular <code>Reference</code> of the XMLDSIG + * <code>SignedInfo</code> referring to the XMLDSIGManifest or SignatureManifest + * respectively. + */ + protected int referringReferenceNumber_; + + /** + * Creates a new instance. + * + * @param wrapped The wrapped <code>Content</code>. Must be of type {@link Content#BINARY_CONTENT}. + * + * @param partOf see {@link InputData} + * + * @param referringReferenceNumber see {@link InputData} + */ + public InputDataBinaryImpl(Content wrapped, String partOf, int referringReferenceNumber) throws MOARuntimeException + { + if (wrapped.getContentType() != Content.BINARY_CONTENT) throw new MOARuntimeException("9901", null); + + wrapped_ = (ContentBinary) wrapped; + partOf_ = partOf; + referringReferenceNumber_ = referringReferenceNumber; + } + + /** + * @see at.gv.egovernment.moa.spss.api.common.Content#getContentType() + */ + public int getContentType() + { + return wrapped_.getContentType(); + } + + /** + * @see at.gv.egovernment.moa.spss.api.common.Content#getReference() + */ + public String getReference() + { + return wrapped_.getReference(); + } + + /** + * @see at.gv.egovernment.moa.spss.api.common.ContentBinary#getBinaryContent() + */ + public InputStream getBinaryContent() + { + return wrapped_.getBinaryContent(); + } + + /** + * @see at.gv.egovernment.moa.spss.api.common.InputData#getPartOf() + */ + public String getPartOf() + { + return partOf_; + } + + /** + * @see at.gv.egovernment.moa.spss.api.common.InputData#getReferringReferenceNumber() + */ + public int getReferringReferenceNumber() + { + return referringReferenceNumber_; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/InputDataXMLImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/InputDataXMLImpl.java new file mode 100644 index 000000000..029a402f5 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/InputDataXMLImpl.java @@ -0,0 +1,99 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import org.w3c.dom.NodeList; + +import at.gv.egovernment.moa.spss.MOARuntimeException; +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.common.ContentXML; +import at.gv.egovernment.moa.spss.api.common.InputData; + +/** + * Content wrapper decorating an XML content with two additional attributes + * needed for returning <code>HashInputData</code> and <code>ReferenceInputData + * </code> information as part of <code>VerifyXMLSignatureResponse</code>. + * + * @author Gregor Karlinger + * + * @version $Id$ + */ +public class InputDataXMLImpl implements ContentXML, InputData +{ + /** + * The wrapped <code>ContentXML</code>. + */ + protected ContentXML wrapped_; + + /** + * This attribute signals what kind of container the XMLDSIG <code>Reference</code> + * this <code>InputData</code> belongs to is part of. + */ + protected String partOf_; + + /** + * If this <code>InputData</code> belongs to an XMLDSIG <code>Reference</code> + * being part of either a XMLDSIGManifest or a SignatureManifest, this attribute + * (a positive int) signals the particular <code>Reference</code> of the XMLDSIG + * <code>SignedInfo</code> referring to the XMLDSIGManifest or SignatureManifest + * respectively. + */ + protected int referringReferenceNumber_; + + /** + * Creates a new instance. + * + * @param wrapped The wrapped <code>ContentBinary</code>. Must be of type {@link Content#XML_CONTENT}. + * + * @param partOf see {@link InputData} + * + * @param referringReferenceNumber see {@link InputData} + */ + public InputDataXMLImpl(Content wrapped, String partOf, int referringReferenceNumber) + { + if (wrapped.getContentType() != Content.XML_CONTENT) throw new MOARuntimeException("9901", null); + + wrapped_ = (ContentXML) wrapped; + partOf_ = partOf; + referringReferenceNumber_ = referringReferenceNumber; + } + + /** + * @see at.gv.egovernment.moa.spss.api.common.Content#getContentType() + */ + public int getContentType() + { + return wrapped_.getContentType(); + } + + /** + * @see at.gv.egovernment.moa.spss.api.common.Content#getReference() + */ + public String getReference() + { + return wrapped_.getReference(); + } + + /** + * @see at.gv.egovernment.moa.spss.api.common.ContentXML#getXMLContent() + */ + public NodeList getXMLContent() + { + return wrapped_.getXMLContent(); + } + + /** + * @see at.gv.egovernment.moa.spss.api.common.InputData#getPartOf() + */ + public String getPartOf() + { + return partOf_; + } + + /** + * @see at.gv.egovernment.moa.spss.api.common.InputData#getReferringReferenceNumber() + */ + public int getReferringReferenceNumber() + { + return referringReferenceNumber_; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyXMLSignatureResponseImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyXMLSignatureResponseImpl.java index f163013c1..989dbfb4a 100644 --- a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyXMLSignatureResponseImpl.java +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyXMLSignatureResponseImpl.java @@ -18,10 +18,17 @@ public class VerifyXMLSignatureResponseImpl /** Information about the signer certificate. */ private SignerInfo signerInfo; - /** The hash input data objects. */ + + /** + * The hash input data objects. The list consists of {@link at.gv.egovernment.moa.spss.api.common.InputData}s. + * */ private List hashInputDatas = new ArrayList(); - /** The reference input data objects. */ + + /** + * The reference input data objects. The list consists of {@link at.gv.egovernment.moa.spss.api.common.InputData}s. + * */ private List referenceInputDatas = new ArrayList(); + /** Information about the signature check. */ private ReferencesCheckResult signatureCheck; /** Information about the signature manifest check. */ diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureResponseBuilder.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureResponseBuilder.java index 56bcf63fa..960d9571d 100644 --- a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureResponseBuilder.java +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureResponseBuilder.java @@ -17,6 +17,7 @@ import at.gv.egovernment.moa.spss.MOASystemException; import at.gv.egovernment.moa.spss.api.common.Content; import at.gv.egovernment.moa.spss.api.common.ContentBinary; import at.gv.egovernment.moa.spss.api.common.ContentXML; +import at.gv.egovernment.moa.spss.api.common.InputData; import at.gv.egovernment.moa.spss.api.xmlverify.ManifestRefsCheckResult; import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResult; import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse; @@ -78,8 +79,8 @@ public class VerifyXMLSignatureResponseBuilder { responseData = response.getHashInputDatas(); if (responseData != null && !responseData.isEmpty()) { for (iter = responseData.iterator(); iter.hasNext();) { - Content content = (Content) iter.next(); - addContent("HashInputData", content); + InputData inputData = (InputData) iter.next(); + addContent("HashInputData", inputData); } } @@ -87,8 +88,8 @@ public class VerifyXMLSignatureResponseBuilder { responseData = response.getReferenceInputDatas(); if (responseData != null && !responseData.isEmpty()) { for (iter = responseData.iterator(); iter.hasNext();) { - Content content = (Content) iter.next(); - addContent("ReferenceInputData", content); + InputData inputData = (InputData) iter.next(); + addContent("ReferenceInputData", inputData); } } @@ -127,23 +128,32 @@ public class VerifyXMLSignatureResponseBuilder { * Add an element of type <code>ContentBaseType</code> to the response. * * @param elementName The name of the element. - * @param content The <code>Content</code> to add. Based on the type of - * the <code>Content</code>, either a <code>Base64Content</code> element - * or a <code>XMLContent</code> subelement will be added. A - * <code>ContentBinary</code> of type <code>BinaryDataObject</code> will be - * added as a <code>Base64Content</code> child element. - * <code>ContentXML</code> will be added as <code>XMLContent</code> child - * element. + * + * @param inputData The <code>InputData</code> to add. Based on the type of + * + * the <code>InputData</code>, either a <code>Base64Content</code> element + * or a <code>XMLContent</code> subelement will be added. An <code> + * InputDataBinaryImpl</code> will be added as a <code>Base64Content</code> + * child element. An<code>InputDataXMLImpl</code> will be added as <code> + * XMLContent</code> child element. + * * @throws MOAApplicationException An error occurred adding the content. */ - private void addContent(String elementName, Content content) + private void addContent(String elementName, InputData inputData) throws MOAApplicationException { Element contentElem = responseDoc.createElementNS(MOA_NS_URI, elementName); - switch (content.getContentType()) { + contentElem.setAttributeNS(null, "PartOf", inputData.getPartOf()); + if (inputData.getReferringReferenceNumber() != InputData.REFERER_NONE_) + contentElem.setAttributeNS( + null, + "ReferringSigReference", + Integer.toString(inputData.getReferringReferenceNumber())); + + switch (inputData.getContentType()) { case Content.XML_CONTENT : - ContentXML contentXml = (ContentXML) content; + ContentXML contentXml = (ContentXML) inputData; NodeList nodes = contentXml.getXMLContent(); Element xmlElem; int i; @@ -161,7 +171,7 @@ public class VerifyXMLSignatureResponseBuilder { case Content.BINARY_CONTENT : Element binaryElem = responseDoc.createElementNS(MOA_NS_URI, "Base64Content"); - ContentBinary contentBinary = (ContentBinary) content; + ContentBinary contentBinary = (ContentBinary) inputData; String base64Str; try { |