|
From: Pelle B. <pe...@us...> - 2004-04-16 23:54:12
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/xmlsec In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6037/src/test/org/neuclear/xml/xmlsec Modified Files: SimpleXMLSigTest.java Added Files: HTMLSignatureTest.java Log Message: Added HTMLSignature with tests and associated changes in StandaloneSigner --- NEW FILE: HTMLSignatureTest.java --- package org.neuclear.xml.xmlsec; import junit.framework.TestCase; import org.dom4j.Document; import org.neuclear.commons.crypto.passphraseagents.UserCancellationException; import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.commons.crypto.signers.Signer; import org.neuclear.commons.crypto.signers.TestCaseSigner; import org.neuclear.xml.XMLException; import org.neuclear.xml.XMLTools; import java.io.*; /* NeuClear Distributed Transaction Clearing Platform (C) 2003 Pelle Braendgaard This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA $Id: HTMLSignatureTest.java,v 1.1 2004/04/16 23:54:03 pelle Exp $ $Log: HTMLSignatureTest.java,v $ Revision 1.1 2004/04/16 23:54:03 pelle Added HTMLSignature with tests and associated changes in StandaloneSigner */ /** * User: pelleb * Date: Apr 16, 2004 * Time: 10:19:37 PM */ public class HTMLSignatureTest extends TestCase { public HTMLSignatureTest(String s) { super(s); } protected void setUp() throws Exception { signer = new TestCaseSigner(); } public void testSignHTMLDocument() throws FileNotFoundException, XMLException, NonExistingSignerException, UserCancellationException { InputStream is = new BufferedInputStream(new FileInputStream("src/testdata/html/bobsmith.html")); XMLSignature sig = new HTMLSignature("bob", signer, is); assertNotNull(sig); final File file = new File("target/testdata/html/bobsmithsig.html"); file.getParentFile().mkdirs(); XMLTools.writeFile(file, sig.getPrimaryReferenceElement()); Document doc = XMLTools.loadDocument(file); assertValidEnvelopedSignature(doc); } private void assertValidEnvelopedSignature(Document doc) throws XMLSecurityException { try { XMLSignature sig = new EnvelopedSignature(doc.getRootElement()); assertTrue("Signature Verified", true); } catch (InvalidSignatureException e) { assertTrue("Signature Failed", false); } } private Signer signer; } Index: SimpleXMLSigTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/xmlsec/SimpleXMLSigTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SimpleXMLSigTest.java 23 Mar 2004 20:51:00 -0000 1.13 --- SimpleXMLSigTest.java 16 Apr 2004 23:54:03 -0000 1.14 *************** *** 26,34 **** * $Id$ * $Log$ * Revision 1.13 2004/03/23 20:51:00 pelle * Added ExternalSignature and further Javadocs. * Added Busy Developers Guide and Interop guide. * Ready for release. ! * * Revision 1.12 2004/03/19 22:21:51 pelle * Changes in the XMLSignature class, which is now Abstract there are currently 3 implementations for: --- 26,37 ---- * $Id$ * $Log$ + * Revision 1.14 2004/04/16 23:54:03 pelle + * Added HTMLSignature with tests and associated changes in StandaloneSigner + * * Revision 1.13 2004/03/23 20:51:00 pelle * Added ExternalSignature and further Javadocs. * Added Busy Developers Guide and Interop guide. * Ready for release. ! * <p/> * Revision 1.12 2004/03/19 22:21:51 pelle * Changes in the XMLSignature class, which is now Abstract there are currently 3 implementations for: *************** *** 321,325 **** EnvelopedSignature envsig = new EnvelopedSignature(kp, elem); ! System.out.println(doc.asXML()); try { --- 324,328 ---- EnvelopedSignature envsig = new EnvelopedSignature(kp, elem); ! // System.out.println(doc.asXML()); try { *************** *** 338,342 **** DataObjectSignature datasig = new DataObjectSignature(kp, elem); Element sigelem = datasig.getElement(); ! System.out.println(sigelem.asXML()); try { --- 341,345 ---- DataObjectSignature datasig = new DataObjectSignature(kp, elem); Element sigelem = datasig.getElement(); ! // System.out.println(sigelem.asXML()); try { |