You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(119) |
Oct
(111) |
Nov
(238) |
Dec
(395) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(239) |
Feb
(59) |
Mar
(354) |
Apr
(489) |
May
(23) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
(5) |
Jun
(2) |
Jul
|
Aug
|
Sep
(3) |
Oct
(14) |
Nov
(17) |
Dec
(9) |
| 2007 |
Jan
(4) |
Feb
(3) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
|
Aug
|
Sep
(1) |
Oct
(2) |
Nov
(1) |
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(7) |
May
(3) |
Jun
(6) |
Jul
(4) |
Aug
(3) |
Sep
(15) |
Oct
(13) |
Nov
(35) |
Dec
(40) |
| 2009 |
Jan
(19) |
Feb
(21) |
Mar
(16) |
Apr
(18) |
May
(36) |
Jun
(20) |
Jul
(32) |
Aug
(11) |
Sep
(3) |
Oct
(2) |
Nov
(2) |
Dec
(13) |
| 2010 |
Jan
(5) |
Feb
(5) |
Mar
(7) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(4) |
Nov
|
Dec
(3) |
| 2012 |
Jan
(3) |
Feb
(3) |
Mar
(1) |
Apr
(4) |
May
(8) |
Jun
(4) |
Jul
(9) |
Aug
(2) |
Sep
(8) |
Oct
(3) |
Nov
(8) |
Dec
(4) |
| 2013 |
Jan
(2) |
Feb
(1) |
Mar
(5) |
Apr
(6) |
May
(10) |
Jun
(5) |
Jul
(6) |
Aug
(7) |
Sep
(5) |
Oct
(2) |
Nov
(4) |
Dec
(4) |
| 2014 |
Jan
(13) |
Feb
(4) |
Mar
(7) |
Apr
(9) |
May
(20) |
Jun
(13) |
Jul
(10) |
Aug
(3) |
Sep
(5) |
Oct
(2) |
Nov
(2) |
Dec
(2) |
| 2015 |
Jan
(3) |
Feb
(3) |
Mar
(5) |
Apr
(4) |
May
(3) |
Jun
(2) |
Jul
(4) |
Aug
(3) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(3) |
| 2016 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(4) |
Sep
(3) |
Oct
(3) |
Nov
(4) |
Dec
(2) |
| 2017 |
Jan
|
Feb
(2) |
Mar
|
Apr
(2) |
May
(1) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <pe...@us...> - 2004-03-03 23:39:43
|
Update of /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19593/src/test/org/neuclear/id Modified Files: IdentityTests.java NeuClearBenchmark.java SignedMessageTest.java Log Message: Updated various tests to use the AbstractObjectCreationTest Index: IdentityTests.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/id/IdentityTests.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IdentityTests.java 18 Feb 2004 00:14:36 -0000 1.4 --- IdentityTests.java 3 Mar 2004 23:26:44 -0000 1.5 *************** *** 7,10 **** --- 7,11 ---- import org.neuclear.commons.crypto.CryptoException; import org.neuclear.commons.crypto.CryptoTools; + import org.neuclear.commons.crypto.Base32; import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.id.builders.Builder; *************** *** 27,31 **** */ public class IdentityTests extends AbstractObjectCreationTest { - private static final String NAME = "neu://test"; private static final String SIGNER = "http://localhost:11870/Signer"; --- 28,31 ---- *************** *** 34,49 **** } ! protected void verifyObject(SignedNamedObject obj) throws NonExistingSignerException { assertTrue(obj instanceof Identity); Identity id=(Identity) obj; ! assertEquals(CryptoTools.encodeBase32(CryptoTools.digest(signer.getPublicKey(NAME).getEncoded())),obj.getName().substring(5,37)); ! // assertEquals(id.getLogger(),LOGGER); ! // assertEquals(id.getName()); ! // assertEquals(id.getRepository(),REPOSITORY); assertEquals(id.getSigner(),SIGNER); - // assertEquals(id.getReceiver(),RECEIVER); assertNotNull(id.getPublicKey()); } protected Builder createBuilder() throws NeuClearException { return new IdentityBuilder(getSigner().getPublicKey(NAME),SIGNER,null,null); --- 34,52 ---- } ! protected void verifyObject(SignedNamedObject obj) throws CryptoException { assertTrue(obj instanceof Identity); Identity id=(Identity) obj; ! assertEquals(CryptoTools.encodeBase32(CryptoTools.digest(signer.getPublicKey(NAME).getEncoded())), ! obj.getName().substring(5,37)); ! assertEquals(new String(CryptoTools.digest(signer.getPublicKey(NAME).getEncoded())), ! new String(Base32.decode(obj.getName().substring(5,37)))); assertEquals(id.getSigner(),SIGNER); assertNotNull(id.getPublicKey()); } + protected Class getRequiredClass() { + return Identity.class; + } + protected Builder createBuilder() throws NeuClearException { return new IdentityBuilder(getSigner().getPublicKey(NAME),SIGNER,null,null); *************** *** 60,63 **** --- 63,67 ---- } + public void testEmbedded() throws NoSuchAlgorithmException, XMLSecurityException, CryptoException, NameResolutionException, InvalidNamedObjectException{ KeyPair kp=CryptoTools.createTinyKeyPair(); Index: NeuClearBenchmark.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/id/NeuClearBenchmark.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NeuClearBenchmark.java 2 Mar 2004 18:59:12 -0000 1.3 --- NeuClearBenchmark.java 3 Mar 2004 23:26:44 -0000 1.4 *************** *** 69,74 **** } catch (InvalidNamedObjectException e) { e.printStackTrace(); //To change body of catch statement use Options | File Templates. - } catch (NameResolutionException e) { - e.printStackTrace(); //To change body of catch statement use Options | File Templates. } } --- 69,72 ---- Index: SignedMessageTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/id/SignedMessageTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SignedMessageTest.java 19 Jan 2004 23:49:45 -0000 1.3 --- SignedMessageTest.java 3 Mar 2004 23:26:44 -0000 1.4 *************** *** 28,31 **** --- 28,35 ---- } + protected Class getRequiredClass() { + return SignedMessage.class; + } + protected Builder createBuilder() throws NeuClearException { return new SignedMessageBuilder("neu://alice@test","Test","Hello there"); |
|
From: <pe...@us...> - 2004-03-03 23:39:42
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/tools/commandline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19593/src/java/org/neuclear/id/tools/commandline Modified Files: CommandLineSigner.java IdentityCreator.java Log Message: Updated various tests to use the AbstractObjectCreationTest Index: CommandLineSigner.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/tools/commandline/CommandLineSigner.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CommandLineSigner.java 19 Feb 2004 19:38:13 -0000 1.11 --- CommandLineSigner.java 3 Mar 2004 23:26:43 -0000 1.12 *************** *** 1,4 **** --- 1,7 ---- /* $Id$ * $Log$ + * Revision 1.12 2004/03/03 23:26:43 pelle + * Updated various tests to use the AbstractObjectCreationTest + * * Revision 1.11 2004/02/19 19:38:13 pelle * At times IntelliJ IDEA can cause some real hassle. On my last checkin it optimized away all of the dom4j and command line imports. *************** *** 182,186 **** * * Revision 1.4 2002/10/10 21:29:25 pelle ! * Oops. XML-Signature's SignedInfo element I had coded as SignatureInfo * As I thought Canonicalisation doesnt seem to be standard. * Updated the SignedServlet to default to using ~/.neuclear/signers.ks --- 185,189 ---- * * Revision 1.4 2002/10/10 21:29:25 pelle ! * Oops. XML-Signature's SignedInfo element I had coded as SignedInfo * As I thought Canonicalisation doesnt seem to be standard. * Updated the SignedServlet to default to using ~/.neuclear/signers.ks *************** *** 222,225 **** --- 225,229 ---- package org.neuclear.id.tools.commandline; + import org.apache.commons.cli.*; import org.dom4j.Document; import org.neuclear.commons.LowLevelException; *************** *** 241,245 **** import org.neuclear.xml.XMLException; import org.neuclear.xml.XMLTools; - import org.apache.commons.cli.*; import java.io.*; --- 245,248 ---- *************** *** 363,368 **** dest = new FileOutputStream(of); System.out.println("Outputting to: " + of); } - XMLTools.writeFile(dest, subject.getElement()); System.out.println(); System.out.println("You now need to copy the file: " + of + " to your webserver so it is visible at a given location"); --- 366,371 ---- dest = new FileOutputStream(of); System.out.println("Outputting to: " + of); + XMLTools.writeFile(outFile, subject.getElement().getDocument()); } System.out.println(); System.out.println("You now need to copy the file: " + of + " to your webserver so it is visible at a given location"); Index: IdentityCreator.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/tools/commandline/IdentityCreator.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IdentityCreator.java 2 Mar 2004 18:59:11 -0000 1.9 --- IdentityCreator.java 3 Mar 2004 23:26:43 -0000 1.10 *************** *** 1,4 **** --- 1,7 ---- /* $Id$ * $Log$ + * Revision 1.10 2004/03/03 23:26:43 pelle + * Updated various tests to use the AbstractObjectCreationTest + * * Revision 1.9 2004/03/02 18:59:11 pelle * Further cleanups in neuclear-id. Moved everything under id. *************** *** 178,182 **** * * Revision 1.4 2002/10/10 21:29:25 pelle ! * Oops. XML-Signature's SignedInfo element I had coded as SignatureInfo * As I thought Canonicalisation doesnt seem to be standard. * Updated the SignedServlet to default to using ~/.neuclear/signers.ks --- 181,185 ---- * * Revision 1.4 2002/10/10 21:29:25 pelle ! * Oops. XML-Signature's SignedInfo element I had coded as SignedInfo * As I thought Canonicalisation doesnt seem to be standard. * Updated the SignedServlet to default to using ~/.neuclear/signers.ks *************** *** 261,265 **** final String defaultlogger = Utility.denullString(cmd.getOptionValue("l"), LogSender.LOGGER); final String defaultreceiver = cmd.getOptionValue("b"); ! if (!sig.canSignFor(alias)){ System.out.println("You do not currently have a key matching this name. Do you with to create one?"); if (!Utility.getAffirmative(true)) { --- 264,268 ---- final String defaultlogger = Utility.denullString(cmd.getOptionValue("l"), LogSender.LOGGER); final String defaultreceiver = cmd.getOptionValue("b"); ! if (!sig.canSignFor(alias)) { System.out.println("You do not currently have a key matching this name. Do you with to create one?"); if (!Utility.getAffirmative(true)) { *************** *** 267,272 **** System.exit(0); } ! System.out.println("Generating Keys for "+alias+"... "); ! PublicKey pub=sig.generateKey(alias); System.out.println("DONE"); System.out.println("STORING Keys"); --- 270,275 ---- System.exit(0); } ! System.out.println("Generating Keys for " + alias + "... "); ! PublicKey pub = sig.generateKey(alias); System.out.println("DONE"); System.out.println("STORING Keys"); *************** *** 276,282 **** final PublicKey newkid = pksource.getPublicKey(alias); ! return new IdentityBuilder(newkid, defaultsigner, defaultlogger, defaultreceiver); } catch (InvalidNamedObjectException e) { ! System.err.println("The name: "+e.getName()+" is not valid. "); System.exit(1); } catch (NonExistingSignerException e) { --- 279,285 ---- final PublicKey newkid = pksource.getPublicKey(alias); ! return new IdentityBuilder(newkid, defaultsigner, defaultlogger, defaultreceiver); } catch (InvalidNamedObjectException e) { ! System.err.println("The name: " + e.getName() + " is not valid. "); System.exit(1); } catch (NonExistingSignerException e) { *************** *** 290,294 **** final IdentityCreator signer = new IdentityCreator(args); signer.execute(); ! } catch (UserCancellationException e){ System.out.println("Bye"); } catch (Exception e) { --- 293,297 ---- final IdentityCreator signer = new IdentityCreator(args); signer.execute(); ! } catch (UserCancellationException e) { System.out.println("Bye"); } catch (Exception e) { |
|
From: <pe...@us...> - 2004-03-03 23:37:19
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19226/src/java/org/neuclear/commons/crypto Modified Files: Base32.java Log Message: Added a "test" alias to testkeys.jks Index: Base32.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/Base32.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Base32.java 19 Jan 2004 23:49:29 -0000 1.4 --- Base32.java 3 Mar 2004 23:24:25 -0000 1.5 *************** *** 22,25 **** --- 22,28 ---- $Id$ $Log$ + Revision 1.5 2004/03/03 23:24:25 pelle + Added a "test" alias to testkeys.jks + Revision 1.4 2004/01/19 23:49:29 pelle Unit testing uncovered further issues with Base32 *************** *** 139,142 **** --- 142,156 ---- return new String(encodeToByteArray(raw)); } + + /** + * Encode a String as base32 + * + * @param raw <code>byte[]<code> to be base32 encoded + * @return the <code>String<code> with encoded data + */ + public static String encode(final String raw) throws CryptoException { + return encode(raw.getBytes()); + } + public static int getEncodedLength(int src) { final int baselength = src*8; *************** *** 194,206 **** return (byte) ((chunk>>>((7-num)*5))&31); } - /** - * Encode a String as base32 - * - * @param raw <code>byte[]<code> to be base32 encoded - * @return the <code>String<code> with encoded data - */ - public static String encode(final String raw) throws CryptoException { - return encode(raw.getBytes()); - } private static byte encodeVal(byte val) { --- 208,211 ---- |
|
From: <pe...@us...> - 2004-03-03 23:37:18
|
Update of /cvsroot/neuclear/neuclear-commons/src/testdata/keys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19226/src/testdata/keys Modified Files: testkeys.jks Log Message: Added a "test" alias to testkeys.jks Index: testkeys.jks =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/testdata/keys/testkeys.jks,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsKJhZwj and /tmp/cvsYpjKiO differ |
|
From: <pe...@us...> - 2004-03-03 23:37:18
|
Update of /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19226/src/test/org/neuclear/commons/crypto Modified Files: Base32Tests.java Log Message: Added a "test" alias to testkeys.jks Index: Base32Tests.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/Base32Tests.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Base32Tests.java 19 Feb 2004 15:29:13 -0000 1.6 --- Base32Tests.java 3 Mar 2004 23:24:25 -0000 1.7 *************** *** 23,26 **** --- 23,29 ---- $Id$ $Log$ + Revision 1.7 2004/03/03 23:24:25 pelle + Added a "test" alias to testkeys.jks + Revision 1.6 2004/02/19 15:29:13 pelle Various cleanups and corrections *************** *** 79,108 **** } ! /* public void testSHABase32() throws CryptoException { for (int i=0;i<TESTSTRINGS.length;i++){ ! // System.out.print("Encoding: "+TESTSTRINGS[i]+" ..."); ! final String hash = com.waterken.url.Base32.encode(CryptoTools.digest(TESTSTRINGS[i])); ! assertEquals(32, hash.length()); ! System.out.println(" ->"+hash); ! assertTrue("TESTSTRINGS["+i+"]",CryptoTools.equalByteArrays(CryptoTools.digest(TESTSTRINGS[i]),Base32.decode(hash))); } } ! public void testSHABase32vsTyler() throws CryptoException { for (int i=0;i<TESTSTRINGS.length;i++){ ! // System.out.print("Encoding: "+TESTSTRINGS[i]+" ..."); ! final String hash = com.waterken.url.Base32.encode(CryptoTools.digest(TESTSTRINGS[i])); ! assertEquals(32, hash.length()); ! // System.out.println(" ->"+hash); assertTrue("TESTSTRINGS["+i+"]",CryptoTools.equalByteArrays(CryptoTools.digest(TESTSTRINGS[i]),Base32.decode(hash))); } } public void testBase32vsTyler() throws CryptoException { for (int i=0;i<TESTSTRINGS.length;i++){ - // System.out.print("Encoding: "+TESTSTRINGS[i]+" ..."); final String encoded = Base32.encode(TESTSTRINGS[i]); ! // System.out.println(" ->"+encoded); ! assertEquals("TESTSTRINGS["+i+"]",com.waterken.url.Base32.encode(TESTSTRINGS[i].getBytes()),encoded); } } --- 82,107 ---- } ! public void testSHA1vsDecodedTyler() throws CryptoException { for (int i=0;i<TESTSTRINGS.length;i++){ ! assertTrue("TESTSTRINGS["+i+"]",CryptoTools.equalByteArrays(CryptoTools.digest(TESTSTRINGS[i]),Base32.decode(TYLER_SHA1_OUTPUT[i]))); } } ! public void testSHA1vsDecodedOwn() throws CryptoException { for (int i=0;i<TESTSTRINGS.length;i++){ ! byte[] hash=Base32.encode(CryptoTools.digest(TESTSTRINGS[i])).getBytes(); assertTrue("TESTSTRINGS["+i+"]",CryptoTools.equalByteArrays(CryptoTools.digest(TESTSTRINGS[i]),Base32.decode(hash))); } } + public void testSHA1HomevsTyler() throws CryptoException { + for (int i=0;i<TESTSTRINGS.length;i++){ + assertEquals("TESTSTRINGS["+i+"]",Base32.encode(CryptoTools.digest(TESTSTRINGS[i])),TYLER_SHA1_OUTPUT); + } + } public void testBase32vsTyler() throws CryptoException { for (int i=0;i<TESTSTRINGS.length;i++){ final String encoded = Base32.encode(TESTSTRINGS[i]); ! assertEquals("TESTSTRINGS["+i+"]",TYLER_OUTPUT[i],encoded); } } *************** *** 111,122 **** for (int i=0;i<TESTSTRINGS.length;i++){ ! // System.out.print("Encoding: "+TESTSTRINGS[i]+" ..."); ! // final String encoded = Base32.encode(TESTSTRINGS[i]); ! // System.out.println(" ->"+encoded); ! final byte decoded[] = Base32.decode(com.waterken.url.Base32.encode(TESTSTRINGS[i].getBytes())); assertEquals("TESTSTRINGS["+i+"]",TESTSTRINGS[i].getBytes(),decoded); } } - */ public void assertEquals(String description, byte a[], byte b[]) { assertEquals(description + " length", a.length, b.length); --- 110,117 ---- for (int i=0;i<TESTSTRINGS.length;i++){ ! final byte decoded[] = Base32.decode(TYLER_OUTPUT[i]); assertEquals("TESTSTRINGS["+i+"]",TESTSTRINGS[i].getBytes(),decoded); } } public void assertEquals(String description, byte a[], byte b[]) { assertEquals(description + " length", a.length, b.length); *************** *** 126,129 **** --- 121,134 ---- } + + /* + public void testOutputTyler() throws CryptoException{ + for (int i=0;i<TESTSTRINGS.length;i++){ + final String encoded = com.waterken.url.Base32.encode(CryptoTools.digest(TESTSTRINGS[i])); + System.out.println("\""+encoded+"\","); + } + } + */ + static final String TESTSTRINGS[] = new String[]{ "", *************** *** 143,146 **** --- 148,183 ---- }; + static final String TYLER_OUTPUT[]=new String[]{ + "", + "ga", + "gayq", + "gayte", + "gaytemy", + "gaytemzu", + "gaytemzugu", + "gaytemzugu3a", + "gaytemzugu3do", + "gaytemzugu3dooa", + "gaytemzugu3doobz", + "gaytemzugu3doobzie", + "gaytemzugu3doobzieydcmrtgq2tmnzyhfaxgmbrgiztinjwg44dsqi", + "h47qqpz7h4cd6hb7cq7t6pz7ha7wwx3x" + }; + static final String TYLER_SHA1_OUTPUT[]=new String[]{ + "3i42h3s6nnfq2msvx7xzkyayscx5qbyj", + "wzmj7rvlbxecz4jathi4fvakxgkoqqim", + "3x7bmm2f2m4bsowcxxayh6hj3t7zas2d", + "ysrntg6crurwbgfasutxw7vqoggwxydi", + "ys24q26vo7nd3e76u7ejzotby6furzmj", + "cgieutulo73cilrnfcdqkar23liaveyq", + "7x4lywauknxwmajiqtqunkeipjchbgsw", + "w7wqramqyiclghgxcsconiofhcmgwx3x", + "zsvi3dompubqzvvgo2g3qh4q2dxzo3b5", + "tjyutjnhpbv3g2hanuemlv3xotvuhje6", + "q6woyf6ntxgsbjywzqwpm5axw4oiu4aw", + "weh5oeb3kibeinn6i3jiaskxum76y7dn", + "uo4jb3ds2i2bb2qbds2h5nusuwum2fxh", + "5bhw3daqpo2iq5eqbqgt54g5otdjldov" + }; } |
|
From: <pe...@us...> - 2004-03-03 23:36:19
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19311/src/java/org/neuclear/xml/c14 Modified Files: Canonicalizer.java Log Message: Interops with enveloped signatures. Index: Canonicalizer.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14/Canonicalizer.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Canonicalizer.java 2 Mar 2004 23:50:45 -0000 1.11 --- Canonicalizer.java 3 Mar 2004 23:23:24 -0000 1.12 *************** *** 8,11 **** --- 8,14 ---- * $Id$ * $Log$ + * Revision 1.12 2004/03/03 23:23:24 pelle + * Interops with enveloped signatures. + * * Revision 1.11 2004/03/02 23:50:45 pelle * minor changes. *************** *** 144,147 **** --- 147,151 ---- import org.neuclear.xml.transforms.XPathTransform; import org.neuclear.xml.xmlsec.XMLSecurityException; + import org.neuclear.commons.Utility; import java.io.*; *************** *** 351,366 **** namespaceStack.push(ns); writeNamespace(ns, sorted); ! // } else if (ns.getURI() != null && ! // ns.getURI().equals("") && ! // element.getParent() != null && ! // element.getParent().getNamespaceURI() != null ! // && !element.getParent().getNamespaceURI().equals("") ! } else if ( ! (element.getParent() == null) ! || ( ! !ns.getURI().equals(element.getParent().getNamespaceURI()) ! && ns.getPrefix().equals(element.getParent().getNamespacePrefix())///TODO where the hell and I'm going with this ! ! ) ) { writeNamespace(ns, sorted); --- 355,363 ---- namespaceStack.push(ns); writeNamespace(ns, sorted); ! } else if (ns.getURI() != null && ! ns.getURI().equals("") && ! element.getParent() != null && ! element.getParent().getNamespaceURI() != null ! && !element.getParent().getNamespaceURI().equals("") ) { writeNamespace(ns, sorted); *************** *** 454,459 **** // TODO This breaks example 3 from the Merlin Eight, but I'm not sure how to go about fixing it, due to DOM4J's // nondifferentiation between <test/> and <test xmlns=""/> ! // if (Utility.isEmpty(prefix) && Utility.isEmpty(namespace.getURI())) ! // return; writer.write(" xmlns"); if (prefix != null && prefix.length() > 0) { --- 451,456 ---- // TODO This breaks example 3 from the Merlin Eight, but I'm not sure how to go about fixing it, due to DOM4J's // nondifferentiation between <test/> and <test xmlns=""/> ! if (Utility.isEmpty(prefix) && Utility.isEmpty(namespace.getURI())) ! return; writer.write(" xmlns"); if (prefix != null && prefix.length() > 0) { |
|
From: <pe...@us...> - 2004-03-03 23:36:19
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19311/src/java/org/neuclear/xml/xmlsec Modified Files: Reference.java Log Message: Interops with enveloped signatures. Index: Reference.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/Reference.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Reference.java 2 Mar 2004 23:50:45 -0000 1.13 --- Reference.java 3 Mar 2004 23:23:24 -0000 1.14 *************** *** 1,4 **** --- 1,7 ---- /* $Id$ * $Log$ + * Revision 1.14 2004/03/03 23:23:24 pelle + * Interops with enveloped signatures. + * * Revision 1.13 2004/03/02 23:50:45 pelle * minor changes. *************** *** 247,253 **** private static byte[] createDigest(final Canonicalizer canon, Object root) throws XMLSecurityException { final byte[] value = canon.canonicalize(root); ! System.out.println("Canonicalized Reference:"); ! System.out.println(new String(value)); ! System.out.println("------"); return CryptoTools.digest(value); } --- 250,256 ---- private static byte[] createDigest(final Canonicalizer canon, Object root) throws XMLSecurityException { final byte[] value = canon.canonicalize(root); ! // System.out.println("Canonicalized Reference:"); ! // System.out.println(new String(value)); ! // System.out.println("------"); return CryptoTools.digest(value); } |
|
From: <pe...@us...> - 2004-03-03 00:02:53
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/c14 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5337/src/test/org/neuclear/xml/c14 Modified Files: CanonicalizationTest.java Log Message: minor changes. receiver didnt get checked in by idea in recent refactoring. Index: CanonicalizationTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/c14/CanonicalizationTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CanonicalizationTest.java 2 Mar 2004 23:30:44 -0000 1.5 --- CanonicalizationTest.java 2 Mar 2004 23:50:45 -0000 1.6 *************** *** 8,11 **** --- 8,15 ---- * $Id$ * $Log$ + * Revision 1.6 2004/03/02 23:50:45 pelle + * minor changes. + * receiver didnt get checked in by idea in recent refactoring. + * * Revision 1.5 2004/03/02 23:30:44 pelle * Renamed SignatureInfo to SignedInfo as that is the name of the Element. *************** *** 81,85 **** public final class CanonicalizationTest extends TestCase { ! private final static boolean ASSERT_FAIL = false; //Change this to assert failed documents public CanonicalizationTest(final String s) { --- 85,89 ---- public final class CanonicalizationTest extends TestCase { ! private final static boolean ASSERT_FAIL = true; //Change this to assert failed documents public CanonicalizationTest(final String s) { |
|
From: <pe...@us...> - 2004-03-03 00:02:53
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5337/src/java/org/neuclear/xml/xmlsec Modified Files: Reference.java Log Message: minor changes. receiver didnt get checked in by idea in recent refactoring. Index: Reference.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/Reference.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Reference.java 2 Mar 2004 23:30:43 -0000 1.12 --- Reference.java 2 Mar 2004 23:50:45 -0000 1.13 *************** *** 1,4 **** --- 1,8 ---- /* $Id$ * $Log$ + * Revision 1.13 2004/03/02 23:50:45 pelle + * minor changes. + * receiver didnt get checked in by idea in recent refactoring. + * * Revision 1.12 2004/03/02 23:30:43 pelle * Renamed SignatureInfo to SignedInfo as that is the name of the Element. *************** *** 243,249 **** private static byte[] createDigest(final Canonicalizer canon, Object root) throws XMLSecurityException { final byte[] value = canon.canonicalize(root); ! // System.out.println("Canonicalized Reference:"); ! // System.out.println(new String(value)); ! // System.out.println("------"); return CryptoTools.digest(value); } --- 247,253 ---- private static byte[] createDigest(final Canonicalizer canon, Object root) throws XMLSecurityException { final byte[] value = canon.canonicalize(root); ! System.out.println("Canonicalized Reference:"); ! System.out.println(new String(value)); ! System.out.println("------"); return CryptoTools.digest(value); } |
|
From: <pe...@us...> - 2004-03-03 00:02:52
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5337/src/java/org/neuclear/xml/c14 Modified Files: Canonicalizer.java Log Message: minor changes. receiver didnt get checked in by idea in recent refactoring. Index: Canonicalizer.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14/Canonicalizer.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Canonicalizer.java 2 Mar 2004 23:30:43 -0000 1.10 --- Canonicalizer.java 2 Mar 2004 23:50:45 -0000 1.11 *************** *** 8,11 **** --- 8,15 ---- * $Id$ * $Log$ + * Revision 1.11 2004/03/02 23:50:45 pelle + * minor changes. + * receiver didnt get checked in by idea in recent refactoring. + * * Revision 1.10 2004/03/02 23:30:43 pelle * Renamed SignatureInfo to SignedInfo as that is the name of the Element. *************** *** 135,139 **** import org.dom4j.*; import org.dom4j.tree.NamespaceStack; - import org.neuclear.commons.Utility; import org.neuclear.xml.ElementProxy; import org.neuclear.xml.XMLTools; --- 139,142 ---- *************** *** 348,356 **** namespaceStack.push(ns); writeNamespace(ns, sorted); ! } else if (ns.getURI() != null && ! ns.getURI().equals("") && ! element.getParent() != null && ! element.getParent().getNamespaceURI() != null ! && !element.getParent().getNamespaceURI().equals("") ) { writeNamespace(ns, sorted); --- 351,366 ---- namespaceStack.push(ns); writeNamespace(ns, sorted); ! // } else if (ns.getURI() != null && ! // ns.getURI().equals("") && ! // element.getParent() != null && ! // element.getParent().getNamespaceURI() != null ! // && !element.getParent().getNamespaceURI().equals("") ! } else if ( ! (element.getParent() == null) ! || ( ! !ns.getURI().equals(element.getParent().getNamespaceURI()) ! && ns.getPrefix().equals(element.getParent().getNamespacePrefix())///TODO where the hell and I'm going with this ! ! ) ) { writeNamespace(ns, sorted); *************** *** 444,449 **** // TODO This breaks example 3 from the Merlin Eight, but I'm not sure how to go about fixing it, due to DOM4J's // nondifferentiation between <test/> and <test xmlns=""/> ! if (Utility.isEmpty(prefix) && Utility.isEmpty(namespace.getURI())) ! return; writer.write(" xmlns"); if (prefix != null && prefix.length() > 0) { --- 454,459 ---- // TODO This breaks example 3 from the Merlin Eight, but I'm not sure how to go about fixing it, due to DOM4J's // nondifferentiation between <test/> and <test xmlns=""/> ! // if (Utility.isEmpty(prefix) && Utility.isEmpty(namespace.getURI())) ! // return; writer.write(" xmlns"); if (prefix != null && prefix.length() > 0) { |
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32469/src/java/org/neuclear/xml/xmlsec Modified Files: Reference.java XMLSignature.java Added Files: SignedInfo.java Removed Files: SignatureInfo.java Log Message: Renamed SignatureInfo to SignedInfo as that is the name of the Element. Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik can't tell the difference between <test/> and <test xmlns=""/>. Changed XMLSignature it is now has less repeated code. --- NEW FILE: SignedInfo.java --- /* $Id: SignedInfo.java,v 1.1 2004/03/02 23:30:43 pelle Exp $ * $Log: SignedInfo.java,v $ * Revision 1.1 2004/03/02 23:30:43 pelle * Renamed SignatureInfo to SignedInfo as that is the name of the Element. * Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. * Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik * can't tell the difference between <test/> and <test xmlns=""/>. * Changed XMLSignature it is now has less repeated code. * * Revision 1.6 2004/01/14 06:42:38 pelle * Got rid of the verifyXXX() methods * * Revision 1.5 2004/01/13 23:37:59 pelle * Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes. * * Revision 1.4 2003/12/11 23:56:53 pelle * Trying to test the ReceiverServlet with cactus. Still no luck. Need to return a ElementProxy of some sort. * Cleaned up some missing fluff in the ElementProxy interface. getTagName(), getQName() and getNameSpace() have been killed. * * Revision 1.3 2003/11/21 04:44:31 pelle * EncryptedFileStore now works. It uses the PBECipher with DES3 afair. * Otherwise You will Finaliate. * Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final. * This should hopefully make everything more stable (and secure). * * Revision 1.2 2003/11/11 21:18:07 pelle * Further vital reshuffling. * org.neudist.crypto.* and org.neudist.utils.* have been moved to respective areas under org.neuclear.commons * org.neuclear.signers.* as well as org.neuclear.passphraseagents have been moved under org.neuclear.commons.crypto as well. * Did a bit of work on the Canonicalizer and changed a few other minor bits. * * Revision 1.1.1.1 2003/11/11 16:33:25 pelle * Moved over from neudist.org * Moved remaining common utilities into commons * * Revision 1.9 2003/11/08 20:27:02 pelle * Updated the Signer interface to return a key type to be used for XML SignedInfo. Thus we now support DSA sigs yet again. * * Revision 1.8 2003/02/24 12:57:37 pelle * Sorted out problem with signing enveloping signatures. * Canonicalizer needs a Document. If there isn't a Document the xpath wont work and returns false. * Thus always have a document for an element. * * Revision 1.7 2003/02/24 03:26:30 pelle * XMLSignature class has been tested as working for Enveloped Signatures. * It is still failing verification on home grown Enveloping Signatures. * It failes while checking reference validity. This means there is something strange about the Digest is initially * calculated for Enveloping signatures. * * Revision 1.6 2003/02/24 00:41:07 pelle * Cleaned up a lot of code for new fixed processing model. * It all still work as before, but will be easier to modify the Reference processing model which is the only * main thing todo besides X509 and HMAC-SHA1 support. * * Revision 1.5 2003/02/22 16:54:30 pelle * Major structural changes in the whole processing framework. * Verification now supports Enveloping and detached signatures. * The reference element is a lot more important at the moment and handles much of the logic. * Replaced homegrown Base64 with Blackdowns. * Still experiencing problems with decoding foreign signatures. I reall dont understand it. I'm going to have * to reread the specs a lot more and study other implementations sourcecode. * * Revision 1.4 2003/02/08 19:11:10 pelle * Cleaned stuff up a bit. * * Revision 1.3 2003/02/08 18:48:37 pelle * The Signature phase has been rewritten. * There now is a new Class called QuickEmbeddedSignature which is more in line with my original idea for this library. * It simply has a template of the xml and signs it in a standard way. * The original XMLSignature class is still used for verification and will in the future handle more thoroughly * all the various flavours of XMLSig. * XMLSecTools has got different flavours of canonicalize now. Including one where you can pass it a Canonicaliser to use. * Of the new Canonicalizer's are CanonicalizerWithComments, which I accidently left out of the last commit. * And CanonicalizerWithoutSignature which leaves out the Signature in the Canonicalization phase and is thus * a lot more efficient than the previous approach. * * Revision 1.2 2003/01/21 03:14:11 pelle * Mainly clean ups through out and further documentation. * * Revision 1.1 2003/01/18 18:12:32 pelle * First Independent commit of the Independent XML-Signature API for NeuDist. * * Revision 1.3 2002/10/10 21:29:31 pelle * Oops. XML-Signature's SignedInfo element I had coded as SignedInfo * As I thought Canonicalisation doesnt seem to be standard. * Updated the SignedServlet to default to using ~/.neuclear/signers.ks * * Revision 1.2 2002/09/21 23:11:16 pelle * A bunch of clean ups. Got rid of as many hard coded URL's as I could. * */ package org.neuclear.xml.xmlsec; /** * @author pelleb * @version $Revision: 1.1 $ */ import org.dom4j.Element; import org.neuclear.commons.crypto.signers.Signer; import org.neuclear.xml.XMLException; import org.neuclear.xml.c14.Canonicalizer; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.Signature; public final class SignedInfo extends AbstractXMLSigElement { public SignedInfo(final Element root, final int sigalg, final int sigtype) throws XMLSecurityException { super(SignedInfo.TAG_NAME); this.algType = sigalg; final Element cm = XMLSecTools.createElementInSignatureSpace("CanonicalizationMethod"); cm.addAttribute("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"); try { addElement(cm); final Element sm = XMLSecTools.createElementInSignatureSpace("SignatureMethod"); if (sigalg == SignedInfo.SIG_ALG_RSA) sm.addAttribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#rsa-sha1"); else sm.addAttribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#dsa-sha1"); addElement(sm); ref = new Reference(root, sigtype); addElement(ref); } catch (XMLException e) { throw new XMLSecurityException(e); } } public SignedInfo(final Element elem) throws XMLSecurityException, InvalidSignatureException { super(elem); if (!elem.getQName().equals(XMLSecTools.createQName(TAG_NAME))) throw new XMLSecurityException("Element: " + elem.getQualifiedName() + " is not a valid: " + XMLSecTools.NS_DS.getPrefix() + ":" + TAG_NAME); this.sig = sig; final Element c14elem = elem.element(XMLSecTools.createQName("CanonicalizationMethod")); if (c14elem != null && c14elem.attributeValue("Algorithm").equals("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments")) c14nType = Canonicalizer.C14NTYPE_WITH_COMMENTS; final Element refElem = elem.element(XMLSecTools.createQName("Reference")); if (refElem != null) ref = new Reference(refElem); //Check reference element if signature is enveloped } /** * Method getSigningKey * This returns the signing PublicKey if it exists or null if it doesnt. * * @return * @throws XMLSecurityException */ public final Reference getReference() throws XMLSecurityException { return ref; } final Canonicalizer getCanonicalizer() { // if (ref.getSigType() == Reference.XMLSIGTYPE_ENVELOPED) // return new CanonicalizerWithoutSignature(); // else if (c14nType == Canonicalizer.C14NTYPE_WITH_COMMENTS) // return new CanonicalizerWithComments(); return new Canonicalizer(); } final XMLSignature getSig() { return sig; } //TODO Ignore this bit for now final Signature getSignatureAlgorithm() throws XMLSecurityException { try { return Signature.getInstance("SHA1withRSA", "BC"); } catch (NoSuchAlgorithmException e) { XMLSecTools.rethrowException(e); } catch (NoSuchProviderException e) { XMLSecTools.rethrowException(e); } return null; } public final byte[] canonicalize() throws XMLSecurityException { return XMLSecTools.canonicalize(getCanonicalizer(), getElement()); } public final String getTagName() { return TAG_NAME; } private static final String TAG_NAME = "SignedInfo"; private Reference ref; private int c14nType = 0; private int algType = 0; private XMLSignature sig; public final static int SIG_ALG_RSA = Signer.KEY_RSA; public final static int SIG_ALG_DSA = Signer.KEY_DSA; // private PublicKey pub; } Index: Reference.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/Reference.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Reference.java 2 Mar 2004 18:39:57 -0000 1.11 --- Reference.java 2 Mar 2004 23:30:43 -0000 1.12 *************** *** 1,4 **** --- 1,11 ---- /* $Id$ * $Log$ + * Revision 1.12 2004/03/02 23:30:43 pelle + * Renamed SignatureInfo to SignedInfo as that is the name of the Element. + * Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. + * Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik + * can't tell the difference between <test/> and <test xmlns=""/>. + * Changed XMLSignature it is now has less repeated code. + * * Revision 1.11 2004/03/02 18:39:57 pelle * Done some more minor fixes within xmlsig, but mainly I've removed the old Source and Store patterns and sub packages. This is because *************** *** 124,128 **** * * Revision 1.4 2002/10/10 21:29:31 pelle ! * Oops. XML-Signature's SignedInfo element I had coded as SignatureInfo * As I thought Canonicalisation doesnt seem to be standard. * Updated the SignedServlet to default to using ~/.neuclear/signers.ks --- 131,135 ---- * * Revision 1.4 2002/10/10 21:29:31 pelle ! * Oops. XML-Signature's SignedInfo element I had coded as SignedInfo * As I thought Canonicalisation doesnt seem to be standard. * Updated the SignedServlet to default to using ~/.neuclear/signers.ks *************** *** 169,194 **** super(Reference.TAG_NAME); final Canonicalizer canon; ! Object ref=null; Element transformsElement = addElement("Transforms"); // final Element object; ! if (sigtype == XMLSIGTYPE_ENVELOPED){ ! createAttribute("URI",""); ! canon=new CanonicalizerWithoutSignature(); ! transformsElement.addElement(XMLSecTools.createQName("Transform")).addAttribute("Algorithm","http://www.w3.org/2000/09/xmldsig#enveloped-signature"); ! ref=root; ! } else if (sigtype == XMLSIGTYPE_ENVELOPING){ ! canon= new Canonicalizer(); ! ref=root; } else { throw new XMLSecurityException("Unsupported Signature Method"); } ! transformsElement.addElement(XMLSecTools.createQName("Transform")).addAttribute("Algorithm","http://www.w3.org/TR/2001/REC-xml-c14n-20010315"); ! type=sigtype; ! final String id = Utility.denullString(root.attributeValue("Id"),root.attributeValue("ID")); if (!Utility.isEmpty(id)) ! createAttribute("URI","#"+id); ! addDigest(canon,ref); } --- 176,201 ---- super(Reference.TAG_NAME); final Canonicalizer canon; ! Object ref = null; Element transformsElement = addElement("Transforms"); // final Element object; ! if (sigtype == XMLSIGTYPE_ENVELOPED) { ! createAttribute("URI", ""); ! canon = new CanonicalizerWithoutSignature(); ! transformsElement.addElement(XMLSecTools.createQName("Transform")).addAttribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#enveloped-signature"); ! ref = root; ! } else if (sigtype == XMLSIGTYPE_ENVELOPING) { ! canon = new Canonicalizer(); ! ref = root; } else { throw new XMLSecurityException("Unsupported Signature Method"); } ! transformsElement.addElement(XMLSecTools.createQName("Transform")).addAttribute("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"); ! type = sigtype; ! final String id = Utility.denullString(root.attributeValue("Id"), root.attributeValue("ID")); if (!Utility.isEmpty(id)) ! createAttribute("URI", "#" + id); ! addDigest(canon, ref); } *************** *** 196,205 **** public Reference(final String uri) throws XMLSecurityException { super(Reference.TAG_NAME); ! type=XMLSIGTYPE_DETACHED; ! createAttribute("URI",uri); ! addDigest(new Canonicalizer(),loadReference(uri)); } /** * Build this from XML Reference Element * @param elem * @throws XMLSecurityException --- 203,214 ---- public Reference(final String uri) throws XMLSecurityException { super(Reference.TAG_NAME); ! type = XMLSIGTYPE_DETACHED; ! createAttribute("URI", uri); ! addDigest(new Canonicalizer(), loadReference(uri)); } + /** * Build this from XML Reference Element + * * @param elem * @throws XMLSecurityException *************** *** 209,258 **** if (!elem.getQName().getName().equals(TAG_NAME)) throw new XMLSecurityException("Element: " + elem.getQualifiedName() + " is not a valid: " + XMLSecTools.NS_DS.getPrefix() + ":" + TAG_NAME); ! type=findSignatureType(elem); ! byte digest[]=XMLSecTools.decodeBase64Element(getElement().element(XMLSecTools.createQName("DigestValue"))); ! final Object object=findRefElement(elem); ! if (object==null) ! throw new XMLSecurityException("Couldnt Dereference Object:\n "+elem.asXML()); final Canonicalizer canon; ! if (type==XMLSIGTYPE_ENVELOPED) ! canon=new CanonicalizerWithoutSignature(); else ! canon=new Canonicalizer(); final byte dig2[] = createDigest(canon, object); ! if (!CryptoTools.equalByteArrays(digest,dig2)) ! throw new InvalidSignatureException(digest,dig2); } private void addDigest(final Canonicalizer canon, Object root) throws XMLSecurityException { ! addElement("DigestMethod").addAttribute(XMLSecTools.createQName("Algorithm"),"http://www.w3.org/2000/09/xmldsig#sha1"); ! getElement().add(XMLSecTools.base64ToElement("DigestValue",createDigest(canon,root))); } private static byte[] createDigest(final Canonicalizer canon, Object root) throws XMLSecurityException { final byte[] value = canon.canonicalize(root); ! // System.out.println("Canonicalized:"); // System.out.println(new String(value)); // System.out.println("------"); ! return CryptoTools.digest(value); } private static int findSignatureType(Element elem) { ! final String id=elem.attributeValue("URI"); ! if (!Utility.isEmpty(id)&&id.length()>1){ ! if (id.startsWith("#")) ! return XMLSIGTYPE_ENVELOPING; ! return XMLSIGTYPE_DETACHED; ! } return XMLSIGTYPE_ENVELOPED; } private static Object findRefElement(Element elem) throws XMLSecurityException { ! final String id=elem.attributeValue("URI"); ! if (!Utility.isEmpty(id)&&id.length()>1){ ! if (id.startsWith("#")){ // System.out.println("Ref: "+id.substring(1)); ! return XMLTools.getByID(elem,id.substring(1));//.createCopy(); } // Non Local URI, we need to load it --- 218,268 ---- if (!elem.getQName().getName().equals(TAG_NAME)) throw new XMLSecurityException("Element: " + elem.getQualifiedName() + " is not a valid: " + XMLSecTools.NS_DS.getPrefix() + ":" + TAG_NAME); ! type = findSignatureType(elem); ! byte digest[] = XMLSecTools.decodeBase64Element(getElement().element(XMLSecTools.createQName("DigestValue"))); ! final Object object = findRefElement(elem); ! if (object == null) ! throw new XMLSecurityException("Couldnt Dereference Object:\n " + elem.asXML()); final Canonicalizer canon; ! if (type == XMLSIGTYPE_ENVELOPED) ! canon = new CanonicalizerWithoutSignature(); else ! canon = new Canonicalizer(); final byte dig2[] = createDigest(canon, object); ! if (!CryptoTools.equalByteArrays(digest, dig2)) ! throw new InvalidSignatureException(digest, dig2); } + private void addDigest(final Canonicalizer canon, Object root) throws XMLSecurityException { ! addElement("DigestMethod").addAttribute(XMLSecTools.createQName("Algorithm"), "http://www.w3.org/2000/09/xmldsig#sha1"); ! getElement().add(XMLSecTools.base64ToElement("DigestValue", createDigest(canon, root))); } private static byte[] createDigest(final Canonicalizer canon, Object root) throws XMLSecurityException { final byte[] value = canon.canonicalize(root); ! // System.out.println("Canonicalized Reference:"); // System.out.println(new String(value)); // System.out.println("------"); ! return CryptoTools.digest(value); } private static int findSignatureType(Element elem) { ! final String id = elem.attributeValue("URI"); ! if (!Utility.isEmpty(id) && id.length() > 1) { ! if (id.startsWith("#")) ! return XMLSIGTYPE_ENVELOPING; ! return XMLSIGTYPE_DETACHED; ! } return XMLSIGTYPE_ENVELOPED; } private static Object findRefElement(Element elem) throws XMLSecurityException { ! final String id = elem.attributeValue("URI"); ! if (!Utility.isEmpty(id) && id.length() > 1) { ! if (id.startsWith("#")) { // System.out.println("Ref: "+id.substring(1)); ! return XMLTools.getByID(elem, id.substring(1));//.createCopy(); } // Non Local URI, we need to load it *************** *** 268,281 **** throw new XMLSecurityException("XMLSignature is not linked to Document"); try { ! URL url= new URL(refuri); ! String ref=url.getRef(); ! if (ref!=null) // If we have a reference part it is XML ! return XMLTools.loadDocument(url).getRootElement().elementByID(ref); ! BufferedInputStream is=new BufferedInputStream(url.openStream()); ! ByteArrayOutputStream os=new ByteArrayOutputStream(is.available()); ! byte input[]=new byte[is.available()]; ! int count=0; ! while((count=is.read(input))>=0){ ! os.write(input,0,count); } is.close(); --- 278,291 ---- throw new XMLSecurityException("XMLSignature is not linked to Document"); try { ! URL url = new URL(refuri); ! String ref = url.getRef(); ! if (ref != null) // If we have a reference part it is XML ! return XMLTools.loadDocument(url).getRootElement().elementByID(ref); ! BufferedInputStream is = new BufferedInputStream(url.openStream()); ! ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); ! byte input[] = new byte[is.available()]; ! int count = 0; ! while ((count = is.read(input)) >= 0) { ! os.write(input, 0, count); } is.close(); *************** *** 291,296 **** ! ! public String getUri(){ return getElement().attributeValue("URI"); } --- 301,305 ---- ! public String getUri() { return getElement().attributeValue("URI"); } Index: XMLSignature.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/XMLSignature.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** XMLSignature.java 2 Mar 2004 18:39:57 -0000 1.13 --- XMLSignature.java 2 Mar 2004 23:30:43 -0000 1.14 *************** *** 1,4 **** --- 1,11 ---- /* $Id$ * $Log$ + * Revision 1.14 2004/03/02 23:30:43 pelle + * Renamed SignatureInfo to SignedInfo as that is the name of the Element. + * Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. + * Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik + * can't tell the difference between <test/> and <test xmlns=""/>. + * Changed XMLSignature it is now has less repeated code. + * * Revision 1.13 2004/03/02 18:39:57 pelle * Done some more minor fixes within xmlsig, but mainly I've removed the old Source and Store patterns and sub packages. This is because *************** *** 169,173 **** * * Revision 1.4 2002/10/10 21:29:31 pelle ! * Oops. XML-Signature's SignedInfo element I had coded as SignatureInfo * As I thought Canonicalisation doesnt seem to be standard. * Updated the SignedServlet to default to using ~/.neuclear/signers.ks --- 176,180 ---- * * Revision 1.4 2002/10/10 21:29:31 pelle ! * Oops. XML-Signature's SignedInfo element I had coded as SignedInfo * As I thought Canonicalisation doesnt seem to be standard. * Updated the SignedServlet to default to using ~/.neuclear/signers.ks *************** *** 186,189 **** --- 193,197 ---- import org.dom4j.DocumentHelper; import org.dom4j.Element; + import org.neuclear.commons.crypto.Base64; import org.neuclear.commons.crypto.CryptoException; import org.neuclear.commons.crypto.CryptoTools; *************** *** 197,201 **** import java.security.PrivateKey; import java.security.PublicKey; - import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; --- 205,208 ---- *************** *** 207,213 **** /** * Creates an Enveloped (Embedded) Signature object based on the given element root ! * ! * @param keypair ! * @param root * @throws XMLSecurityException */ --- 214,220 ---- /** * Creates an Enveloped (Embedded) Signature object based on the given element root ! * ! * @param keypair ! * @param root * @throws XMLSecurityException */ *************** *** 233,246 **** } ! //TODO Something does not work right with Enveloping signatures. I am trying to figure out what it is. However enveloped are all ! // that we need for NeuClear, so I may put this on the backburner. ! public XMLSignature(final PrivateKey key, final PublicKey pub, Element root, final int type) throws XMLSecurityException, CryptoException { super(XMLSignature.TAG_NAME); try { ! if (type == Reference.XMLSIGTYPE_ENVELOPED) { root.add(getElement()); ! } else if (type == Reference.XMLSIGTYPE_ENVELOPING) { final Element objElem = XMLSecTools.createElementInSignatureSpace("Object"); ! objElem.addAttribute("Id","data"); DocumentHelper.createDocument(getElement());//As Signature Element is parent we will now add a doc objElem.add(root); --- 240,259 ---- } ! /** ! * Internal constructor used for common stuff regardless of key type ! * ! * @param pub ! * @param root ! * @param type ! * @throws XMLSecurityException ! */ ! private XMLSignature(final PublicKey pub, Element root, final int type) throws XMLSecurityException { super(XMLSignature.TAG_NAME); try { ! if (type == Reference.XMLSIGTYPE_ENVELOPED) { root.add(getElement()); ! } else if (type == Reference.XMLSIGTYPE_ENVELOPING) { final Element objElem = XMLSecTools.createElementInSignatureSpace("Object"); ! objElem.addAttribute("Id", "data"); DocumentHelper.createDocument(getElement());//As Signature Element is parent we will now add a doc objElem.add(root); *************** *** 248,261 **** getElement().add(root); } ! final int alg = (key instanceof RSAPrivateKey) ? SignatureInfo.SIG_ALG_RSA : SignatureInfo.SIG_ALG_DSA; ! si = new SignatureInfo( root, alg, type); addElement(si); ! final byte[] cansi = si.canonicalize(); ! // System.out.println("Canonicalized:"); ! // System.out.println(new String(cansi)); ! // System.out.println("------"); ! addElement(XMLSecTools.base64ToElement("SignatureValue", CryptoTools.sign(key, cansi))); if (pub != null) addElement(new KeyInfo(pub)); // If Enveloping add Object element last if (type == Reference.XMLSIGTYPE_ENVELOPING) { --- 261,271 ---- getElement().add(root); } ! final int alg = (pub instanceof RSAPublicKey) ? SignedInfo.SIG_ALG_RSA : SignedInfo.SIG_ALG_DSA; ! si = new SignedInfo(root, alg, type); addElement(si); ! sigval = addElement("SignatureValue"); if (pub != null) addElement(new KeyInfo(pub)); + // If Enveloping add Object element last if (type == Reference.XMLSIGTYPE_ENVELOPING) { *************** *** 267,304 **** } } ! public XMLSignature(final String name, final Signer signer, Element root,final int type) throws XMLSecurityException, NonExistingSignerException, UserCancellationException { ! super(XMLSignature.TAG_NAME); ! if (! (signer instanceof PublicKeySource)) ! throw new XMLSecurityException("We Require a PublicKeySource"); ! PublicKeySource src=(PublicKeySource)signer; ! try { ! if (type == Reference.XMLSIGTYPE_ENVELOPED) { ! root.add(getElement()); ! } else if (type == Reference.XMLSIGTYPE_ENVELOPING) { ! final Element objElem = XMLSecTools.createElementInSignatureSpace("Object"); ! objElem.addAttribute("Id","data"); ! DocumentHelper.createDocument(getElement());//As Signature Element is parent we will now add a doc ! objElem.add(root); ! root = objElem; ! getElement().add(root); ! } ! final PublicKey pub = src.getPublicKey(name); ! final int alg = (pub instanceof RSAPublicKey) ? SignatureInfo.SIG_ALG_RSA : SignatureInfo.SIG_ALG_DSA; ! si = new SignatureInfo( root, alg, type); ! addElement(si); ! final byte[] cansi = si.canonicalize(); // System.out.println("Canonicalized:"); // System.out.println(new String(cansi)); // System.out.println("------"); ! addElement(XMLSecTools.base64ToElement("SignatureValue", signer.sign(name, cansi))); ! final KeyInfo key = new KeyInfo(pub); ! addElement(key); ! if (type == Reference.XMLSIGTYPE_ENVELOPING) { ! getElement().remove(root); ! getElement().add(root); ! } ! } catch (XMLException e) { ! throw new XMLSecurityException(e); ! } } --- 277,303 ---- } } ! ! public XMLSignature(final PrivateKey key, final PublicKey pub, Element root, final int type) throws XMLSecurityException, CryptoException { ! this(pub, root, type); ! final byte[] cansi = si.canonicalize(); // System.out.println("Canonicalized:"); // System.out.println(new String(cansi)); // System.out.println("------"); ! sigval.setText(Base64.encode(CryptoTools.sign(key, cansi))); ! } ! ! public XMLSignature(final String name, final Signer signer, Element root, final int type) throws XMLSecurityException, UserCancellationException, NonExistingSignerException { ! this(getPublicKey(signer, name), root, type); ! final byte[] cansi = si.canonicalize(); ! // System.out.println("Canonicalized SI:"); ! // System.out.println(new String(cansi)); ! // System.out.println("------"); ! sigval.setText(Base64.encode(signer.sign(name, cansi))); ! } ! ! private static PublicKey getPublicKey(final Signer signer, final String name) throws XMLSecurityException, NonExistingSignerException { ! if (!(signer instanceof PublicKeySource)) ! throw new XMLSecurityException("The Signer must also be a public key source"); ! return ((PublicKeySource) signer).getPublicKey(name); } *************** *** 308,313 **** if (!elem.getQName().equals(XMLSecTools.createQName(TAG_NAME)) || siElem == null) // Not sure if equals is imeplemented properly for QNames throw new XMLSecurityException("Element: " + elem.getQualifiedName() + " is not a valid: " + XMLSecTools.NS_DS.getPrefix() + ":" + TAG_NAME); ! si = new SignatureInfo(siElem); ! KeyInfo key=getKeyInfo(); if (key == null) throw new XMLSecurityException("No included PublicKey, can not verify."); --- 307,312 ---- if (!elem.getQName().equals(XMLSecTools.createQName(TAG_NAME)) || siElem == null) // Not sure if equals is imeplemented properly for QNames throw new XMLSecurityException("Element: " + elem.getQualifiedName() + " is not a valid: " + XMLSecTools.NS_DS.getPrefix() + ":" + TAG_NAME); ! si = new SignedInfo(siElem); ! KeyInfo key = getKeyInfo(); if (key == null) throw new XMLSecurityException("No included PublicKey, can not verify."); *************** *** 327,336 **** } ! public XMLSignature(final Element elem,PublicKey pub) throws XMLSecurityException, InvalidSignatureException { super(elem); final Element siElem = elem.element(XMLSecTools.createQName("SignedInfo")); if (!elem.getQName().equals(XMLSecTools.createQName(TAG_NAME)) || siElem == null) // Not sure if equals is imeplemented properly for QNames throw new XMLSecurityException("Element: " + elem.getQualifiedName() + " is not a valid: " + XMLSecTools.NS_DS.getPrefix() + ":" + TAG_NAME); ! si = new SignatureInfo(siElem); final byte[] sig = getSignature(); final byte[] cansi = si.canonicalize(); --- 326,335 ---- } ! public XMLSignature(final Element elem, PublicKey pub) throws XMLSecurityException, InvalidSignatureException { super(elem); final Element siElem = elem.element(XMLSecTools.createQName("SignedInfo")); if (!elem.getQName().equals(XMLSecTools.createQName(TAG_NAME)) || siElem == null) // Not sure if equals is imeplemented properly for QNames throw new XMLSecurityException("Element: " + elem.getQualifiedName() + " is not a valid: " + XMLSecTools.NS_DS.getPrefix() + ":" + TAG_NAME); ! si = new SignedInfo(siElem); final byte[] sig = getSignature(); final byte[] cansi = si.canonicalize(); *************** *** 355,383 **** public final PublicKey getSignersKey() throws XMLSecurityException { ! KeyInfo key=getKeyInfo(); if (key == null) return null; return key.getPublicKey(); } public final String getSignersId() throws XMLSecurityException { ! KeyInfo key=getKeyInfo(); if (key == null) return null; return key.getKeyName(); } ! private final synchronized KeyInfo getKeyInfo() throws XMLSecurityException{ ! if (ki==null){ final Element keyInfoElem = getElement().element(XMLSecTools.createQName("KeyInfo")); if (keyInfoElem != null) ! ki=new KeyInfo(keyInfoElem); } return ki; } ! protected final SignatureInfo getSi() { return si; } ! private SignatureInfo si; private KeyInfo ki; private static final String TAG_NAME = "Signature"; --- 354,385 ---- public final PublicKey getSignersKey() throws XMLSecurityException { ! KeyInfo key = getKeyInfo(); if (key == null) return null; return key.getPublicKey(); } + public final String getSignersId() throws XMLSecurityException { ! KeyInfo key = getKeyInfo(); if (key == null) return null; return key.getKeyName(); } ! ! private final synchronized KeyInfo getKeyInfo() throws XMLSecurityException { ! if (ki == null) { final Element keyInfoElem = getElement().element(XMLSecTools.createQName("KeyInfo")); if (keyInfoElem != null) ! ki = new KeyInfo(keyInfoElem); } return ki; } ! protected final SignedInfo getSi() { return si; } ! private SignedInfo si; ! private Element sigval; private KeyInfo ki; private static final String TAG_NAME = "Signature"; --- SignatureInfo.java DELETED --- |
|
From: <pe...@us...> - 2004-03-02 23:42:51
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/xmlsec In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32469/src/test/org/neuclear/xml/xmlsec Modified Files: SimpleXMLSigTest.java Log Message: Renamed SignatureInfo to SignedInfo as that is the name of the Element. Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik can't tell the difference between <test/> and <test xmlns=""/>. Changed XMLSignature it is now has less repeated code. Index: SimpleXMLSigTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/xmlsec/SimpleXMLSigTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SimpleXMLSigTest.java 2 Mar 2004 18:39:57 -0000 1.9 --- SimpleXMLSigTest.java 2 Mar 2004 23:30:44 -0000 1.10 *************** *** 6,9 **** --- 6,12 ---- import org.dom4j.DocumentHelper; import org.neuclear.commons.crypto.CryptoException; + import org.neuclear.commons.crypto.passphraseagents.UserCancellationException; + import org.neuclear.commons.crypto.signers.Signer; + import org.neuclear.commons.crypto.signers.TestCaseSigner; import org.neuclear.commons.test.JunitTools; import org.neuclear.xml.XMLException; *************** *** 22,39 **** * $Id$ * $Log$ * Revision 1.9 2004/03/02 18:39:57 pelle * Done some more minor fixes within xmlsig, but mainly I've removed the old Source and Store patterns and sub packages. This is because * they really are no longer necessary with the new non naming naming system. ! * * Revision 1.8 2004/02/19 00:28:00 pelle * Discovered several incompatabilities with the xmlsig implementation. Have been working on getting it working. * Currently there is still a problem with enveloping signatures and it seems enveloped signatures done via signers. ! * * Revision 1.7 2004/01/14 06:42:38 pelle * Got rid of the verifyXXX() methods ! * * Revision 1.6 2004/01/13 23:37:59 pelle * Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes. ! * * Revision 1.5 2003/11/21 04:44:31 pelle * EncryptedFileStore now works. It uses the PBECipher with DES3 afair. --- 25,49 ---- * $Id$ * $Log$ + * Revision 1.10 2004/03/02 23:30:44 pelle + * Renamed SignatureInfo to SignedInfo as that is the name of the Element. + * Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. + * Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik + * can't tell the difference between <test/> and <test xmlns=""/>. + * Changed XMLSignature it is now has less repeated code. + * * Revision 1.9 2004/03/02 18:39:57 pelle * Done some more minor fixes within xmlsig, but mainly I've removed the old Source and Store patterns and sub packages. This is because * they really are no longer necessary with the new non naming naming system. ! * <p/> * Revision 1.8 2004/02/19 00:28:00 pelle * Discovered several incompatabilities with the xmlsig implementation. Have been working on getting it working. * Currently there is still a problem with enveloping signatures and it seems enveloped signatures done via signers. ! * <p/> * Revision 1.7 2004/01/14 06:42:38 pelle * Got rid of the verifyXXX() methods ! * <p/> * Revision 1.6 2004/01/13 23:37:59 pelle * Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes. ! * <p/> * Revision 1.5 2003/11/21 04:44:31 pelle * EncryptedFileStore now works. It uses the PBECipher with DES3 afair. *************** *** 41,45 **** * Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final. * This should hopefully make everything more stable (and secure). ! * * Revision 1.4 2003/11/20 23:41:58 pelle * Getting all the tests to work in id --- 51,55 ---- * Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final. * This should hopefully make everything more stable (and secure). ! * <p/> * Revision 1.4 2003/11/20 23:41:58 pelle * Getting all the tests to work in id *************** *** 47,51 **** * First version of EntityLedger that will use OFB's EntityEngine. This will allow us to support a vast amount databases without * writing SQL. (Yipee) ! * * Revision 1.3 2003/11/18 23:35:18 pelle * Payment Web Application is getting there. --- 57,61 ---- * First version of EntityLedger that will use OFB's EntityEngine. This will allow us to support a vast amount databases without * writing SQL. (Yipee) ! * <p/> * Revision 1.3 2003/11/18 23:35:18 pelle * Payment Web Application is getting there. *************** *** 117,128 **** public SimpleXMLSigTest(final String s) throws SecurityException, NoSuchAlgorithmException, CryptoException { super(s); ! signer = JunitTools.getTestRSAKey(); ! dsaSigner = JunitTools.getTestDSAKey(); new File("target/testdata/homegrown").mkdirs(); } ! public final void testRSASignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(signer, doc.getRootElement()); final File outputFile = new File("target/testdata/homegrown/signature-enveloped-rsa.xml"); XMLTools.writeFile(outputFile, doc); --- 127,139 ---- public SimpleXMLSigTest(final String s) throws SecurityException, NoSuchAlgorithmException, CryptoException { super(s); ! rsa = JunitTools.getTestRSAKey(); ! dsa = JunitTools.getTestDSAKey(); ! signer = new TestCaseSigner(); new File("target/testdata/homegrown").mkdirs(); } ! public final void testEnvelopedUsignRSAKeyPair() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(rsa, doc.getRootElement()); final File outputFile = new File("target/testdata/homegrown/signature-enveloped-rsa.xml"); XMLTools.writeFile(outputFile, doc); *************** *** 132,138 **** } ! public final void testRSAEnvelopingSignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(signer, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); final File outputFile = new File("target/testdata/homegrown/signature-enveloping-rsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); --- 143,149 ---- } ! public final void testEnvelopingUsignRSAKeyPair() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(rsa, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); final File outputFile = new File("target/testdata/homegrown/signature-enveloping-rsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); *************** *** 142,148 **** } ! public final void testDSAEnvelopingSignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(dsaSigner, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); final File outputFile = new File("target/testdata/homegrown/signature-enveloping-dsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); --- 153,159 ---- } ! public final void testEnvelopingUsignDSAKeyPair() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(dsa, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); final File outputFile = new File("target/testdata/homegrown/signature-enveloping-dsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); *************** *** 152,160 **** } ! public final void testDSASignXML() throws DocumentException, XMLException, CryptoException { ! assertTrue("Test if public key is really DSA", dsaSigner.getPublic() instanceof DSAPublicKey); Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(dsaSigner, doc.getRootElement()); final File outputFile = new File("target/testdata/homegrown/signature-enveloped-dsa.xml"); --- 163,171 ---- } ! public final void testEnvelopedUsignDSAKeyPair() throws DocumentException, XMLException, CryptoException { ! assertTrue("Test if public key is really DSA", dsa.getPublic() instanceof DSAPublicKey); Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(dsa, doc.getRootElement()); final File outputFile = new File("target/testdata/homegrown/signature-enveloped-dsa.xml"); *************** *** 166,192 **** ! public final void testBadSignXML() throws DocumentException, XMLException, CryptoException { final Document doc = DocumentHelper.parseText(TESTXML); ! XMLSecTools.signElement( doc.getRootElement(), signer); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement(), signer.getPublic())); doc.getRootElement().addElement("BadElement"); ! assertTrue("Test that Signature is invalid", !XMLSecTools.verifySignature(doc.getRootElement(), signer.getPublic())); } ! public final void testBadDSASignXML() throws DocumentException, XMLException, CryptoException { final Document doc = DocumentHelper.parseText(TESTXML); ! XMLSecTools.signElement(doc.getRootElement(), dsaSigner); ! assertTrue("Test if DSA Signature is valid", XMLSecTools.verifySignature(doc.getRootElement(), dsaSigner.getPublic())); doc.getRootElement().addElement("BadElement"); ! assertTrue("Test that DSA Signature is invalid", !XMLSecTools.verifySignature(doc.getRootElement(), signer.getPublic())); } ! final KeyPair signer; ! final KeyPair dsaSigner; final static String TESTXML = "<test><test2></test2></test>"; } --- 177,245 ---- ! public final void testBadRSASignature() throws DocumentException, XMLException, CryptoException { final Document doc = DocumentHelper.parseText(TESTXML); ! XMLSecTools.signElement(doc.getRootElement(), rsa); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement(), rsa.getPublic())); doc.getRootElement().addElement("BadElement"); ! assertTrue("Test that Signature is invalid", !XMLSecTools.verifySignature(doc.getRootElement(), rsa.getPublic())); } ! public final void testBadDSASignature() throws DocumentException, XMLException, CryptoException { final Document doc = DocumentHelper.parseText(TESTXML); ! XMLSecTools.signElement(doc.getRootElement(), dsa); ! assertTrue("Test if DSA Signature is valid", XMLSecTools.verifySignature(doc.getRootElement(), dsa.getPublic())); doc.getRootElement().addElement("BadElement"); ! assertTrue("Test that DSA Signature is invalid", !XMLSecTools.verifySignature(doc.getRootElement(), rsa.getPublic())); } ! public final void testEnvelopedUsingSigner() throws DocumentException, XMLException, CryptoException, UserCancellationException { ! Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature("neu://test", signer, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPED); ! final File outputFile = new File("target/testdata/homegrown/signature-enveloped-signer.xml"); ! XMLTools.writeFile(outputFile, doc); ! ! doc = XMLTools.loadDocument(outputFile); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement())); ! } ! ! public final void testEnvelopingUsingSigner() throws DocumentException, XMLException, CryptoException, UserCancellationException { ! Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature("neu://test", signer, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); ! final File outputFile = new File("target/testdata/homegrown/signature-enveloping-signer.xml"); ! XMLTools.writeFile(outputFile, sig.getElement()); ! ! doc = XMLTools.loadDocument(outputFile); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement())); ! } ! ! public final void testComplexEnvelopedUsingSigner() throws DocumentException, XMLException, CryptoException, UserCancellationException { ! Document doc = DocumentHelper.parseText(COMPLEX_XML); ! final XMLSignature sig = new XMLSignature("neu://test", signer, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPED); ! final File outputFile = new File("target/testdata/homegrown/signature-complex-enveloped-signer.xml"); ! XMLTools.writeFile(outputFile, doc); ! ! doc = XMLTools.loadDocument(outputFile); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement())); ! } ! ! public final void testComplexEnvelopingUsingSigner() throws DocumentException, XMLException, CryptoException, UserCancellationException { ! Document doc = DocumentHelper.parseText(COMPLEX_XML); ! final XMLSignature sig = new XMLSignature("neu://test", signer, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); ! final File outputFile = new File("target/testdata/homegrown/signature-complex-enveloping-signer.xml"); ! XMLTools.writeFile(outputFile, sig.getElement()); ! ! doc = XMLTools.loadDocument(outputFile); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement())); ! } ! ! private final KeyPair rsa; ! private final KeyPair dsa; ! private final Signer signer; final static String TESTXML = "<test><test2></test2></test>"; + final static String COMPLEX_XML = "<test xmlns=\"http://talk.org\"><test2></test2></test>"; } |
|
From: <pe...@us...> - 2004-03-02 23:42:51
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/c14 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32469/src/test/org/neuclear/xml/c14 Modified Files: CanonicalizationTest.java Added Files: SimpleCanonicalizationTest.java Log Message: Renamed SignatureInfo to SignedInfo as that is the name of the Element. Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik can't tell the difference between <test/> and <test xmlns=""/>. Changed XMLSignature it is now has less repeated code. --- NEW FILE: SimpleCanonicalizationTest.java --- package org.neuclear.xml.c14; import junit.framework.TestCase; /* 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: SimpleCanonicalizationTest.java,v 1.1 2004/03/02 23:30:44 pelle Exp $ $Log: SimpleCanonicalizationTest.java,v $ Revision 1.1 2004/03/02 23:30:44 pelle Renamed SignatureInfo to SignedInfo as that is the name of the Element. Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik can't tell the difference between <test/> and <test xmlns=""/>. Changed XMLSignature it is now has less repeated code. */ /** * User: pelleb * Date: Mar 2, 2004 * Time: 9:08:25 PM */ public class SimpleCanonicalizationTest extends TestCase { public void testCanonical() { } private static final String orig = ""; } Index: CanonicalizationTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/c14/CanonicalizationTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CanonicalizationTest.java 14 Jan 2004 06:42:38 -0000 1.4 --- CanonicalizationTest.java 2 Mar 2004 23:30:44 -0000 1.5 *************** *** 1,3 **** --- 1,4 ---- package org.neuclear.xml.c14; + /** * (C) 2003 Antilles Software Ventures SA *************** *** 7,10 **** --- 8,18 ---- * $Id$ * $Log$ + * Revision 1.5 2004/03/02 23:30:44 pelle + * Renamed SignatureInfo to SignedInfo as that is the name of the Element. + * Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. + * Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik + * can't tell the difference between <test/> and <test xmlns=""/>. + * Changed XMLSignature it is now has less repeated code. + * * Revision 1.4 2004/01/14 06:42:38 pelle * Got rid of the verifyXXX() methods *************** *** 70,79 **** import java.io.*; - import java.net.URL; public final class CanonicalizationTest extends TestCase { public CanonicalizationTest(final String s) { super(s); ! reader=new SAXReader(false); reader.setMergeAdjacentText(false); reader.setStripWhitespaceText(false); --- 78,89 ---- import java.io.*; public final class CanonicalizationTest extends TestCase { + + private final static boolean ASSERT_FAIL = false; //Change this to assert failed documents + public CanonicalizationTest(final String s) { super(s); ! reader = new SAXReader(false); reader.setMergeAdjacentText(false); reader.setStripWhitespaceText(false); *************** *** 94,98 **** public final void runDirectoryTest(final String path) throws DocumentException, IOException, FileNotFoundException, XMLSecurityException { ! final File dir=new File(path).getAbsoluteFile(); if (!dir.exists()) { System.out.println("Doesnt exist"); --- 104,108 ---- public final void runDirectoryTest(final String path) throws DocumentException, IOException, FileNotFoundException, XMLSecurityException { ! final File dir = new File(path).getAbsoluteFile(); if (!dir.exists()) { System.out.println("Doesnt exist"); *************** *** 101,106 **** //FilenameFilter filter=FilenameFilter; ! final File[] xmlfiles=dir.listFiles(new FilenameFilter(){ ! public boolean accept(final File dirf, final String name) { return name.endsWith(".xml"); } --- 111,116 ---- //FilenameFilter filter=FilenameFilter; ! final File[] xmlfiles = dir.listFiles(new FilenameFilter() { ! public boolean accept(final File dirf, final String name) { return name.endsWith(".xml"); } *************** *** 111,135 **** final File xmlfile = xmlfiles[i]; ! System.out.println("Testing file: "+xmlfile.getName()); ! final File c14file=getC14Name(xmlfile); ! if (c14file.exists()&&!hasXPath(xmlfile)){ //Just disabling the XPath Subset functionality until I hear from the Dom4J guys try { ! if (xmlfile.getName().equals("example-6.xml")) ! System.out.println("Here we go"); ! final Document doc=reader.read(xmlfile.toURL()); ! byte[] ourbytes=null; if (hasXPath(xmlfile)) { ! final File xpathFile=getXPathFileName(xmlfile); ! final FileReader xpreader=new FileReader(xpathFile); ! final char[] xpathc=new char[(int)xpathFile.length()]; ! xpreader.read(xpathc,0,xpathc.length); xpreader.close(); ! final String xpath=new String(xpathc); ! System.out.println("XPATH="+xpath); ! ourbytes=XMLSecTools.canonicalizeSubset(doc,xpath); } else ! ourbytes=XMLSecTools.canonicalize(doc); ! final FileOutputStream fos=new FileOutputStream(getC14OutputName(xmlfile)); fos.write(ourbytes); fos.close(); --- 121,143 ---- final File xmlfile = xmlfiles[i]; ! System.out.println("Testing file: " + xmlfile.getName()); ! final File c14file = getC14Name(xmlfile); ! if (c14file.exists() && !hasXPath(xmlfile)) { //Just disabling the XPath Subset functionality until I hear from the Dom4J guys try { ! final Document doc = reader.read(xmlfile.toURL()); ! byte[] ourbytes = null; if (hasXPath(xmlfile)) { ! final File xpathFile = getXPathFileName(xmlfile); ! final FileReader xpreader = new FileReader(xpathFile); ! final char[] xpathc = new char[(int) xpathFile.length()]; ! xpreader.read(xpathc, 0, xpathc.length); xpreader.close(); ! final String xpath = new String(xpathc); ! System.out.println("XPATH=" + xpath); ! ourbytes = XMLSecTools.canonicalizeSubset(doc, xpath); } else ! ourbytes = XMLSecTools.canonicalize(doc); ! final FileOutputStream fos = new FileOutputStream(getC14OutputName(xmlfile)); fos.write(ourbytes); fos.close(); *************** *** 142,146 **** } ! } else System.err.println("Missing C14 Version: "+c14file.getName()); } --- 150,155 ---- } ! } else ! System.err.println("Missing C14 Version: " + c14file.getName()); } *************** *** 149,190 **** private void compareFileWithByteArray(final File c14file, final byte[] ourbytes) throws IOException { ! final byte[] theirbytes=new byte[(int)c14file.length()]; ! final FileInputStream fis=new FileInputStream(c14file); fis.read(theirbytes); ! boolean equal=ourbytes.length==theirbytes.length; if (!equal) { ! System.out.println("Ourbytes= "+ourbytes.length+" theirbytes="+theirbytes.length); } ! assertTrue(equal); ! int j=0; ! for ( j=0;equal&&j<ourbytes.length;j++){ // System.out.print(ourbytes[j]); ! equal=ourbytes[j]==theirbytes[j]; ! if (!equal){ ! System.out.println("Problem was at character: "+j+" ourbytes["+j+"]='"+ourbytes[j]+"' theirbytes["+j+"]='"+theirbytes[j]+"'"); System.out.println(new String(ourbytes)); System.out.println(new String(theirbytes)); ! // System.out.println("====ORIGINALFILE===="); ! // System.out.println(doc.asXML()); } } ! assertTrue(equal); } ! private File getC14Name(final File file){ ! final String newname=file.getName(); ! return new File(file.getParentFile(),newname.substring(0,newname.length()-3)+"c14n"); } ! private File getC14OutputName(final File file){ ! final String newname=file.getName(); ! return new File(file.getParentFile(),newname.substring(0,newname.length()-3)+"out"); } ! private File getXPathFileName(final File file){ ! final String newname=file.getName(); ! return new File(file.getParentFile(),newname.substring(0,newname.length()-3)+"xpath"); } private boolean hasXPath(final File file) { return getXPathFileName(file).exists(); --- 158,204 ---- private void compareFileWithByteArray(final File c14file, final byte[] ourbytes) throws IOException { ! final byte[] theirbytes = new byte[(int) c14file.length()]; ! final FileInputStream fis = new FileInputStream(c14file); fis.read(theirbytes); ! boolean equal = ourbytes.length == theirbytes.length; if (!equal) { ! System.out.println("Ourbytes= " + ourbytes.length + " theirbytes=" + theirbytes.length); } ! if (ASSERT_FAIL) ! assertTrue(equal); ! int j = 0; ! for (j = 0; equal && j < ourbytes.length; j++) { // System.out.print(ourbytes[j]); ! equal = ourbytes[j] == theirbytes[j]; ! if (!equal) { ! System.out.println("Problem was at character: " + j + " ourbytes[" + j + "]='" + ourbytes[j] + "' theirbytes[" + j + "]='" + theirbytes[j] + "'"); System.out.println(new String(ourbytes)); System.out.println(new String(theirbytes)); ! // System.out.println("====ORIGINALFILE===="); ! // System.out.println(doc.asXML()); } } ! if (ASSERT_FAIL) ! assertTrue(equal); } ! private File getC14Name(final File file) { ! final String newname = file.getName(); ! return new File(file.getParentFile(), newname.substring(0, newname.length() - 3) + "c14n"); } ! ! private File getC14OutputName(final File file) { ! final String newname = file.getName(); ! return new File(file.getParentFile(), newname.substring(0, newname.length() - 3) + "out"); } ! ! private File getXPathFileName(final File file) { ! final String newname = file.getName(); ! return new File(file.getParentFile(), newname.substring(0, newname.length() - 3) + "xpath"); } + private boolean hasXPath(final File file) { return getXPathFileName(file).exists(); |
|
From: <pe...@us...> - 2004-03-02 23:42:50
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32469/src/java/org/neuclear/xml Modified Files: AbstractElementProxy.java Log Message: Renamed SignatureInfo to SignedInfo as that is the name of the Element. Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik can't tell the difference between <test/> and <test xmlns=""/>. Changed XMLSignature it is now has less repeated code. Index: AbstractElementProxy.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/AbstractElementProxy.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** AbstractElementProxy.java 19 Feb 2004 00:27:59 -0000 1.10 --- AbstractElementProxy.java 2 Mar 2004 23:30:43 -0000 1.11 *************** *** 2,5 **** --- 2,12 ---- * $Id$ * $Log$ + * Revision 1.11 2004/03/02 23:30:43 pelle + * Renamed SignatureInfo to SignedInfo as that is the name of the Element. + * Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. + * Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik + * can't tell the difference between <test/> and <test xmlns=""/>. + * Changed XMLSignature it is now has less repeated code. + * * Revision 1.10 2004/02/19 00:27:59 pelle * Discovered several incompatabilities with the xmlsig implementation. Have been working on getting it working. *************** *** 105,109 **** * * Revision 1.3 2002/10/10 21:29:31 pelle ! * Oops. XML-Signature's SignedInfo element I had coded as SignatureInfo * As I thought Canonicalisation doesnt seem to be standard. * Updated the SignedServlet to default to using ~/.neuclear/signers.ks --- 112,116 ---- * * Revision 1.3 2002/10/10 21:29:31 pelle ! * Oops. XML-Signature's SignedInfo element I had coded as SignedInfo * As I thought Canonicalisation doesnt seem to be standard. * Updated the SignedServlet to default to using ~/.neuclear/signers.ks *************** *** 191,194 **** --- 198,202 ---- return element; } + /** * Adds another Element with the given name and the same Namespace as this element to this element. *************** *** 196,201 **** * @param child */ ! protected final Element addElement(final String child,final String text) { ! Element elem=addElement(child); elem.addText(text); return elem; --- 204,209 ---- * @param child */ ! protected final Element addElement(final String child, final String text) { ! Element elem = addElement(child); elem.addText(text); return elem; |
|
From: <pe...@us...> - 2004-03-02 23:42:50
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32469/src/java/org/neuclear/xml/c14 Modified Files: Canonicalizer.java Log Message: Renamed SignatureInfo to SignedInfo as that is the name of the Element. Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik can't tell the difference between <test/> and <test xmlns=""/>. Changed XMLSignature it is now has less repeated code. Index: Canonicalizer.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14/Canonicalizer.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Canonicalizer.java 19 Feb 2004 19:37:33 -0000 1.9 --- Canonicalizer.java 2 Mar 2004 23:30:43 -0000 1.10 *************** *** 8,11 **** --- 8,18 ---- * $Id$ * $Log$ + * Revision 1.10 2004/03/02 23:30:43 pelle + * Renamed SignatureInfo to SignedInfo as that is the name of the Element. + * Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. + * Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik + * can't tell the difference between <test/> and <test xmlns=""/>. + * Changed XMLSignature it is now has less repeated code. + * * Revision 1.9 2004/02/19 19:37:33 pelle * At times IntelliJ IDEA can cause some real hassle. On my last checkin it optimized away all of the dom4j and command line imports. *************** *** 126,131 **** */ - import org.dom4j.tree.NamespaceStack; import org.dom4j.*; import org.neuclear.xml.ElementProxy; import org.neuclear.xml.XMLTools; --- 133,139 ---- */ import org.dom4j.*; + import org.dom4j.tree.NamespaceStack; + import org.neuclear.commons.Utility; import org.neuclear.xml.ElementProxy; import org.neuclear.xml.XMLTools; *************** *** 331,336 **** final int previouslyDeclaredNamespaces = namespaceStack.size(); - final Namespace ns = element.getNamespace(); final TreeMap sorted = new TreeMap(); if (isNamespaceDeclaration(ns)) { namespaceStack.push(ns); --- 339,348 ---- final int previouslyDeclaredNamespaces = namespaceStack.size(); final TreeMap sorted = new TreeMap(); + + if (previouslyDeclaredNamespaces == 0) { + writeParentNS(element, sorted); + } + final Namespace ns = element.getNamespace(); if (isNamespaceDeclaration(ns)) { namespaceStack.push(ns); *************** *** 373,376 **** --- 385,400 ---- } + private void writeParentNS(final Element element, final TreeMap sorted) throws IOException { + Element parent = element.getParent(); + if (parent != null) { + final Namespace ns = parent.getNamespace(); + if (isNamespaceDeclaration(ns)) { + namespaceStack.push(ns); + writeNamespace(ns, sorted); + } + writeParentNS(parent, sorted); + } + } + private void writeNamespace(final Namespace namespace, final TreeMap sorted) throws IOException { if (namespace != null) { *************** *** 417,420 **** --- 441,449 ---- private void writeNSAttribute(final Namespace namespace) throws IOException { final String prefix = namespace.getPrefix(); + + // TODO This breaks example 3 from the Merlin Eight, but I'm not sure how to go about fixing it, due to DOM4J's + // nondifferentiation between <test/> and <test xmlns=""/> + if (Utility.isEmpty(prefix) && Utility.isEmpty(namespace.getURI())) + return; writer.write(" xmlns"); if (prefix != null && prefix.length() > 0) { |
|
From: <pe...@us...> - 2004-03-02 19:28:58
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/receiver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6120/src/java/org/neuclear/id/receiver Log Message: Directory /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/receiver added to the repository |
|
From: <pe...@us...> - 2004-03-02 19:15:37
|
Update of /cvsroot/neuclear/neuclear-id/src/test-cactus/org/neuclear/receiver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2485/src/test-cactus/org/neuclear/receiver Removed Files: MockReceiver.java ReceiverServletTest.java Log Message: Even further minors --- MockReceiver.java DELETED --- --- ReceiverServletTest.java DELETED --- |
|
From: <pe...@us...> - 2004-03-02 19:11:41
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1482/src/java/org/neuclear/id Modified Files: SignedMessage.java SignedNamedCore.java SignedNamedObject.java Log Message: Further cleanups in neuclear-id. Moved everything under id. Index: SignedMessage.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/SignedMessage.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SignedMessage.java 20 Jan 2004 17:39:12 -0000 1.3 --- SignedMessage.java 2 Mar 2004 18:59:11 -0000 1.4 *************** *** 4,8 **** import org.neuclear.commons.time.TimeTools; import org.neuclear.xml.xmlsec.XMLSecurityException; ! import org.neuclear.auth.AuthenticationTicket; import org.dom4j.Element; import org.dom4j.DocumentHelper; --- 4,8 ---- import org.neuclear.commons.time.TimeTools; import org.neuclear.xml.xmlsec.XMLSecurityException; ! import org.neuclear.id.auth.AuthenticationTicket; import org.dom4j.Element; import org.dom4j.DocumentHelper; Index: SignedNamedCore.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/SignedNamedCore.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** SignedNamedCore.java 18 Feb 2004 00:14:32 -0000 1.19 --- SignedNamedCore.java 2 Mar 2004 18:59:11 -0000 1.20 *************** *** 2,5 **** --- 2,8 ---- * $Id$ * $Log$ + * Revision 1.20 2004/03/02 18:59:11 pelle + * Further cleanups in neuclear-id. Moved everything under id. + * * Revision 1.19 2004/02/18 00:14:32 pelle * Many, many clean ups. I've readded Targets in a new method. *************** *** 300,304 **** * @see org.neuclear.id.verifier.VerifyingReader * @see org.neuclear.id.resolver.NSResolver ! * @see org.neuclear.senders.Sender * @see org.neuclear.commons.crypto.signers.Signer */ --- 303,307 ---- * @see org.neuclear.id.verifier.VerifyingReader * @see org.neuclear.id.resolver.NSResolver ! * @see org.neuclear.id.senders.Sender * @see org.neuclear.commons.crypto.signers.Signer */ Index: SignedNamedObject.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/SignedNamedObject.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** SignedNamedObject.java 18 Feb 2004 00:14:32 -0000 1.18 --- SignedNamedObject.java 2 Mar 2004 18:59:11 -0000 1.19 *************** *** 2,5 **** --- 2,8 ---- * $Id$ * $Log$ + * Revision 1.19 2004/03/02 18:59:11 pelle + * Further cleanups in neuclear-id. Moved everything under id. + * * Revision 1.18 2004/02/18 00:14:32 pelle * Many, many clean ups. I've readded Targets in a new method. *************** *** 264,268 **** * @see org.neuclear.id.verifier.VerifyingReader * @see org.neuclear.id.resolver.NSResolver ! * @see org.neuclear.senders.Sender * @see org.neuclear.commons.crypto.signers.Signer */ --- 267,271 ---- * @see org.neuclear.id.verifier.VerifyingReader * @see org.neuclear.id.resolver.NSResolver ! * @see org.neuclear.id.senders.Sender * @see org.neuclear.commons.crypto.signers.Signer */ |
|
From: <pe...@us...> - 2004-03-02 19:11:40
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/verifier In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1482/src/java/org/neuclear/id/verifier Modified Files: VerifyingReader.java Log Message: Further cleanups in neuclear-id. Moved everything under id. Index: VerifyingReader.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/verifier/VerifyingReader.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** VerifyingReader.java 19 Feb 2004 15:30:21 -0000 1.19 --- VerifyingReader.java 2 Mar 2004 18:59:11 -0000 1.20 *************** *** 2,6 **** import org.dom4j.Element; ! import org.neuclear.auth.AuthenticationTicket; import org.neuclear.id.*; import org.neuclear.xml.XMLException; --- 2,6 ---- import org.dom4j.Element; ! import org.neuclear.id.auth.AuthenticationTicket; import org.neuclear.id.*; import org.neuclear.xml.XMLException; *************** *** 31,34 **** --- 31,37 ---- $Id$ $Log$ + Revision 1.20 2004/03/02 18:59:11 pelle + Further cleanups in neuclear-id. Moved everything under id. + Revision 1.19 2004/02/19 15:30:21 pelle Various cleanups and corrections |
|
From: <pe...@us...> - 2004-03-02 19:11:40
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/tools/commandline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1482/src/java/org/neuclear/id/tools/commandline Modified Files: IdentityCreator.java Log Message: Further cleanups in neuclear-id. Moved everything under id. Index: IdentityCreator.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/tools/commandline/IdentityCreator.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** IdentityCreator.java 18 Feb 2004 00:14:31 -0000 1.8 --- IdentityCreator.java 2 Mar 2004 18:59:11 -0000 1.9 *************** *** 1,4 **** --- 1,7 ---- /* $Id$ * $Log$ + * Revision 1.9 2004/03/02 18:59:11 pelle + * Further cleanups in neuclear-id. Moved everything under id. + * * Revision 1.8 2004/02/18 00:14:31 pelle * Many, many clean ups. I've readded Targets in a new method. *************** *** 225,229 **** import org.neuclear.id.builders.Builder; import org.neuclear.id.builders.IdentityBuilder; ! import org.neuclear.senders.LogSender; import java.security.PublicKey; --- 228,232 ---- import org.neuclear.id.builders.Builder; import org.neuclear.id.builders.IdentityBuilder; ! import org.neuclear.id.senders.LogSender; import java.security.PublicKey; |
|
From: <pe...@us...> - 2004-03-02 19:11:40
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/targets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1482/src/java/org/neuclear/id/targets Modified Files: Targets.java Log Message: Further cleanups in neuclear-id. Moved everything under id. Index: Targets.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/targets/Targets.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Targets.java 18 Feb 2004 00:14:31 -0000 1.1 --- Targets.java 2 Mar 2004 18:59:10 -0000 1.2 *************** *** 4,8 **** import org.neuclear.commons.NeuClearException; import org.neuclear.id.SignedNamedObject; ! import org.neuclear.senders.Sender; import java.util.List; --- 4,8 ---- import org.neuclear.commons.NeuClearException; import org.neuclear.id.SignedNamedObject; ! import org.neuclear.id.senders.Sender; import java.util.List; *************** *** 28,31 **** --- 28,34 ---- $Id$ $Log$ + Revision 1.2 2004/03/02 18:59:10 pelle + Further cleanups in neuclear-id. Moved everything under id. + Revision 1.1 2004/02/18 00:14:31 pelle Many, many clean ups. I've readded Targets in a new method. |
|
From: <pe...@us...> - 2004-03-02 19:11:39
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/builders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1482/src/java/org/neuclear/id/builders Modified Files: AuthenticationTicketBuilder.java Log Message: Further cleanups in neuclear-id. Moved everything under id. Index: AuthenticationTicketBuilder.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/builders/AuthenticationTicketBuilder.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** AuthenticationTicketBuilder.java 13 Jan 2004 23:38:26 -0000 1.10 --- AuthenticationTicketBuilder.java 2 Mar 2004 18:59:10 -0000 1.11 *************** *** 2,6 **** import org.dom4j.DocumentHelper; ! import org.neuclear.auth.AuthenticationTicket; import org.neuclear.commons.time.TimeTools; import org.neuclear.id.InvalidNamedObjectException; --- 2,6 ---- import org.dom4j.DocumentHelper; ! import org.neuclear.id.auth.AuthenticationTicket; import org.neuclear.commons.time.TimeTools; import org.neuclear.id.InvalidNamedObjectException; *************** *** 30,33 **** --- 30,36 ---- $Id$ $Log$ + Revision 1.11 2004/03/02 18:59:10 pelle + Further cleanups in neuclear-id. Moved everything under id. + Revision 1.10 2004/01/13 23:38:26 pelle Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes. |
|
From: <pe...@us...> - 2004-03-02 19:11:18
|
Update of /cvsroot/neuclear/neuclear-id/src/test-cactus/org/neuclear/id/auth In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1482/src/test-cactus/org/neuclear/id/auth Added Files: AuthenticationFilterTest.java AuthenticationServletTest.java Log Message: Further cleanups in neuclear-id. Moved everything under id. --- NEW FILE: AuthenticationFilterTest.java --- package org.neuclear.id.auth; import org.apache.cactus.FilterTestCase; import org.apache.cactus.WebRequest; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.Base64; import org.neuclear.commons.crypto.signers.TestCaseSigner; import org.neuclear.id.SignedNamedObject; import org.neuclear.id.builders.AuthenticationTicketBuilder; import org.neuclear.xml.XMLException; import org.neuclear.xml.xmlsec.XMLSecTools; import javax.servlet.*; import java.io.IOException; import java.security.GeneralSecurityException; /* 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: AuthenticationFilterTest.java,v 1.1 2004/03/02 18:59:13 pelle Exp $ $Log: AuthenticationFilterTest.java,v $ Revision 1.1 2004/03/02 18:59:13 pelle Further cleanups in neuclear-id. Moved everything under id. Revision 1.2 2004/01/13 23:38:26 pelle Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes. Revision 1.1 2003/12/12 19:28:03 pelle All the Cactus tests now for signing signers. Added working AuthenticationFilterTest Returned original functionality to DemoSigningServlet. This is set up to use the test keys stored in neuclear-commons. SigningServlet should now work for general use. It uses the default keystore. Will add configurability later. It also uses the GUIDialogAgent. */ /** * User: pelleb * Date: Dec 12, 2003 * Time: 1:25:21 PM */ public class AuthenticationFilterTest extends FilterTestCase { public AuthenticationFilterTest() throws GeneralSecurityException, NeuClearException { signer = new TestCaseSigner(); } public void beginValid(WebRequest theRequest) throws GeneralSecurityException, NeuClearException, XMLException { AuthenticationTicketBuilder authreq = new AuthenticationTicketBuilder("neu://bob@test", "neu://test", "http://localhost"); SignedNamedObject signed = authreq.convert("neu://bob@test",signer); theRequest.setContentType("application/x-www-form-urlencoded"); String b64 = Base64.encode(signed.getEncoded().getBytes()); theRequest.addParameter("neuclear-request", b64, "POST"); theRequest.setURL("http://users.neuclear.org", "/test", "/Receiver", null, null); } public void testValid() throws ServletException, IOException { AuthenticationFilter filter = new AuthenticationFilter(); config.setInitParameter("service", "neu://test"); filter.init(config); FilterChain mockFilterChain = new FilterChain() { public void doFilter(ServletRequest theRequest, ServletResponse theResponse) throws IOException, ServletException { assertNotNull(request.getUserPrincipal()); assertEquals("neu://bob@test", request.getUserPrincipal().getName()); } public void init(FilterConfig theConfig) { } public void destroy() { } }; filter.doFilter(request, response, mockFilterChain); } public void beginUnsigned(WebRequest theRequest) throws GeneralSecurityException, NeuClearException, XMLException { AuthenticationTicketBuilder authreq = new AuthenticationTicketBuilder("neu://bob@test", "neu://test", "http://localhost"); theRequest.setContentType("application/x-www-form-urlencoded"); String b64 = XMLSecTools.encodeElementBase64(authreq); theRequest.addParameter("neuclear-request", b64, "POST"); theRequest.setURL("http://users.neuclear.org", "/test", "/Receiver", null, null); } public void testUnsigned() throws ServletException, IOException { AuthenticationFilter filter = new AuthenticationFilter(); config.setInitParameter("service", "neu://test"); filter.init(config); FilterChain mockFilterChain = new FilterChain() { public void doFilter(ServletRequest theRequest, ServletResponse theResponse) throws IOException, ServletException { assertNull(request.getUserPrincipal()); } public void init(FilterConfig theConfig) { } public void destroy() { } }; filter.doFilter(request, response, mockFilterChain); } private TestCaseSigner signer; } --- NEW FILE: AuthenticationServletTest.java --- package org.neuclear.id.auth; import org.apache.cactus.ServletTestCase; import org.apache.cactus.WebRequest; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.Utility; import org.neuclear.commons.crypto.signers.TestCaseSigner; import org.neuclear.commons.crypto.signers.JCESigner; import org.neuclear.commons.crypto.Base64; import org.neuclear.xml.XMLException; import org.neuclear.id.builders.AuthenticationTicketBuilder; import org.neuclear.id.builders.SignatureRequestBuilder; import org.neuclear.id.SignedNamedObject; import org.neuclear.id.SignatureRequest; import org.neuclear.id.resolver.NSResolver; import org.neuclear.id.verifier.VerifyingReader; import org.neuclear.id.signers.SigningServlet; import org.neuclear.id.signers.DemoSigningServlet; import org.xml.sax.SAXException; import javax.servlet.ServletException; import java.security.GeneralSecurityException; import java.io.IOException; import java.io.ByteArrayInputStream; import com.meterware.httpunit.WebForm; /* 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: AuthenticationServletTest.java,v 1.1 2004/03/02 18:59:13 pelle Exp $ $Log: AuthenticationServletTest.java,v $ Revision 1.1 2004/03/02 18:59:13 pelle Further cleanups in neuclear-id. Moved everything under id. Revision 1.1 2003/12/20 00:21:19 pelle overwrote the standard Object.toString(), hashCode() and equals() methods for SignedNamedObject/Core fixed cactus tests Added TransferRequestServlet Added cactus tests to pay */ /** * User: pelleb * Date: Dec 19, 2003 * Time: 6:05:53 PM */ public class AuthenticationServletTest extends ServletTestCase { public AuthenticationServletTest(String string) throws NeuClearException { super(string); signer = new TestCaseSigner(); } public void beginAuthReq(WebRequest theRequest) throws GeneralSecurityException, NeuClearException, XMLException { theRequest.setContentType("application/x-www-form-urlencoded"); theRequest.addParameter("identity", "neu://bob@test", "POST"); theRequest.setURL("http://users.neuclear.org", "/test", "/Receiver", null, null); } public void testAuthReq() throws ServletException, IOException { assertEquals(request.getContentType(), "application/x-www-form-urlencoded"); assertEquals(request.getMethod(), "POST"); config.setInitParameter("serviceid","neu://test"); config.setInitParameter("title","cactustest"); AuthenticationServlet servlet = new AuthenticationServlet(); servlet.init(config); servlet.service(request, response); } public void endAuthReq(com.meterware.httpunit.WebResponse theResponse) throws SAXException, NeuClearException, XMLException { assertEquals("cactustest", theResponse.getTitle()); WebForm forms[] = theResponse.getForms(); assertNotNull(forms); assertEquals(1, forms.length); assertTrue(forms[0].hasParameterNamed("neuclear-request")); String encoded = forms[0].getParameterValue("neuclear-request"); assertTrue(!Utility.isEmpty(encoded)); final SignedNamedObject obj = VerifyingReader.getInstance().read(new ByteArrayInputStream(Base64.decode(encoded))); assertNotNull(obj); assertTrue(obj instanceof SignatureRequest); SignatureRequest sigreq = (SignatureRequest) obj; assertEquals(sigreq.getSignatory().getName(), "neu://test"); assertEquals(sigreq.getUnsigned().getElement().getName(), "AuthenticationTicket"); assertEquals(sigreq.getUserid(), "neu://bob@test"); assertEquals(NSResolver.resolveIdentity("neu://bob@test").getSigner(), forms[0].getAction()); } JCESigner signer; } |
|
From: <pe...@us...> - 2004-03-02 19:11:18
|
Update of /cvsroot/neuclear/neuclear-id/src/test-cactus/org/neuclear/id/receiver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1482/src/test-cactus/org/neuclear/id/receiver Added Files: MockReceiver.java ReceiverServletTest.java Log Message: Further cleanups in neuclear-id. Moved everything under id. --- NEW FILE: MockReceiver.java --- package org.neuclear.id.receiver; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.signers.Signer; import org.neuclear.commons.crypto.signers.TestCaseSigner; import org.neuclear.commons.crypto.signers.InvalidPassphraseException; import org.neuclear.id.SignedNamedObject; import org.neuclear.id.builders.AuthenticationTicketBuilder; import org.neuclear.xml.ElementProxy; /* 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: MockReceiver.java,v 1.1 2004/03/02 18:59:13 pelle Exp $ $Log: MockReceiver.java,v $ Revision 1.1 2004/03/02 18:59:13 pelle Further cleanups in neuclear-id. Moved everything under id. Revision 1.3 2004/01/13 15:11:36 pelle Now builds. Now need to do unit tests Revision 1.2 2003/12/12 00:13:11 pelle This may actually work now. Need to put a few more test cases in to make sure. Revision 1.1 2003/12/11 23:57:30 pelle Trying to test the ReceiverServlet with cactus. Still no luck. Need to return a ElementProxy of some sort. Cleaned up some missing fluff in the ElementProxy interface. getTagName(), getQName() and getNameSpace() have been killed. */ /** * User: pelleb * Date: Dec 11, 2003 * Time: 6:03:55 PM */ public class MockReceiver implements Receiver { public MockReceiver() { try { signer=new TestCaseSigner(); } catch (InvalidPassphraseException e) { throw new RuntimeException(e); } } /** * Add your main transaction processing logic within this method. * Remember you must check the validity of the SignedNamedObject here. Until you do so * you can not trust it. * * @param obj * @throws UnsupportedTransaction */ public SignedNamedObject receive(SignedNamedObject obj) throws UnsupportedTransaction, NeuClearException { received = obj; return new AuthenticationTicketBuilder("neu://test", obj.getName(), "http://localhost").convert("neu://bob@test",signer);//Just some dummy } public SignedNamedObject getLastReceived() { return received; } private Signer signer; private SignedNamedObject received = null; } --- NEW FILE: ReceiverServletTest.java --- package org.neuclear.id.receiver; import org.apache.cactus.ServletTestCase; import org.apache.cactus.WebRequest; import org.neuclear.id.auth.AuthenticationTicket; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.Base64; import org.neuclear.commons.crypto.signers.JCESigner; import org.neuclear.commons.crypto.signers.TestCaseSigner; import org.neuclear.id.builders.AuthenticationTicketBuilder; import org.neuclear.xml.XMLException; import javax.servlet.ServletException; import java.io.ByteArrayInputStream; import java.io.IOException; import java.security.GeneralSecurityException; /* 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: ReceiverServletTest.java,v 1.1 2004/03/02 18:59:13 pelle Exp $ $Log: ReceiverServletTest.java,v $ Revision 1.1 2004/03/02 18:59:13 pelle Further cleanups in neuclear-id. Moved everything under id. Revision 1.6 2004/01/13 23:38:26 pelle Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes. Revision 1.5 2003/12/12 15:12:50 pelle The ReceiverServletTest now passes. Add first stab at a SigningServletTest which currently doesnt pass. Revision 1.4 2003/12/12 12:32:54 pelle Working on getting the SOAPServletTest working under cactus Revision 1.3 2003/12/11 23:57:30 pelle Trying to test the ReceiverServlet with cactus. Still no luck. Need to return a ElementProxy of some sort. Cleaned up some missing fluff in the ElementProxy interface. getTagName(), getQName() and getNameSpace() have been killed. Revision 1.2 2003/11/28 00:12:59 pelle Getting the NeuClear web transactions working. Revision 1.1 2003/11/24 23:33:38 pelle More Cactus unit testing going on. */ /** * User: pelleb * Date: Nov 24, 2003 * Time: 5:08:05 PM */ public class ReceiverServletTest extends ServletTestCase { public ReceiverServletTest(String string) throws GeneralSecurityException, NeuClearException { super(string); signer = new TestCaseSigner(); } public void beginReceiveBase64(WebRequest theRequest) throws GeneralSecurityException, NeuClearException, XMLException { AuthenticationTicketBuilder builder = new AuthenticationTicketBuilder("neu://bob@test", "neu://test", "http://localhost"); AuthenticationTicket ticket = (AuthenticationTicket) builder.convert("neu://bob@test",signer); theRequest.setContentType("application/x-www-form-urlencoded"); String b64 =Base64.encode(ticket.getEncoded().getBytes()); theRequest.addParameter("neuclear-request", b64, "POST"); theRequest.setURL("http://users.neuclear.org", "/test", "/Receiver", null, null); } public void testReceiveBase64() throws ServletException, IOException { assertEquals(request.getContentType(), "application/x-www-form-urlencoded"); assertEquals(request.getMethod(),"POST"); ReceiverServlet servlet = new ReceiverServlet(); MockReceiver receiver = new MockReceiver(); servlet.setReceiver(receiver); servlet.init(config); servlet.service(request, response); assertNotNull(receiver.getLastReceived()); assertEquals(receiver.getLastReceived().getSignatory().getName(), "neu://bob@test"); } public void beginReceiveSOAP(WebRequest theRequest) throws GeneralSecurityException, NeuClearException, XMLException, IOException { AuthenticationTicketBuilder builder = new AuthenticationTicketBuilder("neu://alice@test", "neu://test", "http://localhost"); AuthenticationTicket ticket = (AuthenticationTicket) builder.convert("neu://bob@test",signer); theRequest.setContentType("text/xml"); theRequest.setURL("http://users.neuclear.org", "/test", "/Service", null, null); theRequest.setUserData(new ByteArrayInputStream(ticket.getEncoded().getBytes())); } public void testReceiveSOAP() throws ServletException, IOException { assertEquals(request.getContentType(), "text/xml"); assertEquals(request.getMethod(),"POST"); ReceiverServlet servlet = new ReceiverServlet(); MockReceiver receiver = new MockReceiver(); servlet.setReceiver(receiver); servlet.init(config); servlet.service(request, response); assertNotNull(receiver.getLastReceived()); assertEquals(receiver.getLastReceived().getSignatory().getName(), "neu://alice@test"); } JCESigner signer; } |
|
From: <pe...@us...> - 2004-03-02 19:11:18
|
Update of /cvsroot/neuclear/neuclear-id/src/webapp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1482/src/webapp Modified Files: index.jsp Log Message: Further cleanups in neuclear-id. Moved everything under id. Index: index.jsp =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/webapp/index.jsp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** index.jsp 12 Dec 2003 23:45:41 -0000 1.12 --- index.jsp 2 Mar 2004 18:59:14 -0000 1.13 *************** *** 1,5 **** <%@ page import="org.neuclear.commons.Utility, org.neuclear.id.SignedNamedObject, ! org.neuclear.auth.AuthenticationTicket, org.neuclear.id.NSTools, org.neuclear.commons.servlets.ServletTools , --- 1,5 ---- <%@ page import="org.neuclear.commons.Utility, org.neuclear.id.SignedNamedObject, ! org.neuclear.id.auth.AuthenticationTicket, org.neuclear.id.NSTools, org.neuclear.commons.servlets.ServletTools , |