diff options
author | gregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2003-11-11 22:36:36 +0000 |
---|---|---|
committer | gregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2003-11-11 22:36:36 +0000 |
commit | 643b4096cdd0f0ed98f21c9b5b681ed89bcb08dc (patch) | |
tree | 9e750c9103ad923b291820bc85fcbd669c2e7900 /spss.test/src/testgenerator/SignatureManifestCheckParams.java | |
parent | bc620256eb9b4dc6a33244b1105e58773358dbe6 (diff) | |
download | moa-id-spss-643b4096cdd0f0ed98f21c9b5b681ed89bcb08dc.tar.gz moa-id-spss-643b4096cdd0f0ed98f21c9b5b681ed89bcb08dc.tar.bz2 moa-id-spss-643b4096cdd0f0ed98f21c9b5b681ed89bcb08dc.zip |
Erstellt.tags/Build-1.2.0.D01-svn
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@51 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.test/src/testgenerator/SignatureManifestCheckParams.java')
-rw-r--r-- | spss.test/src/testgenerator/SignatureManifestCheckParams.java | 176 |
1 files changed, 176 insertions, 0 deletions
diff --git a/spss.test/src/testgenerator/SignatureManifestCheckParams.java b/spss.test/src/testgenerator/SignatureManifestCheckParams.java new file mode 100644 index 000000000..b1505418d --- /dev/null +++ b/spss.test/src/testgenerator/SignatureManifestCheckParams.java @@ -0,0 +1,176 @@ +package testgenerator; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.apache.xml.serialize.DOMWriterImpl; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + + +/** + * @author knirschs + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class SignatureManifestCheckParams { +/* So solls mal aussehen :-) + + <SignatureManifestCheckParams ReturnReferenceInputData="true"> + <ReferenceInfo> + <VerifyTransformsInfoProfile> + <dsig:Transforms> + <dsig:Transform Algorithm="http://www.w3.org/TR/1999/REC-xslt-19991116"> + <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/> + </dsig:Transform> + </dsig:Transforms> + <TransformParameter URI="validURI"> + <Base64Content>validBase64Data</Base64Content> + </TransformParameter> + </VerifyTransformsInfoProfile> + <VerifyTransformsInfoProfileID>validID</VerifyTransformsInfoProfileID> + </ReferenceInfo> + </SignatureManifestCheckParams> +*/ + private Document document; + private Element refInfo; + private Element verifyTrans; + private Element transPara; + private Element dsigTrans; + + public SignatureManifestCheckParams(String returnReferenceInputData) throws Exception{ + + // Find the implementation + DocumentBuilderFactory factory + = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + DocumentBuilder builder = factory.newDocumentBuilder(); + DOMImplementation impl = builder.getDOMImplementation(); + + // Create the document + document = impl.createDocument(null, "SignatureManifestCheckParams", null); + + //document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); // Create from whole cloth + Element root = document.getDocumentElement(); + if (returnReferenceInputData!=null) + root.setAttribute("ReturnReferenceInputData",returnReferenceInputData); + + refInfo = (Element) document.createElement("ReferenceInfo"); + root.appendChild(refInfo); + + verifyTrans = (Element) document.createElement("VerifyTransformsInfoProfile"); + + + } + + public void addTransPara(String URI) + { + transPara = document.createElement("TransformParameter"); + transPara.setAttribute("URI",URI); + verifyTrans.appendChild(transPara); + + } + + + /** + * Method addDsigTransform: To add an dsig:Tranform element with a special algorithm + * @param algName + */ + public void addDsigTransform(String algName, Element el) + { + if (dsigTrans==null) + { + dsigTrans = (Element) document.createElementNS("http://www.w3.org/2000/09/xmldsig#","Transforms"); + dsigTrans.setPrefix("dsig"); + verifyTrans.appendChild(dsigTrans); + + refInfo.appendChild(verifyTrans); + } + + + Element trans = document.createElementNS("http://www.w3.org/2000/09/xmldsig#","Transform"); + trans.setPrefix("dsig"); + trans.setAttribute("Algorithm",algName); + if (el!=null) trans.appendChild(el); + dsigTrans.appendChild(trans); + } + + public void addDisgTransform(Element transformElement) + { + if (dsigTrans==null) + { + dsigTrans = (Element) document.createElementNS("http://www.w3.org/2000/09/xmldsig#","Transforms"); + dsigTrans.setPrefix("dsig"); + verifyTrans.appendChild(dsigTrans); + + refInfo.appendChild(verifyTrans); + } + + dsigTrans.appendChild(transformElement); + } + + /** + * Method addTransformsProfileID. + * @param id + */ + public void addTransformsProfileID(String id) + { + Element profID = (Element) document.createElement("VerifyTransformsInfoProfileID"); + profID.appendChild(document.createTextNode(id)); + refInfo.appendChild(profID); + } + + public void addTransParaElement(String elemName, String content) + { + if (elemName!="Hash") { + + Element eleName = document.createElement(elemName); + eleName.appendChild(document.createTextNode(content)); + transPara.appendChild(eleName); + + } else { + + Element eleName = document.createElement(elemName); + Element digMethod = document.createElementNS("http://www.w3.org/2000/09/xmldsig#","DigestMethod"); + digMethod.setPrefix("dsig"); + digMethod.setAttribute("Algorithm","http://www.w3.org/2000/09/xmldsig#sha1"); + eleName.appendChild(digMethod); + Element hash = document.createElementNS("http://www.w3.org/2000/09/xmldsig#","DigestValue"); + hash.setPrefix("dsig"); + hash.appendChild(document.createTextNode(content)); + eleName.appendChild(hash); + + transPara.appendChild(eleName); + + + } + + } + +public String returnDoc() throws Exception + { + String result =(new DOMWriterImpl(true)).writeToString(document.getDocumentElement()); + + TestCases tc = new TestCases(); + + result = TestCases.replaceString(result,"<?xml version=\"1.0\"?>",""); + try { + result = TestCases.replaceString(result," xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\"",""); + result = TestCases.replaceString(result," xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\"",""); + result = TestCases.replaceString(result," xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\"",""); + } catch (Exception e) { + } + + + return result; + } + + public Document getDoc() throws Exception + { + return document; + } +} |