From 643b4096cdd0f0ed98f21c9b5b681ed89bcb08dc Mon Sep 17 00:00:00 2001 From: gregor Date: Tue, 11 Nov 2003 22:36:36 +0000 Subject: Erstellt. git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@51 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../SignatureManifestCheckParams.java | 176 +++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 spss.test/src/testgenerator/SignatureManifestCheckParams.java (limited to 'spss.test/src/testgenerator/SignatureManifestCheckParams.java') 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 :-) + + + + + + + + + + + validBase64Data + + + validID + + +*/ + 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,"",""); + 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; + } +} -- cgit v1.2.3