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: Pelle B. <pe...@us...> - 2004-03-22 22:24:31
|
Update of /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11256/src/test/org/neuclear/ledger/simple Log Message: Directory /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/simple added to the repository |
|
From: Pelle B. <pe...@us...> - 2004-03-22 22:23:11
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10919/src/java/org/neuclear/ledger/tests Log Message: Directory /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/tests added to the repository |
|
From: <bug...@ve...> - 2004-03-22 22:11:35
|
Message:
The following issue has been closed.
Resolver: Pelle Braendgaard
Date: Mon, 22 Mar 2004 2:11 PM
This has now been implemented and passes all unit tests.
---------------------------------------------------------------------
View the issue:
http://jira.neuclear.org//browse/GL-22
Here is an overview of the issue:
---------------------------------------------------------------------
Key: GL-22
Summary: Create SimpleLedger for testing purposes
Type: New Feature
Status: Closed
Priority: Major
Resolution: FIXED
Original Estimate: Unknown
Time Spent: Unknown
Remaining: Unknown
Project: NeuClear Ledger
Fix Fors:
r_0_4
Versions:
r_0_4
Assignee: Pelle Braendgaard
Reporter: Pelle Braendgaard
Created: Mon, 22 Mar 2004 1:31 PM
Updated: Mon, 22 Mar 2004 2:11 PM
Description:
We need a Simple Ledger implementation for testing purposes. This can be an in memory implementation.
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.neuclear.org//secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|
|
From: Pelle B. <pe...@us...> - 2004-03-22 22:09:59
|
Update of /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7293/src/test/org/neuclear/ledger Modified Files: AbstractLedgerTest.java Log Message: SimpleLedger now passes all unit tests Index: AbstractLedgerTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/AbstractLedgerTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractLedgerTest.java 22 Mar 2004 20:08:24 -0000 1.1 --- AbstractLedgerTest.java 22 Mar 2004 21:59:38 -0000 1.2 *************** *** 16,22 **** * $Id$ * $Log$ * Revision 1.1 2004/03/22 20:08:24 pelle * Added simple ledger for unit testing and in memory use ! * * Revision 1.12 2004/03/22 17:33:02 pelle * Added a verified transfer to neuclear-ledger. --- 16,25 ---- * $Id$ * $Log$ + * Revision 1.2 2004/03/22 21:59:38 pelle + * SimpleLedger now passes all unit tests + * * Revision 1.1 2004/03/22 20:08:24 pelle * Added simple ledger for unit testing and in memory use ! * <p/> * Revision 1.12 2004/03/22 17:33:02 pelle * Added a verified transfer to neuclear-ledger. *************** *** 298,306 **** ledger.performCompleteHold(tran, 100, "done"); ! assertEquals("ALICE BALANCE CANCELLED", aliceBalance - amount, ledger.getBalance(ALICE), 0); ! assertEquals("BOB BALANCE CANCELLED", bobBalance + amount, ledger.getBalance(BOB), 0); ! assertEquals("ALICE Available BALANCE CANCELLED", aliceBalance - amount, ledger.getAvailableBalance(ALICE), 0); ! assertEquals("BOB Available BALANCE CANCELLED", bobBalance + amount, ledger.getAvailableBalance(BOB), 0); --- 301,309 ---- ledger.performCompleteHold(tran, 100, "done"); ! assertEquals("ALICE BALANCE COMPLETED", aliceBalance - amount, ledger.getBalance(ALICE), 0); ! assertEquals("BOB BALANCE COMPLETED", bobBalance + amount, ledger.getBalance(BOB), 0); ! assertEquals("ALICE Available BALANCE COMPLETED", aliceBalance - amount, ledger.getAvailableBalance(ALICE), 0); ! assertEquals("BOB Available BALANCE COMPLETED", bobBalance + amount, ledger.getAvailableBalance(BOB), 0); |
|
From: Pelle B. <pe...@us...> - 2004-03-22 22:09:59
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7293/src/java/org/neuclear/ledger Modified Files: Ledger.java Log Message: SimpleLedger now passes all unit tests Index: Ledger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/Ledger.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Ledger.java 22 Mar 2004 17:33:02 -0000 1.11 --- Ledger.java 22 Mar 2004 21:59:37 -0000 1.12 *************** *** 4,7 **** --- 4,10 ---- * $Id$ * $Log$ + * Revision 1.12 2004/03/22 21:59:37 pelle + * SimpleLedger now passes all unit tests + * * Revision 1.11 2004/03/22 17:33:02 pelle * Added a verified transfer to neuclear-ledger. *************** *** 183,187 **** * @throws TransactionExpiredException */ ! public abstract PostedTransaction performCompleteHold(PostedHeldTransaction hold, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, TransactionExpiredException; /** --- 186,190 ---- * @throws TransactionExpiredException */ ! public abstract PostedTransaction performCompleteHold(PostedHeldTransaction hold, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, TransactionExpiredException, UnknownTransactionException; /** *************** *** 287,290 **** --- 290,295 ---- public final PostedHeldTransaction hold(String from, String to, Date expiry, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, UnBalancedTransactionException, InsufficientFundsException { + if (getAvailableBalance(from) - amount < 0) + throw new InsufficientFundsException(this, from, amount); return hold(CryptoTools.createRandomID(), CryptoTools.createRandomID(), from, to, expiry, amount, comment); } |
|
From: Pelle B. <pe...@us...> - 2004-03-22 22:09:58
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7293/src/java/org/neuclear/ledger/simple Modified Files: SimpleLedger.java Log Message: SimpleLedger now passes all unit tests Index: SimpleLedger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple/SimpleLedger.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SimpleLedger.java 22 Mar 2004 20:08:24 -0000 1.1 --- SimpleLedger.java 22 Mar 2004 21:59:37 -0000 1.2 *************** *** 4,7 **** --- 4,10 ---- * $Id$ * $Log$ + * Revision 1.2 2004/03/22 21:59:37 pelle + * SimpleLedger now passes all unit tests + * * Revision 1.1 2004/03/22 20:08:24 pelle * Added simple ledger for unit testing and in memory use *************** *** 85,89 **** ledger = new LinkedHashMap(); held = new LinkedHashMap(); ! books = new HashMap(); } --- 88,93 ---- ledger = new LinkedHashMap(); held = new LinkedHashMap(); ! balances = new HashMap(); ! } *************** *** 102,108 **** --- 106,130 ---- final PostedTransaction posted = new PostedTransaction(trans, new Date()); ledger.put(id, posted); + updateBalances(posted); return posted; } + private void updateBalances(final PostedTransaction trans) { + synchronized (balances) { + Iterator iter = trans.getItems(); + while (iter.hasNext()) { + TransactionItem item = (TransactionItem) iter.next(); + addTransactionItem(item); + } + } + } + + private void addTransactionItem(TransactionItem item) { + if (balances.containsKey(item.getBook())) + balances.put(item.getBook(), new Double(((Double) balances.get(item.getBook())).doubleValue() + item.getAmount())); + else + balances.put(item.getBook(), new Double(item.getAmount())); + } + /** * Similar to a transaction but guarantees that there wont be any negative balances left after the transaction. *************** *** 166,175 **** * */ ! public PostedTransaction performCompleteHold(PostedHeldTransaction hold, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, TransactionExpiredException { ! if (!held.containsKey(hold) || hold.getExpiryTime().before(new Date())) throw new TransactionExpiredException(this, hold); held.remove(hold.getId()); PostedTransaction posted = new PostedTransaction(hold, new Date(), amount, comment); ledger.put(posted.getId(), posted); return posted; } --- 188,200 ---- * */ ! public PostedTransaction performCompleteHold(PostedHeldTransaction hold, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, TransactionExpiredException, UnknownTransactionException { ! if (!held.containsKey(hold.getId())) ! throw new UnknownTransactionException(this, hold.getId()); ! if (hold.getExpiryTime().before(new Date())) throw new TransactionExpiredException(this, hold); held.remove(hold.getId()); PostedTransaction posted = new PostedTransaction(hold, new Date(), amount, comment); ledger.put(posted.getId(), posted); + updateBalances(posted); return posted; } *************** *** 196,214 **** */ public double getBalance(final String book) { ! double balance = 0; ! // Very silly slow and lazy implementation ! final Iterator iter = ledger.keySet().iterator(); ! final boolean going = true; ! while (iter.hasNext() && going) { ! final PostedTransaction tran = (PostedTransaction) ledger.get((String) iter.next()); ! final Iterator items = tran.getItems(); ! while (items.hasNext()) { ! final TransactionItem item = (TransactionItem) items.next(); ! if (item.getBook().equals(book)) ! balance += item.getAmount(); ! } ! } ! System.out.println("Book: " + book + " has a balance of: " + balance); ! return balance; } --- 221,227 ---- */ public double getBalance(final String book) { ! if (balances.containsKey(book)) ! return ((Double) balances.get(book)).doubleValue(); ! return 0; } *************** *** 228,234 **** // Very silly slow and lazy implementation final Iterator iter = held.keySet().iterator(); ! final boolean going = true; ! while (iter.hasNext() && going) { ! final PostedHeldTransaction tran = (PostedHeldTransaction) ledger.get((String) iter.next()); if (now.after(tran.getExpiryTime())) { iter.remove(); --- 241,247 ---- // Very silly slow and lazy implementation final Iterator iter = held.keySet().iterator(); ! while (iter.hasNext()) { ! final Object o = held.get(iter.next()); ! final PostedHeldTransaction tran = (PostedHeldTransaction) o; if (now.after(tran.getExpiryTime())) { iter.remove(); *************** *** 237,241 **** while (items.hasNext()) { final TransactionItem item = (TransactionItem) items.next(); ! if (item.getBook().equals(book)) balance += item.getAmount(); } --- 250,254 ---- while (items.hasNext()) { final TransactionItem item = (TransactionItem) items.next(); ! if (item.getBook().equals(book) && item.getAmount() < 0) balance += item.getAmount(); } *************** *** 284,287 **** --- 297,301 ---- private final LinkedHashMap held; private final String id; + private final HashMap balances; |
|
From: <bug...@ve...> - 2004-03-22 21:32:35
|
Message: Work on this issue has been started by Pelle Braendgaard (mailto:pe...@ve...) --------------------------------------------------------------------- View the issue: http://jira.neuclear.org//browse/GL-22 Here is an overview of the issue: --------------------------------------------------------------------- Key: GL-22 Summary: Create SimpleLedger for testing purposes Type: New Feature Status: In Progress Priority: Major Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: NeuClear Ledger Fix Fors: r_0_4 Versions: r_0_4 Assignee: Pelle Braendgaard Reporter: Pelle Braendgaard Created: Mon, 22 Mar 2004 1:31 PM Updated: Mon, 22 Mar 2004 1:31 PM Description: We need a Simple Ledger implementation for testing purposes. This can be an in memory implementation. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://jira.neuclear.org//secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
|
From: <bug...@ve...> - 2004-03-22 21:32:34
|
Message: A new issue has been created in JIRA. --------------------------------------------------------------------- View the issue: http://jira.neuclear.org//browse/GL-22 Here is an overview of the issue: --------------------------------------------------------------------- Key: GL-22 Summary: Create SimpleLedger for testing purposes Type: New Feature Status: Open Priority: Major Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: NeuClear Ledger Fix Fors: r_0_4 Versions: r_0_4 Assignee: Pelle Braendgaard Reporter: Pelle Braendgaard Created: Mon, 22 Mar 2004 1:31 PM Updated: Mon, 22 Mar 2004 1:31 PM Description: We need a Simple Ledger implementation for testing purposes. This can be an in memory implementation. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://jira.neuclear.org//secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:20:37
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/senders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11947/src/java/org/neuclear/id/senders Modified Files: Sender.java SmtpSender.java Log Message: Added simple ledger for unit testing and in memory use Index: SmtpSender.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/senders/SmtpSender.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SmtpSender.java 2 Mar 2004 18:59:10 -0000 1.1 --- SmtpSender.java 22 Mar 2004 20:09:46 -0000 1.2 *************** *** 8,11 **** --- 8,14 ---- * $Id$ * $Log$ + * Revision 1.2 2004/03/22 20:09:46 pelle + * Added simple ledger for unit testing and in memory use + * * Revision 1.1 2004/03/02 18:59:10 pelle * Further cleanups in neuclear-id. Moved everything under id. *************** *** 21,26 **** * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for sample web app. ! * Added missing LGPL LICENSE.txt files to signer and sample app * * Revision 1.15 2003/12/10 23:58:52 pelle --- 24,29 ---- * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for simple web app. ! * Added missing LGPL LICENSE.txt files to signer and simple app * * Revision 1.15 2003/12/10 23:58:52 pelle *************** *** 142,146 **** public final class SmtpSender extends Sender { ! public final SignedNamedObject send(String endpoint, final SignedNamedObject obj) throws NeuClearException,UnsupportedEndpointException { final Properties props = System.getProperties(); if (endpoint.startsWith("mailto:")) --- 145,149 ---- public final class SmtpSender extends Sender { ! public final SignedNamedObject send(String endpoint, final SignedNamedObject obj) throws NeuClearException, UnsupportedEndpointException { final Properties props = System.getProperties(); if (endpoint.startsWith("mailto:")) *************** *** 198,201 **** --- 201,205 ---- return "du...@ne..."; } + private static final Pattern SENDER = Pattern.compile("^(mailto:)([\\w-.]+\\@[\\w-.]+)"); Index: Sender.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/senders/Sender.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Sender.java 2 Mar 2004 18:59:10 -0000 1.1 --- Sender.java 22 Mar 2004 20:09:43 -0000 1.2 *************** *** 8,11 **** --- 8,14 ---- * $Id$ * $Log$ + * Revision 1.2 2004/03/22 20:09:43 pelle + * Added simple ledger for unit testing and in memory use + * * Revision 1.1 2004/03/02 18:59:10 pelle * Further cleanups in neuclear-id. Moved everything under id. *************** *** 20,25 **** * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for sample web app. ! * Added missing LGPL LICENSE.txt files to signer and sample app * * Revision 1.13 2003/12/10 23:58:52 pelle --- 23,28 ---- * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for simple web app. ! * Added missing LGPL LICENSE.txt files to signer and simple app * * Revision 1.13 2003/12/10 23:58:52 pelle |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:20:33
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/builders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11947/src/java/org/neuclear/id/builders Modified Files: IdentityBuilder.java Log Message: Added simple ledger for unit testing and in memory use Index: IdentityBuilder.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/builders/IdentityBuilder.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** IdentityBuilder.java 18 Feb 2004 00:14:30 -0000 1.19 --- IdentityBuilder.java 22 Mar 2004 20:09:43 -0000 1.20 *************** *** 2,5 **** --- 2,8 ---- * $Id$ * $Log$ + * Revision 1.20 2004/03/22 20:09:43 pelle + * Added simple ledger for unit testing and in memory use + * * Revision 1.19 2004/02/18 00:14:30 pelle * Many, many clean ups. I've readded Targets in a new method. *************** *** 36,41 **** * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for sample web app. ! * Added missing LGPL LICENSE.txt files to signer and sample app * * Revision 1.13 2003/12/11 23:57:29 pelle --- 39,44 ---- * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for simple web app. ! * Added missing LGPL LICENSE.txt files to signer and simple app * * Revision 1.13 2003/12/11 23:57:29 pelle *************** *** 241,251 **** /** * It creates a Standard Identity document, but doesn't sign it. ! * ! * @param allow PublicKey allowed to sign in here ! * @param signer URL of default interactive signing service for namespace. If null it doesnt allow interactive signing ! * @param receiver URL of default receiver for namespace */ ! public IdentityBuilder( final PublicKey allow, final String signer, final String logger, final String receiver) throws InvalidNamedObjectException { this(createNEUIDQName(TAGNAME), allow, signer, logger, receiver); } --- 244,254 ---- /** * It creates a Standard Identity document, but doesn't sign it. ! * ! * @param allow PublicKey allowed to sign in here ! * @param signer URL of default interactive signing service for namespace. If null it doesnt allow interactive signing ! * @param receiver URL of default receiver for namespace */ ! public IdentityBuilder(final PublicKey allow, final String signer, final String logger, final String receiver) throws InvalidNamedObjectException { this(createNEUIDQName(TAGNAME), allow, signer, logger, receiver); } *************** *** 253,263 **** /** * This constructor should be used by subclasses of Identity. It creates a Standard Identity document, but doesn't sign it. ! * ! * @param tag The Tag used by this sub class ! * @param allow PublicKey allowed to sign in here ! * @param signer URL of default interactive signing service for namespace. If null it doesnt allow interactive signing ! * @param receiver URL of default receiver for namespace */ ! protected IdentityBuilder(final QName tag, final PublicKey allow, final String signer, final String logger, final String receiver) throws InvalidNamedObjectException { super(tag); --- 256,266 ---- /** * This constructor should be used by subclasses of Identity. It creates a Standard Identity document, but doesn't sign it. ! * ! * @param tag The Tag used by this sub class ! * @param allow PublicKey allowed to sign in here ! * @param signer URL of default interactive signing service for namespace. If null it doesnt allow interactive signing ! * @param receiver URL of default receiver for namespace */ ! protected IdentityBuilder(final QName tag, final PublicKey allow, final String signer, final String logger, final String receiver) throws InvalidNamedObjectException { super(tag); *************** *** 265,275 **** addLineBreak(); if (!Utility.isEmpty(signer)) ! addElement("Signer",signer); ! addTarget(logger,"logger"); ! addTarget(receiver,"inbox"); final QName allowName = DocumentHelper.createQName("Allow", NSTools.NS_NEUID); ! Element pub=getElement().element(allowName); ! if (pub==null) pub = getElement().addElement(allowName); else --- 268,278 ---- addLineBreak(); if (!Utility.isEmpty(signer)) ! addElement("Signer", signer); ! addTarget(logger, "logger"); ! addTarget(receiver, "inbox"); final QName allowName = DocumentHelper.createQName("Allow", NSTools.NS_NEUID); ! Element pub = getElement().element(allowName); ! if (pub == null) pub = getElement().addElement(allowName); else *************** *** 280,292 **** } ! private void addTarget(final String href,final String type) { if (!Utility.isEmpty(href)) ! addElement("Target",href).addAttribute("type",type); } - public IdentityBuilder(final PublicKey allow) throws XMLSecurityException, NeuClearException { ! this( allow, null,null,null); } --- 283,294 ---- } ! private void addTarget(final String href, final String type) { if (!Utility.isEmpty(href)) ! addElement("Target", href).addAttribute("type", type); } public IdentityBuilder(final PublicKey allow) throws XMLSecurityException, NeuClearException { ! this(allow, null, null, null); } *************** *** 295,298 **** - } --- 297,299 ---- |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:20:33
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/auth In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11947/src/java/org/neuclear/id/auth Modified Files: AuthenticationServlet.java Log Message: Added simple ledger for unit testing and in memory use Index: AuthenticationServlet.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/auth/AuthenticationServlet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AuthenticationServlet.java 2 Mar 2004 18:59:10 -0000 1.1 --- AuthenticationServlet.java 22 Mar 2004 20:09:43 -0000 1.2 *************** *** 2,31 **** import org.neuclear.commons.NeuClearException; - import org.neuclear.commons.Utility; - import org.neuclear.commons.crypto.signers.*; - import org.neuclear.commons.crypto.passphraseagents.*; - import org.neuclear.commons.crypto.CryptoTools; - import org.neuclear.commons.servlets.ServletTools; import org.neuclear.id.builders.AuthenticationTicketBuilder; - import org.neuclear.id.builders.SignatureRequestBuilder; import org.neuclear.id.builders.Builder; - import org.neuclear.id.resolver.NSResolver; - import org.neuclear.id.Identity; - import org.neuclear.id.InvalidNamedObjectException; - import org.neuclear.xml.XMLException; - import org.neuclear.xml.xmlsec.XMLSecTools; - import org.neuclear.xml.xmlsec.XMLSecurityException; import org.neuclear.id.signers.SignatureRequestServlet; - import javax.servlet.ServletConfig; - import javax.servlet.ServletException; - import javax.servlet.http.Cookie; - import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; - import javax.servlet.http.HttpServletResponse; - import java.io.IOException; - import java.io.PrintWriter; - import java.io.FileNotFoundException; - import java.security.GeneralSecurityException; /* --- 2,10 ---- *************** *** 49,52 **** --- 28,34 ---- $Id$ $Log$ + Revision 1.2 2004/03/22 20:09:43 pelle + Added simple ledger for unit testing and in memory use + Revision 1.1 2004/03/02 18:59:10 pelle Further cleanups in neuclear-id. Moved everything under id. *************** *** 66,71 **** NamedObjectBuilder/SignedNamedObject Pairs. Sample application has been expanded with a basic email application. ! Updated docs for sample web app. ! Added missing LGPL LICENSE.txt files to signer and sample app Revision 1.10 2003/12/15 23:33:04 pelle --- 48,53 ---- NamedObjectBuilder/SignedNamedObject Pairs. Sample application has been expanded with a basic email application. ! Updated docs for simple web app. ! Added missing LGPL LICENSE.txt files to signer and simple app Revision 1.10 2003/12/15 23:33:04 pelle |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:20:17
|
Update of /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9416/src/test/org/neuclear/ledger Modified Files: LedgerTest.java Log Message: Added a verified transfer to neuclear-ledger. Added InsufficientFundsException to be thrown if transfer isnt verified. HeldTransfers also are now verified. Index: LedgerTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/LedgerTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** LedgerTest.java 21 Mar 2004 00:48:36 -0000 1.11 --- LedgerTest.java 22 Mar 2004 17:33:02 -0000 1.12 *************** *** 16,22 **** * $Id$ * $Log$ * Revision 1.11 2004/03/21 00:48:36 pelle * The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. ! * * Revision 1.10 2004/01/02 23:18:35 pelle * Added StatementFactory pattern and refactored the ledger to use it. --- 16,27 ---- * $Id$ * $Log$ + * Revision 1.12 2004/03/22 17:33:02 pelle + * Added a verified transfer to neuclear-ledger. + * Added InsufficientFundsException to be thrown if transfer isnt verified. + * HeldTransfers also are now verified. + * * Revision 1.11 2004/03/21 00:48:36 pelle * The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. ! * <p/> * Revision 1.10 2004/01/02 23:18:35 pelle * Added StatementFactory pattern and refactored the ledger to use it. *************** *** 170,173 **** --- 175,205 ---- } + public final void testVerifiedTransfer() throws LedgerException { + // Need a positive amount in alice's account + if (ledger.getAvailableBalance(ALICE) < 100) + ledger.transfer("MONEY PRESS", ALICE, -ledger.getAvailableBalance(ALICE) + 100, "FUND"); + final double aliceBalance = ledger.getBalance(ALICE); + final double bobBalance = ledger.getBalance(BOB); + final double amount = 100; + + assertTrue("ALICE has a balance of 100 or more", aliceBalance >= 100); + + ledger.verifiedTransfer(ALICE, BOB, amount, "LOAN"); + assertEquals("ALICE BALANCE", aliceBalance - amount, ledger.getBalance(ALICE), 0); + assertEquals("BOB BALANCE", bobBalance + amount, ledger.getBalance(BOB), 0); + + // Now check that it throws InsufficientFundsException + try { + ledger.verifiedTransfer(ALICE, BOB, ledger.getAvailableBalance(ALICE) + 10, "To much"); + assertTrue("InssuficientFundsException should have been thrown", false); + } catch (InsufficientFundsException e) { + ; + } + + + System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); + System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); + } + public final void testMultiTransfer() throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { final double bobBalance = ledger.getBalance(BOB); *************** *** 177,180 **** --- 209,213 ---- cumulative += i; assertEquals("BOB BALANCE", bobBalance + cumulative, ledger.getBalance(BOB), 0); + assertEquals("BOB AVAILABLE BALANCE", ledger.getBalance(BOB), ledger.getAvailableBalance(BOB), 0); } System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); *************** *** 187,190 **** --- 220,225 ---- public final void testHoldAndExpireTransfer() throws LowlevelLedgerException, UnBalancedTransactionException, InvalidTransactionException { + if (ledger.getAvailableBalance(ALICE) < 100) + ledger.transfer("MONEY PRESS", ALICE, -ledger.getAvailableBalance(ALICE) + 100, "FUND"); final double aliceBalance = ledger.getBalance(ALICE); final double bobBalance = ledger.getBalance(BOB); *************** *** 216,222 **** --- 251,261 ---- public final void testHoldAndCancelTransfer() throws LowlevelLedgerException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException { + if (ledger.getAvailableBalance(ALICE) < 100) + ledger.transfer("MONEY PRESS", ALICE, -ledger.getAvailableBalance(ALICE) + 100, "FUND"); final double aliceBalance = ledger.getBalance(ALICE); final double bobBalance = ledger.getBalance(BOB); final double amount = 100; + System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); + System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); PostedHeldTransaction tran = ledger.hold(ALICE, BOB, new Date(System.currentTimeMillis() + 5000), amount, "LOAN"); *************** *** 240,246 **** --- 279,289 ---- public final void testHoldAndCompleteTransfer() throws LowlevelLedgerException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, TransactionExpiredException { + if (ledger.getAvailableBalance(ALICE) < 100) + ledger.transfer("MONEY PRESS", ALICE, -ledger.getAvailableBalance(ALICE) + 100, "FUND"); final double aliceBalance = ledger.getBalance(ALICE); final double bobBalance = ledger.getBalance(BOB); final double amount = 100; + System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); + System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); PostedHeldTransaction tran = ledger.hold(ALICE, BOB, new Date(System.currentTimeMillis() + 5000), amount, "LOAN"); *************** *** 263,266 **** --- 306,330 ---- } + public final void testHoldAndInsufficientFunds() throws LowlevelLedgerException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException { + final double aliceBalance = ledger.getBalance(ALICE); + final double bobBalance = ledger.getBalance(BOB); + final double amount = 100; + System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); + System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); + + // Now check that it throws InsufficientFundsException + try { + ledger.hold(ALICE, BOB, new Date(System.currentTimeMillis() + 5000), ledger.getAvailableBalance(ALICE) + 10, "To much"); + assertTrue("InssuficientFundsException should have been thrown", false); + } catch (InsufficientFundsException e) { + ; + } + + + System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); + System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); + } + + protected Ledger ledger; } |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:20:09
|
Update of /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/id/builders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11947/src/test/org/neuclear/id/builders Modified Files: AuthenticationBuilderTest.java SigningRequestBuilderTest.java Log Message: Added simple ledger for unit testing and in memory use Index: SigningRequestBuilderTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/id/builders/SigningRequestBuilderTest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SigningRequestBuilderTest.java 3 Mar 2004 23:26:45 -0000 1.12 --- SigningRequestBuilderTest.java 22 Mar 2004 20:09:49 -0000 1.13 *************** *** 1,14 **** package org.neuclear.id.builders; - import org.neuclear.id.auth.AuthenticationTicket; import org.neuclear.commons.NeuClearException; - import org.neuclear.commons.crypto.signers.NonExistingSignerException; - import org.neuclear.id.InvalidNamedObjectException; import org.neuclear.id.SignatureRequest; import org.neuclear.id.SignedNamedObject; ! import org.neuclear.id.NameResolutionException; ! import org.neuclear.tests.AbstractSigningTest; import org.neuclear.tests.AbstractObjectCreationTest; - import org.neuclear.xml.XMLException; import java.security.GeneralSecurityException; --- 1,9 ---- package org.neuclear.id.builders; import org.neuclear.commons.NeuClearException; import org.neuclear.id.SignatureRequest; import org.neuclear.id.SignedNamedObject; ! import org.neuclear.id.auth.AuthenticationTicket; import org.neuclear.tests.AbstractObjectCreationTest; import java.security.GeneralSecurityException; *************** *** 34,37 **** --- 29,35 ---- $Id$ $Log$ + Revision 1.13 2004/03/22 20:09:49 pelle + Added simple ledger for unit testing and in memory use + Revision 1.12 2004/03/03 23:26:45 pelle Updated various tests to use the AbstractObjectCreationTest *************** *** 85,89 **** Revision 1.1 2003/11/18 00:01:56 pelle ! The sample signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. --- 83,87 ---- Revision 1.1 2003/11/18 00:01:56 pelle ! The simple signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. *************** *** 100,105 **** } ! protected void verifyObject(SignedNamedObject obj) throws Exception { ! SignatureRequest tosign=(SignatureRequest) obj; assertNotNull(tosign.getUnsigned()); final Builder auth2 = tosign.getUnsigned(); --- 98,103 ---- } ! protected void verifyObject(SignedNamedObject obj) throws Exception { ! SignatureRequest tosign = (SignatureRequest) obj; assertNotNull(tosign.getUnsigned()); final Builder auth2 = tosign.getUnsigned(); *************** *** 107,111 **** assertNotNull(auth2); assertNotNull(auth2.getElement()); ! final AuthenticationTicket auth = (AuthenticationTicket) auth2.convert("neu://bob@test",signer); assertTrue(auth2.isSigned()); // assertEquals(auth.getName(), authreq.getName()); --- 105,109 ---- assertNotNull(auth2); assertNotNull(auth2.getElement()); ! final AuthenticationTicket auth = (AuthenticationTicket) auth2.convert("neu://bob@test", signer); assertTrue(auth2.isSigned()); // assertEquals(auth.getName(), authreq.getName()); *************** *** 120,124 **** protected Builder createBuilder() throws Exception { final AuthenticationTicketBuilder authreq = new AuthenticationTicketBuilder("neu://bob@test", "neu://test", "http://users.neuclear.org:8080"); ! return new SignatureRequestBuilder( "neu://bob@test", authreq, "For testing purposes"); } --- 118,122 ---- protected Builder createBuilder() throws Exception { final AuthenticationTicketBuilder authreq = new AuthenticationTicketBuilder("neu://bob@test", "neu://test", "http://users.neuclear.org:8080"); ! return new SignatureRequestBuilder("neu://bob@test", authreq, "For testing purposes"); } Index: AuthenticationBuilderTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/id/builders/AuthenticationBuilderTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AuthenticationBuilderTest.java 3 Mar 2004 23:26:45 -0000 1.9 --- AuthenticationBuilderTest.java 22 Mar 2004 20:09:49 -0000 1.10 *************** *** 1,12 **** package org.neuclear.id.builders; - import org.neuclear.id.auth.AuthenticationTicket; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.signers.NonExistingSignerException; - import org.neuclear.id.InvalidNamedObjectException; import org.neuclear.id.SignedNamedObject; ! import org.neuclear.tests.AbstractSigningTest; import org.neuclear.tests.AbstractObjectCreationTest; - import org.neuclear.xml.XMLException; import java.security.GeneralSecurityException; --- 1,9 ---- package org.neuclear.id.builders; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.id.SignedNamedObject; ! import org.neuclear.id.auth.AuthenticationTicket; import org.neuclear.tests.AbstractObjectCreationTest; import java.security.GeneralSecurityException; *************** *** 32,35 **** --- 29,35 ---- $Id$ $Log$ + Revision 1.10 2004/03/22 20:09:49 pelle + Added simple ledger for unit testing and in memory use + Revision 1.9 2004/03/03 23:26:45 pelle Updated various tests to use the AbstractObjectCreationTest *************** *** 72,76 **** Revision 1.1 2003/11/18 00:01:56 pelle ! The sample signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. --- 72,76 ---- Revision 1.1 2003/11/18 00:01:56 pelle ! The simple signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. *************** *** 88,92 **** protected void verifyObject(SignedNamedObject obj) throws NonExistingSignerException { ! final AuthenticationTicket auth = (AuthenticationTicket)obj; assertEquals(auth.getSiteHref(), "http://users.neuclear.org:8080"); } --- 88,92 ---- protected void verifyObject(SignedNamedObject obj) throws NonExistingSignerException { ! final AuthenticationTicket auth = (AuthenticationTicket) obj; assertEquals(auth.getSiteHref(), "http://users.neuclear.org:8080"); } |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:20:09
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/verifier In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11947/src/java/org/neuclear/id/verifier Modified Files: VerifyingReader.java Log Message: Added simple ledger for unit testing and in memory use Index: VerifyingReader.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/verifier/VerifyingReader.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** VerifyingReader.java 3 Mar 2004 23:26:43 -0000 1.21 --- VerifyingReader.java 22 Mar 2004 20:09:49 -0000 1.22 *************** *** 2,7 **** import org.dom4j.Element; - import org.neuclear.id.auth.AuthenticationTicket; import org.neuclear.id.*; import org.neuclear.xml.XMLException; import org.neuclear.xml.XMLTools; --- 2,7 ---- import org.dom4j.Element; import org.neuclear.id.*; + import org.neuclear.id.auth.AuthenticationTicket; import org.neuclear.xml.XMLException; import org.neuclear.xml.XMLTools; *************** *** 31,34 **** --- 31,37 ---- $Id$ $Log$ + Revision 1.22 2004/03/22 20:09:49 pelle + Added simple ledger for unit testing and in memory use + Revision 1.21 2004/03/03 23:26:43 pelle Updated various tests to use the AbstractObjectCreationTest *************** *** 61,66 **** NamedObjectBuilder/SignedNamedObject Pairs. Sample application has been expanded with a basic email application. ! Updated docs for sample web app. ! Added missing LGPL LICENSE.txt files to signer and sample app Revision 1.15 2003/12/10 23:58:51 pelle --- 64,69 ---- NamedObjectBuilder/SignedNamedObject Pairs. Sample application has been expanded with a basic email application. ! Updated docs for simple web app. ! Added missing LGPL LICENSE.txt files to signer and simple app Revision 1.15 2003/12/10 23:58:51 pelle *************** *** 107,111 **** Revision 1.9 2003/11/18 00:01:55 pelle ! The sample signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. --- 110,114 ---- Revision 1.9 2003/11/18 00:01:55 pelle ! The simple signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:20:09
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11947/src/java/org/neuclear/id Modified Files: Identity.java SignatureRequest.java Log Message: Added simple ledger for unit testing and in memory use Index: Identity.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/Identity.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Identity.java 18 Feb 2004 00:14:31 -0000 1.30 --- Identity.java 22 Mar 2004 20:09:49 -0000 1.31 *************** *** 2,5 **** --- 2,8 ---- * $Id$ * $Log$ + * Revision 1.31 2004/03/22 20:09:49 pelle + * Added simple ledger for unit testing and in memory use + * * Revision 1.30 2004/02/18 00:14:31 pelle * Many, many clean ups. I've readded Targets in a new method. *************** *** 44,49 **** * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for sample web app. ! * Added missing LGPL LICENSE.txt files to signer and sample app * * Revision 1.23 2003/12/10 23:58:51 pelle --- 47,52 ---- * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for simple web app. ! * Added missing LGPL LICENSE.txt files to signer and simple app * * Revision 1.23 2003/12/10 23:58:51 pelle *************** *** 357,371 **** /** * Constructor for creating an Identity object for a "Nymous" Identity. * @param pub */ ! public Identity(final PublicKey pub){ ! this(new SignedNamedCore(pub),pub,null,null); } ! protected Identity(final SignedNamedCore core, final PublicKey pub,String signer,Targets targets) { super(core); this.pub = pub; ! this.targets=(targets!=null)?targets:Targets.EMPTY; ! this.signer=Utility.denullString(signer,DEFAULT_SIGNER); } --- 360,375 ---- /** * Constructor for creating an Identity object for a "Nymous" Identity. + * * @param pub */ ! public Identity(final PublicKey pub) { ! this(new SignedNamedCore(pub), pub, null, null); } ! protected Identity(final SignedNamedCore core, final PublicKey pub, String signer, Targets targets) { super(core); this.pub = pub; ! this.targets = (targets != null) ? targets : Targets.EMPTY; ! this.signer = Utility.denullString(signer, DEFAULT_SIGNER); } *************** *** 398,402 **** private final PublicKey pub; ! private final Targets targets; private final String signer; --- 402,406 ---- private final PublicKey pub; ! private final Targets targets; private final String signer; *************** *** 410,414 **** * Returns the fixed Root PublicKey */ ! final static synchronized PublicKey getRootPK() { try { if (nsrootpk == null) --- 414,418 ---- * Returns the fixed Root PublicKey */ ! final static synchronized PublicKey getRootPK() { try { if (nsrootpk == null) *************** *** 424,428 **** public NeuClearCertificate(Identity id) { super("NeuClear"); ! this.id=id; } --- 428,432 ---- public NeuClearCertificate(Identity id) { super("NeuClear"); ! this.id = id; } *************** *** 471,474 **** --- 475,479 ---- return getName(); } + private final Identity id; } *************** *** 484,497 **** public final SignedNamedObject read(final SignedNamedCore core, final Element elem) throws InvalidNamedObjectException { ! final Element allowElement = InvalidNamedObjectException.assertContainsElementQName(core,elem,createNEUIDQName("Allow")); try { final KeyInfo ki = new KeyInfo(InvalidNamedObjectException.assertContainsElementQName(allowElement, XMLSecTools.createQName("KeyInfo"))); final PublicKey pub = ki.getPublicKey(); ! final Targets targets=Targets.parseList(elem); ! final Element se=elem.element("Signer"); ! final String signer=(se!=null)?se.getTextTrim():null; ! return new Identity(core, pub,signer,targets); } catch (XMLSecurityException e) { ! throw new InvalidNamedObjectException(core.getName(),e); } } --- 489,502 ---- public final SignedNamedObject read(final SignedNamedCore core, final Element elem) throws InvalidNamedObjectException { ! final Element allowElement = InvalidNamedObjectException.assertContainsElementQName(core, elem, createNEUIDQName("Allow")); try { final KeyInfo ki = new KeyInfo(InvalidNamedObjectException.assertContainsElementQName(allowElement, XMLSecTools.createQName("KeyInfo"))); final PublicKey pub = ki.getPublicKey(); ! final Targets targets = Targets.parseList(elem); ! final Element se = elem.element("Signer"); ! final String signer = (se != null) ? se.getTextTrim() : null; ! return new Identity(core, pub, signer, targets); } catch (XMLSecurityException e) { ! throw new InvalidNamedObjectException(core.getName(), e); } } Index: SignatureRequest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/SignatureRequest.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SignatureRequest.java 18 Feb 2004 00:14:32 -0000 1.14 --- SignatureRequest.java 22 Mar 2004 20:09:49 -0000 1.15 *************** *** 27,30 **** --- 27,33 ---- $Id$ $Log$ + Revision 1.15 2004/03/22 20:09:49 pelle + Added simple ledger for unit testing and in memory use + Revision 1.14 2004/02/18 00:14:32 pelle Many, many clean ups. I've readded Targets in a new method. *************** *** 91,95 **** Revision 1.3 2003/11/18 00:01:55 pelle ! The sample signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. --- 94,98 ---- Revision 1.3 2003/11/18 00:01:55 pelle ! The simple signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. *************** *** 117,121 **** */ public final class SignatureRequest extends SignedNamedObject { ! private SignatureRequest(final SignedNamedCore core, final String userid, final Builder unsigned, final String description) { super(core); this.userid = userid; --- 120,124 ---- */ public final class SignatureRequest extends SignedNamedObject { ! private SignatureRequest(final SignedNamedCore core, final String userid, final Builder unsigned, final String description) { super(core); this.userid = userid; *************** *** 129,133 **** public final Builder getUnsigned() { ! return (Builder) unsigned.clone(); } --- 132,136 ---- public final Builder getUnsigned() { ! return (Builder) unsigned.clone(); } *************** *** 144,150 **** */ public final SignedNamedObject read(final SignedNamedCore core, final Element elem) throws InvalidNamedObjectException { ! InvalidNamedObjectException.assertElementQName(core,elem,createNEUIDQName(SIGREQUEST_TAG)); ! final Element request = InvalidNamedObjectException.assertContainsElementQName(core,elem,createNEUIDQName("Unsigned")); ! final String userid = InvalidNamedObjectException.assertAttributeQName(core,elem,createNEUIDQName("userid")); final Element uelem = ((Element) request.elements().get(0)).createCopy(); final Document doc = DocumentHelper.createDocument(uelem); --- 147,153 ---- */ public final SignedNamedObject read(final SignedNamedCore core, final Element elem) throws InvalidNamedObjectException { ! InvalidNamedObjectException.assertElementQName(core, elem, createNEUIDQName(SIGREQUEST_TAG)); ! final Element request = InvalidNamedObjectException.assertContainsElementQName(core, elem, createNEUIDQName("Unsigned")); ! final String userid = InvalidNamedObjectException.assertAttributeQName(core, elem, createNEUIDQName("userid")); final Element uelem = ((Element) request.elements().get(0)).createCopy(); final Document doc = DocumentHelper.createDocument(uelem); *************** *** 158,162 **** return new SignatureRequest(core, userid, unsigned, description); } catch (XMLSecurityException e) { ! throw new InvalidNamedObjectException(core.getName(),e); } } --- 161,165 ---- return new SignatureRequest(core, userid, unsigned, description); } catch (XMLSecurityException e) { ! throw new InvalidNamedObjectException(core.getName(), e); } } |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:20:08
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/signers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11947/src/java/org/neuclear/id/signers Modified Files: SigningServlet.java Log Message: Added simple ledger for unit testing and in memory use Index: SigningServlet.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/signers/SigningServlet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SigningServlet.java 3 Mar 2004 23:26:43 -0000 1.2 --- SigningServlet.java 22 Mar 2004 20:09:47 -0000 1.3 *************** *** 2,5 **** --- 2,8 ---- * $Id$ * $Log$ + * Revision 1.3 2004/03/22 20:09:47 pelle + * Added simple ledger for unit testing and in memory use + * * Revision 1.2 2004/03/03 23:26:43 pelle * Updated various tests to use the AbstractObjectCreationTest *************** *** 105,109 **** * * Revision 1.12 2003/11/18 00:01:55 pelle ! * The sample signing web application for logging in and out is now working. * There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. * --- 108,112 ---- * * Revision 1.12 2003/11/18 00:01:55 pelle ! * The simple signing web application for logging in and out is now working. * There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. * |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:19:37
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11906/src/java/org/neuclear/xml Modified Files: AbstractElementProxy.java Log Message: Added simple ledger for unit testing and in memory use Index: AbstractElementProxy.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/AbstractElementProxy.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** AbstractElementProxy.java 19 Mar 2004 22:21:51 -0000 1.12 --- AbstractElementProxy.java 22 Mar 2004 20:09:17 -0000 1.13 *************** *** 2,5 **** --- 2,8 ---- * $Id$ * $Log$ + * Revision 1.13 2004/03/22 20:09:17 pelle + * Added simple ledger for unit testing and in memory use + * * Revision 1.12 2004/03/19 22:21:51 pelle * Changes in the XMLSignature class, which is now Abstract there are currently 3 implementations for: *************** *** 29,34 **** * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for sample web app. ! * Added missing LGPL LICENSE.txt files to signer and sample app * * Revision 1.7 2003/12/11 23:56:53 pelle --- 32,37 ---- * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for simple web app. ! * Added missing LGPL LICENSE.txt files to signer and simple app * * Revision 1.7 2003/12/11 23:56:53 pelle |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:19:25
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11773/src/java/org/neuclear/commons/crypto/signers Modified Files: JCESigner.java KeyCache.java TestCaseSigner.java Log Message: Added simple ledger for unit testing and in memory use Index: KeyCache.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/KeyCache.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeyCache.java 21 Nov 2003 04:43:41 -0000 1.2 --- KeyCache.java 22 Mar 2004 20:09:05 -0000 1.3 *************** *** 27,30 **** --- 27,33 ---- $Id$ $Log$ + Revision 1.3 2004/03/22 20:09:05 pelle + Added simple ledger for unit testing and in memory use + Revision 1.2 2003/11/21 04:43:41 pelle EncryptedFileStore now works. It uses the PBECipher with DES3 afair. *************** *** 34,38 **** Revision 1.1 2003/11/18 00:01:02 pelle ! The sample signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. --- 37,41 ---- Revision 1.1 2003/11/18 00:01:02 pelle ! The simple signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. Index: JCESigner.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/JCESigner.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** JCESigner.java 20 Jan 2004 17:38:58 -0000 1.17 --- JCESigner.java 22 Mar 2004 20:09:05 -0000 1.18 *************** *** 2,5 **** --- 2,8 ---- * $Id$ * $Log$ + * Revision 1.18 2004/03/22 20:09:05 pelle + * Added simple ledger for unit testing and in memory use + * * Revision 1.17 2004/01/20 17:38:58 pelle * Further updates to unit tests *************** *** 72,76 **** * * Revision 1.4 2003/11/18 00:01:02 pelle ! * The sample signing web application for logging in and out is now working. * There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. * --- 75,79 ---- * * Revision 1.4 2003/11/18 00:01:02 pelle ! * The simple signing web application for logging in and out is now working. * There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. * *************** *** 176,179 **** --- 179,183 ---- /** * Constructs a JCESigner with the agent providing the keystore passphrase. + * * @param filename * @param type *************** *** 181,192 **** * @param agent * @throws InvalidPassphraseException If the given passphrase is incorrect ! * @throws UserCancellationException If the user choses to cancel the process in the passphrase agent, this should cancel the loading process */ ! public JCESigner(final String filename, final String type, final String provider, final PassPhraseAgent agent) throws UserCancellationException,InvalidPassphraseException { this(filename, createInputStream(filename), type, provider, agent); ! this.filename=filename; } /** * Constructs a JCESigner providing a initial passphrase in the parameters. * @param filename * @param type --- 185,198 ---- * @param agent * @throws InvalidPassphraseException If the given passphrase is incorrect ! * @throws UserCancellationException If the user choses to cancel the process in the passphrase agent, this should cancel the loading process */ ! public JCESigner(final String filename, final String type, final String provider, final PassPhraseAgent agent) throws UserCancellationException, InvalidPassphraseException { this(filename, createInputStream(filename), type, provider, agent); ! this.filename = filename; } + /** * Constructs a JCESigner providing a initial passphrase in the parameters. + * * @param filename * @param type *************** *** 196,212 **** * @throws InvalidPassphraseException If the given passphrase is incorrect */ ! public JCESigner(final String filename, final String type, final String provider, final PassPhraseAgent agent,final char[] initialpassphrase) throws InvalidPassphraseException ! { ! this(filename, createInputStream(filename), type, provider, agent,initialpassphrase); ! this.filename=filename; } /** * The purpose of this method is to either return an InputStream or Null. The reason being that the Keystore accepts null * to create a new KeyStore in memory. * @param filename * @return */ ! private static InputStream createInputStream(final String filename) { if (Utility.isEmpty(filename)) return null; --- 202,219 ---- * @throws InvalidPassphraseException If the given passphrase is incorrect */ ! public JCESigner(final String filename, final String type, final String provider, final PassPhraseAgent agent, final char[] initialpassphrase) throws InvalidPassphraseException { ! this(filename, createInputStream(filename), type, provider, agent, initialpassphrase); ! this.filename = filename; } + /** * The purpose of this method is to either return an InputStream or Null. The reason being that the Keystore accepts null * to create a new KeyStore in memory. + * * @param filename * @return */ ! private static InputStream createInputStream(final String filename) { if (Utility.isEmpty(filename)) return null; *************** *** 224,227 **** --- 231,235 ---- /** * Constructs a JCESigner using the agent to provide the initial passphrase + * * @param name * @param in *************** *** 230,240 **** * @param agent * @throws InvalidPassphraseException If the given passphrase is incorrect ! * @throws UserCancellationException If the user choses to cancel the process in the passphrase agent, this should cancel the loading process */ protected JCESigner(final String name, final InputStream in, final String type, final String provider, final PassPhraseAgent agent) throws UserCancellationException, InvalidPassphraseException { this(loadKeyStore(provider, type, in, agent, name), agent); } /** * Constructs a JCESigner using the provided Initial passphrase to load the keystore * @param name * @param in --- 238,250 ---- * @param agent * @throws InvalidPassphraseException If the given passphrase is incorrect ! * @throws UserCancellationException If the user choses to cancel the process in the passphrase agent, this should cancel the loading process */ protected JCESigner(final String name, final InputStream in, final String type, final String provider, final PassPhraseAgent agent) throws UserCancellationException, InvalidPassphraseException { this(loadKeyStore(provider, type, in, agent, name), agent); } + /** * Constructs a JCESigner using the provided Initial passphrase to load the keystore + * * @param name * @param in *************** *** 245,253 **** * @throws InvalidPassphraseException If the given passphrase is incorrect */ ! protected JCESigner(final String name, final InputStream in, final String type, final String provider, final PassPhraseAgent agent, final char[] initpassphrase) throws InvalidPassphraseException { this(loadKeyStore(provider, type, in, initpassphrase), agent); } /** - * * @param provider * @param type --- 255,263 ---- * @throws InvalidPassphraseException If the given passphrase is incorrect */ ! protected JCESigner(final String name, final InputStream in, final String type, final String provider, final PassPhraseAgent agent, final char[] initpassphrase) throws InvalidPassphraseException { this(loadKeyStore(provider, type, in, initpassphrase), agent); } + /** * @param provider * @param type *************** *** 259,268 **** * @throws UserCancellationException */ ! private static KeyStore loadKeyStore(final String provider, final String type, final InputStream in, final PassPhraseAgent agent, final String name) throws InvalidPassphraseException,UserCancellationException { // System.out.println("Loading JCESigner: "+name); ! return loadKeyStore(provider,type,in,agent.getPassPhrase("Keystore password for: "+name)); } /** - * * @param provider * @param type --- 269,278 ---- * @throws UserCancellationException */ ! private static KeyStore loadKeyStore(final String provider, final String type, final InputStream in, final PassPhraseAgent agent, final String name) throws InvalidPassphraseException, UserCancellationException { // System.out.println("Loading JCESigner: "+name); ! return loadKeyStore(provider, type, in, agent.getPassPhrase("Keystore password for: " + name)); } + /** * @param provider * @param type *************** *** 298,305 **** /** * Creates a signer based on a fully loaded keystore * @param ks * @param agent */ ! public JCESigner(final KeyStore ks, final PassPhraseAgent agent) { this.agent = agent; this.ks = ks; --- 308,316 ---- /** * Creates a signer based on a fully loaded keystore + * * @param ks * @param agent */ ! public JCESigner(final KeyStore ks, final PassPhraseAgent agent) { this.agent = agent; this.ks = ks; *************** *** 327,339 **** public final byte[] sign(final String name, final byte[] data) throws NonExistingSignerException, UserCancellationException { ! return sign(name,data,false); } ! public final byte[] sign(final String name, final byte[] data,boolean incorrect) throws UserCancellationException, NonExistingSignerException { try { ! final char[] pass = getPassPhrase(name,incorrect); return CryptoTools.sign(getKey(name, pass), data); } catch (UnrecoverableKeyException e) { ! System.err.println("Incorrect Passphrase Attemt on: "+name); ! return sign(name,data,true); } catch (NoSuchAlgorithmException e) { throw new LowLevelException(e); --- 338,351 ---- public final byte[] sign(final String name, final byte[] data) throws NonExistingSignerException, UserCancellationException { ! return sign(name, data, false); } ! ! public final byte[] sign(final String name, final byte[] data, boolean incorrect) throws UserCancellationException, NonExistingSignerException { try { ! final char[] pass = getPassPhrase(name, incorrect); return CryptoTools.sign(getKey(name, pass), data); } catch (UnrecoverableKeyException e) { ! System.err.println("Incorrect Passphrase Attemt on: " + name); ! return sign(name, data, true); } catch (NoSuchAlgorithmException e) { throw new LowLevelException(e); *************** *** 346,356 **** } ! private char[] getPassPhrase(final String name,boolean incorrect) throws UserCancellationException { ! if (incorrect&&(agent instanceof InteractiveAgent)) ! ((InteractiveAgent)agent).getPassPhrase(name,true); return agent.getPassPhrase(name); } ! public final boolean canSignFor(final String name) { try { return ks.containsAlias(name); --- 358,368 ---- } ! private char[] getPassPhrase(final String name, boolean incorrect) throws UserCancellationException { ! if (incorrect && (agent instanceof InteractiveAgent)) ! ((InteractiveAgent) agent).getPassPhrase(name, true); return agent.getPassPhrase(name); } ! public final boolean canSignFor(final String name) { try { return ks.containsAlias(name); *************** *** 360,364 **** } ! public final int getKeyType(final String name) { try { if (ks.isKeyEntry(name)) { --- 372,376 ---- } ! public final int getKeyType(final String name) { try { if (ks.isKeyEntry(name)) { *************** *** 382,386 **** try { final KeyPair kp = kpg.generateKeyPair(); ! ks.setKeyEntry(alias, kp.getPrivate(), agent.getPassPhrase(alias), new Certificate[]{CryptoTools.createCertificate(alias,kp)}); return kp.getPublic(); } catch (KeyStoreException e) { --- 394,398 ---- try { final KeyPair kp = kpg.generateKeyPair(); ! ks.setKeyEntry(alias, kp.getPrivate(), agent.getPassPhrase(alias), new Certificate[]{CryptoTools.createCertificate(alias, kp)}); return kp.getPublic(); } catch (KeyStoreException e) { *************** *** 396,404 **** try { final Certificate certificate = ks.getCertificate(name); ! if (certificate==null) throw new NonExistingSignerException(name); ! PublicKey pub= certificate.getPublicKey(); ! if (pub==null) throw new NonExistingSignerException(name); return pub; --- 408,416 ---- try { final Certificate certificate = ks.getCertificate(name); ! if (certificate == null) throw new NonExistingSignerException(name); ! PublicKey pub = certificate.getPublicKey(); ! if (pub == null) throw new NonExistingSignerException(name); return pub; *************** *** 416,430 **** } } ! public synchronized final void save(String filename) throws FileNotFoundException{ if (Utility.isEmpty(filename)) throw new FileNotFoundException("no keystore filename"); try { ! File ksfile=new File(filename); ksfile.getParentFile().mkdirs(); ! ks.store(new FileOutputStream(ksfile),agent.getPassPhrase(filename)); } catch (Exception e) { throw new LowLevelException(e); } } private final KeyStore ks; private final KeyCache cache; --- 428,444 ---- } } ! ! public synchronized final void save(String filename) throws FileNotFoundException { if (Utility.isEmpty(filename)) throw new FileNotFoundException("no keystore filename"); try { ! File ksfile = new File(filename); ksfile.getParentFile().mkdirs(); ! ks.store(new FileOutputStream(ksfile), agent.getPassPhrase(filename)); } catch (Exception e) { throw new LowLevelException(e); } } + private final KeyStore ks; private final KeyCache cache; Index: TestCaseSigner.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/TestCaseSigner.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TestCaseSigner.java 19 Jan 2004 17:53:14 -0000 1.10 --- TestCaseSigner.java 22 Mar 2004 20:09:05 -0000 1.11 *************** *** 27,30 **** --- 27,33 ---- $Id$ $Log$ + Revision 1.11 2004/03/22 20:09:05 pelle + Added simple ledger for unit testing and in memory use + Revision 1.10 2004/01/19 17:53:14 pelle Various clean ups *************** *** 62,66 **** Revision 1.3 2003/11/18 00:01:02 pelle ! The sample signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. --- 65,69 ---- Revision 1.3 2003/11/18 00:01:02 pelle ! The simple signing web application for logging in and out is now working. There had been an issue in the canonicalizer when dealing with the embedded object of the SignatureRequest object. *************** *** 89,93 **** */ public TestCaseSigner() throws InvalidPassphraseException { ! this(KEYSTORE, getKeyStore(), "neuclear"); } --- 92,96 ---- */ public TestCaseSigner() throws InvalidPassphraseException { ! this(KEYSTORE, getKeyStore(), "neuclear"); } *************** *** 100,109 **** * be a SUN JKS format file and the passphrase for the keystore and all * keys must be the same. ! * * @param in InputStream * @param passphrase The passphrase to use * @throws InvalidPassphraseException */ ! public TestCaseSigner(final String name, final InputStream in, final String passphrase) throws InvalidPassphraseException { this(name, in, new AlwaysTheSamePassphraseAgent(passphrase)); } --- 103,112 ---- * be a SUN JKS format file and the passphrase for the keystore and all * keys must be the same. ! * * @param in InputStream * @param passphrase The passphrase to use * @throws InvalidPassphraseException */ ! public TestCaseSigner(final String name, final InputStream in, final String passphrase) throws InvalidPassphraseException { this(name, in, new AlwaysTheSamePassphraseAgent(passphrase)); } *************** *** 114,119 **** "jks", "SUN", agent, ! "neuclear".toCharArray() ! ); } --- 117,121 ---- "jks", "SUN", agent, ! "neuclear".toCharArray()); } |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:19:25
|
Update of /cvsroot/neuclear/neuclear-commons/src/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11773/src/java Modified Files: neuclear-ledger.properties neuclear-sql.properties Log Message: Added simple ledger for unit testing and in memory use Index: neuclear-ledger.properties =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/neuclear-ledger.properties,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** neuclear-ledger.properties 3 Dec 2003 23:22:06 -0000 1.2 --- neuclear-ledger.properties 22 Mar 2004 20:09:05 -0000 1.3 *************** *** 1,4 **** ledger.name=SuperBux ! ledger.class=org.neuclear.ledger.implementations.SQLLedger jndi.name=jdbc/DefaultDs jdbc.class=org.hsqldb.jdbcDriver --- 1,4 ---- ledger.name=SuperBux ! ledger.class=org.neuclear.ledger.sql.SQLLedger jndi.name=jdbc/DefaultDs jdbc.class=org.hsqldb.jdbcDriver Index: neuclear-sql.properties =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/neuclear-sql.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** neuclear-sql.properties 3 Dec 2003 23:22:06 -0000 1.1 --- neuclear-sql.properties 22 Mar 2004 20:09:05 -0000 1.2 *************** *** 1,4 **** ledger.name=SuperBux ! ledger.class=org.neuclear.ledger.implementations.SQLLedger jndi.name=jdbc/DefaultDS jdbc.class=org.hsqldb.jdbcDriver --- 1,4 ---- ledger.name=SuperBux ! ledger.class=org.neuclear.ledger.sql.SQLLedger jndi.name=jdbc/DefaultDS jdbc.class=org.hsqldb.jdbcDriver |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:19:25
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/servlets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11773/src/java/org/neuclear/commons/servlets Modified Files: ServletTools.java Log Message: Added simple ledger for unit testing and in memory use Index: ServletTools.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/servlets/ServletTools.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ServletTools.java 2 Mar 2004 18:58:44 -0000 1.8 --- ServletTools.java 22 Mar 2004 20:09:05 -0000 1.9 *************** *** 1,4 **** --- 1,7 ---- /* $Id$ * $Log$ + * Revision 1.9 2004/03/22 20:09:05 pelle + * Added simple ledger for unit testing and in memory use + * * Revision 1.8 2004/03/02 18:58:44 pelle * Further cleanups in neuclear-id. Moved everything under id. *************** *** 16,21 **** * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for sample web app. ! * Added missing LGPL LICENSE.txt files to signer and sample app * * Revision 1.4 2003/12/15 23:32:40 pelle --- 19,24 ---- * NamedObjectBuilder/SignedNamedObject Pairs. * Sample application has been expanded with a basic email application. ! * Updated docs for simple web app. ! * Added missing LGPL LICENSE.txt files to signer and simple app * * Revision 1.4 2003/12/15 23:32:40 pelle |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:19:06
|
Update of /cvsroot/neuclear/neuclear-ledger-prevalent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11732 Modified Files: project.properties project.xml Log Message: Added simple ledger for unit testing and in memory use Index: project.properties =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-prevalent/project.properties,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** project.properties 22 Mar 2004 17:27:10 -0000 1.1.1.1 --- project.properties 22 Mar 2004 20:08:46 -0000 1.2 *************** *** 2,6 **** # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- ! maven.test.skip=true maven.compile.debug = on --- 2,6 ---- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- ! maven.test.skip=false maven.compile.debug = on Index: project.xml =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-prevalent/project.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** project.xml 22 Mar 2004 17:27:08 -0000 1.1.1.1 --- project.xml 22 Mar 2004 20:08:46 -0000 1.2 *************** *** 1,115 **** <?xml version="1.0"?> <project> ! <name>Prevalent NeuClear Ledger</name> ! <id>neuclear-ledger-prevalent</id> ! <currentVersion>0.4-SNAPSHOT</currentVersion> ! <inceptionYear>2003</inceptionYear> ! <package>org.neuclear.ledger.prevalent</package> ! <logo>/images/logo.gif</logo> ! <shortDescription>NeuClear Ledger prevalent Implementation</shortDescription> ! <organization> ! <name>Antilles Software Ventures SA</name> ! <url>http://neubia.com/</url> ! </organization> ! <description> Generalised Java API for Ledger like Applications. ! </description> ! <url>http://neuclear.org/ledger/</url> <repository> ! <connection> scm:cvs:pserver:ano...@cv...:/cvsroot/neuclear:neuclear-ledger-prevalent ! </connection> ! <url> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/neuclear/neuclear-ledger-prevalent/ ! </url> ! </repository> ! <siteAddress>neuclear.org</siteAddress> ! <siteDirectory>/home/sites/neuclear.org/public_html/ledger/</siteDirectory> ! <issueTrackingUrl>http://jira.neuclear.org</issueTrackingUrl> ! <mailingLists> ! <mailingList> ! <name>NeuClear Announce</name> ! <subscribe>http://lists.sourceforge.net/lists/listinfo/neuclear-announce</subscribe> ! <unsubscribe>http://lists.sourceforge.net/lists/listinfo/neuclear-announce</unsubscribe> ! <archive>http://www.geocrawler.com/redir-sf.php3?list=neuclear-announce</archive> ! </mailingList> ! <mailingList> ! <name>NeuClear Discuss</name> ! <subscribe>http://lists.sourceforge.net/lists/listinfo/neuclear-discuss</subscribe> ! <unsubscribe>http://lists.sourceforge.net/lists/listinfo/neuclear-discuss</unsubscribe> ! <archive>http://www.geocrawler.com/redir-sf.php3?list=neuclear-discuss</archive> ! </mailingList> ! </mailingLists> ! <developers> ! <developer> ! <name>Pelle Braendgaard</name> ! <id>pelle</id> ! <email>pe...@ne...</email> ! <organization>Antilles Software Ventures SA</organization> ! </developer> ! </developers> ! <!-- Need to mark these as compile-time/run-time --> ! <dependencies> ! <dependency> ! <id>neuclear-ledger</id> ! <version>0.4-SNAPSHOT</version> ! </dependency> ! ! <dependency> ! <id>neuclear-commons</id> ! <version>0.6-SNAPSHOT</version> <properties> <war.bundle>true</war.bundle> </properties> ! </dependency> ! <dependency> ! <id>junit</id> ! <name>junit</name> ! <version>3.8.1</version> </dependency> ! </dependencies> ! <build> ! <!-- <sourceDirectories>--> ! <sourceDirectory>src/java</sourceDirectory> ! <!-- </sourceDirectories>--> ! <unitTestSourceDirectory>src/test</unitTestSourceDirectory> ! <integrationUnitTestSourceDirectory/> ! <aspectSourceDirectory/> ! <!-- Unit test cases --> ! <unitTest> ! <includes> ! <include>**/*Test.java</include> ! </includes> ! <excludes> ! <exclude>**/LedgerTest.java</exclude> ! </excludes> ! </unitTest> ! <resources> ! <resource> ! <directory> src/java ! </directory> ! <includes>*.jks</includes> ! <includes>*.xml</includes> ! <!-- <targetPath>org/neuclear/commons/crypto/signers</targetPath>--> ! </resource> ! </resources> ! </build> </project> --- 1,119 ---- <?xml version="1.0"?> <project> ! <name>Prevalent NeuClear Ledger</name> ! <id>neuclear-ledger-prevalent</id> ! <currentVersion>0.4-SNAPSHOT</currentVersion> ! <inceptionYear>2003</inceptionYear> ! <package>org.neuclear.ledger.prevalent</package> ! <logo>/images/logo.gif</logo> ! <shortDescription>NeuClear Ledger prevalent Implementation</shortDescription> ! <organization> ! <name>Antilles Software Ventures SA</name> ! <url>http://neubia.com/</url> ! </organization> ! <description> Generalised Java API for Ledger like Applications. ! </description> ! <url>http://neuclear.org/ledger/prevalent/</url> <repository> ! <connection> scm:cvs:pserver:ano...@cv...:/cvsroot/neuclear:neuclear-ledger-prevalent ! </connection> ! <url> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/neuclear/neuclear-ledger-prevalent/ ! </url> ! </repository> ! <siteAddress>old.neuclear.org</siteAddress> ! <siteDirectory>/home/sites/neuclear.org/public_html/ledger/prevalent/</siteDirectory> ! <issueTrackingUrl>http://jira.neuclear.org</issueTrackingUrl> ! <mailingLists> ! <mailingList> ! <name>NeuClear Announce</name> ! <subscribe>http://lists.sourceforge.net/lists/listinfo/neuclear-announce</subscribe> ! <unsubscribe>http://lists.sourceforge.net/lists/listinfo/neuclear-announce</unsubscribe> ! <archive>http://www.geocrawler.com/redir-sf.php3?list=neuclear-announce</archive> ! </mailingList> ! <mailingList> ! <name>NeuClear Discuss</name> ! <subscribe>http://lists.sourceforge.net/lists/listinfo/neuclear-discuss</subscribe> ! <unsubscribe>http://lists.sourceforge.net/lists/listinfo/neuclear-discuss</unsubscribe> ! <archive>http://www.geocrawler.com/redir-sf.php3?list=neuclear-discuss</archive> ! </mailingList> ! </mailingLists> ! <developers> ! <developer> ! <name>Pelle Braendgaard</name> ! <id>pelle</id> ! <email>pe...@ne...</email> ! <organization>Antilles Software Ventures SA</organization> ! </developer> ! </developers> ! <!-- Need to mark these as compile-time/run-time --> ! <dependencies> ! <dependency> ! <id>neuclear-ledger</id> ! <version>0.4-SNAPSHOT</version> ! </dependency> ! ! <dependency> ! <id>neuclear-commons</id> ! <version>0.6-SNAPSHOT</version> <properties> <war.bundle>true</war.bundle> </properties> ! </dependency> ! <dependency> ! <id>junit</id> ! <name>junit</name> ! <version>3.8.1</version> ! </dependency> ! <dependency> ! <id>prevayler</id> ! <name>prevayler</name> ! <version>2.0.1.000alpha</version> ! <jar>prevayler2.01.000alpha.jar</jar> </dependency> ! </dependencies> ! <build> ! <!-- <sourceDirectories>--> ! <sourceDirectory>src/java</sourceDirectory> ! <!-- </sourceDirectories>--> ! <unitTestSourceDirectory>src/test</unitTestSourceDirectory> ! <integrationUnitTestSourceDirectory/> ! <aspectSourceDirectory/> ! <!-- Unit test cases --> ! <unitTest> ! <includes> ! <include>**/*Test.java</include> ! </includes> ! <excludes> ! <exclude>**/LedgerTest.java</exclude> ! </excludes> ! </unitTest> ! <resources> ! <resource> ! <directory> src/java ! </directory> ! <includes>*.xml</includes> ! </resource> ! </resources> ! </build> </project> |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:19:06
|
Update of /cvsroot/neuclear/neuclear-ledger-prevalent/src/test/org/neuclear/ledger/prevalent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11732/src/test/org/neuclear/ledger/prevalent Modified Files: PrevalentLedgerTest.java Log Message: Added simple ledger for unit testing and in memory use Index: PrevalentLedgerTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-prevalent/src/test/org/neuclear/ledger/prevalent/PrevalentLedgerTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PrevalentLedgerTest.java 22 Mar 2004 17:27:16 -0000 1.1.1.1 --- PrevalentLedgerTest.java 22 Mar 2004 20:08:46 -0000 1.2 *************** *** 1,13 **** package org.neuclear.ledger.prevalent; ! import org.neuclear.ledger.LedgerTest; import org.neuclear.ledger.Ledger; import org.neuclear.ledger.LowlevelLedgerException; import org.neuclear.ledger.UnknownLedgerException; - import org.neuclear.commons.NeuClearException; import javax.naming.NamingException; - import java.sql.SQLException; import java.io.IOException; /** --- 1,13 ---- package org.neuclear.ledger.prevalent; ! import org.neuclear.commons.NeuClearException; ! import org.neuclear.ledger.AbstractLedgerTest; import org.neuclear.ledger.Ledger; import org.neuclear.ledger.LowlevelLedgerException; import org.neuclear.ledger.UnknownLedgerException; import javax.naming.NamingException; import java.io.IOException; + import java.sql.SQLException; /** *************** *** 18,22 **** * To change this template use File | Settings | File Templates. */ ! public class PrevalentLedgerTest extends LedgerTest { public PrevalentLedgerTest(String s) throws LowlevelLedgerException, UnknownLedgerException, SQLException, NamingException, IOException, NeuClearException { super(s); --- 18,22 ---- * To change this template use File | Settings | File Templates. */ ! public class PrevalentLedgerTest extends AbstractLedgerTest { public PrevalentLedgerTest(String s) throws LowlevelLedgerException, UnknownLedgerException, SQLException, NamingException, IOException, NeuClearException { super(s); *************** *** 25,29 **** public Ledger createLedger() throws LowlevelLedgerException { try { ! return new PrevalentLedger("test","target/test-data/ledger/"); } catch (IOException e) { throw new LowlevelLedgerException(e); --- 25,29 ---- public Ledger createLedger() throws LowlevelLedgerException { try { ! return new PrevalentLedger("test", "target/test-data/ledger/"); } catch (IOException e) { throw new LowlevelLedgerException(e); |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:18:54
|
Update of /cvsroot/neuclear/neuclear-pay/src/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11691/src/java Modified Files: neuclear-pay.xml Log Message: Added simple ledger for unit testing and in memory use Index: neuclear-pay.xml =================================================================== RCS file: /cvsroot/neuclear/neuclear-pay/src/java/neuclear-pay.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** neuclear-pay.xml 11 Nov 2003 21:17:19 -0000 1.5 --- neuclear-pay.xml 22 Mar 2004 20:08:35 -0000 1.6 *************** *** 1,5 **** <components> <component type="org.neuclear.commons.sql.ConnectionSource" class="org.neuclear.commons.sql.DefaultConnectionSource"/> ! <component type="org.neuclear.ledger.Ledger" class="org.neuclear.ledger.implementations.SQLLedger"> <param type="java.lang.String">neu://superbux/reserve</param> </component> --- 1,5 ---- <components> <component type="org.neuclear.commons.sql.ConnectionSource" class="org.neuclear.commons.sql.DefaultConnectionSource"/> ! <component type="org.neuclear.ledger.Ledger" class="org.neuclear.ledger.sql.SQLLedger"> <param type="java.lang.String">neu://superbux/reserve</param> </component> |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:18:44
|
Update of /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11636/src/test/org/neuclear/ledger Added Files: AbstractLedgerTest.java SimpleLedgerTest.java Removed Files: LedgerTest.java SQLLedgerTest.java Log Message: Added simple ledger for unit testing and in memory use --- LedgerTest.java DELETED --- --- SQLLedgerTest.java DELETED --- --- NEW FILE: AbstractLedgerTest.java --- package org.neuclear.ledger; import junit.framework.TestCase; import org.neuclear.commons.NeuClearException; import javax.naming.NamingException; import java.io.IOException; import java.sql.SQLException; import java.util.Date; /** * (C) 2003 Antilles Software Ventures SA * User: pelleb * Date: Jan 22, 2003 * Time: 4:18:35 PM * $Id: AbstractLedgerTest.java,v 1.1 2004/03/22 20:08:24 pelle Exp $ * $Log: AbstractLedgerTest.java,v $ * Revision 1.1 2004/03/22 20:08:24 pelle * Added simple ledger for unit testing and in memory use * * Revision 1.12 2004/03/22 17:33:02 pelle * Added a verified transfer to neuclear-ledger. * Added InsufficientFundsException to be thrown if transfer isnt verified. * HeldTransfers also are now verified. * <p/> * Revision 1.11 2004/03/21 00:48:36 pelle * The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. * <p/> * Revision 1.10 2004/01/02 23:18:35 pelle * Added StatementFactory pattern and refactored the ledger to use it. * <p/> * Revision 1.9 2003/12/31 00:39:05 pelle * Added Drivers for handling different Database dialects in the entity model. * Added BookBrowser pattern to ledger, simplifying the statement writing process. * <p/> * Revision 1.8 2003/12/26 22:50:52 pelle * Mainly fixes to SQLLedger to support the schema generated by the new EntityModel * <p/> * Revision 1.7 2003/12/24 00:24:33 pelle * Created a kind of poor man's version of ofbiz.org's EntityEngine. It doesnt use xml to configure it, but code. * Should mainly be used to create tables. Can also insert rows, but hasnt been thoroughly tested. * At some point I will improve that part and add some kind of smart querying engine to it. Similar to EntityEngine. But I dont * need that myself right now. * SQLLedger now uses this to create its tables. It is not fully working yet, but will be shortly. * <p/> * Revision 1.6 2003/12/03 23:21:43 pelle * Got rid of ofbiz support. Way over the top for our use. * <p/> * Revision 1.5 2003/11/21 04:43:21 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). * <p/> * Revision 1.4 2003/11/11 21:17:32 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. * <p/> * Revision 1.3 2003/10/29 21:15:13 pelle * Refactored the whole signing process. Now we have an interface called Signer which is the old SignerStore. * To use it you pass a byte array and an alias. The sign method then returns the signature. * If a Signer needs a passphrase it uses a PassPhraseAgent to present a dialogue box, read it from a command line etc. * This new Signer pattern allows us to use secure signing hardware such as N-Cipher in the future for server applications as well * as SmartCards for end user applications. * <p/> * Revision 1.2 2003/10/28 23:43:15 pelle * The GuiDialogAgent now works. It simply presents itself as a simple modal dialog box asking for a passphrase. * The two Signer implementations both use it for the passphrase. * <p/> * Revision 1.1.1.1 2003/09/20 23:16:21 pelle * First revision of neuclear-ledger in /cvsroot/neuclear * Older versions can be found /cvsroot/neuclear * <p/> * Revision 1.15 2003/08/08 23:05:12 pelle * Updated to use PicoContainer. * This will be made more elegant as we go along. * <p/> * Revision 1.14 2003/08/06 19:16:32 pelle * Updated various missing items. * <p/> * Revision 1.13 2003/08/06 16:41:22 pelle * Fixed a few implementation bugs with regards to the Held Transactions * <p/> * Revision 1.12 2003/08/01 21:59:47 pelle * More changes to the way helds are managed. * <p/> * Revision 1.11 2003/07/30 16:27:55 pelle * Final fixes for unit tests. * Renamed implementHeld() => complete() * Had to override reverse() to make complete work. * Note: had to "fix" a unit test to make SimpleLedger pass * I dont have time to fix it at the moment. I suspect its simple. * <p/> * Revision 1.10 2003/07/29 22:57:50 pelle * New version with refactored support for HeldTransactions. * Please note that this causes a sql exception when adding held_item rows. * <p/> * Revision 1.9 2003/07/28 21:29:15 pelle * Changed a few things in the LedgerFactory. * Still not quite there yet. * <p/> * Revision 1.8 2003/07/23 17:19:26 pelle * Ledgers now have a required display name. * <p/> * Revision 1.7 2003/07/21 19:43:39 pelle * Moved the Revisioning tests into the main AbstractLedgerTest. * Fixed the getTransactionTime method in SQLLedger. * <p/> * Revision 1.6 2003/07/21 18:35:15 pelle * Completed Exception handling refactoring * <p/> * Revision 1.5 2003/07/21 17:47:37 pelle * Held transactions now work in SQL * <p/> * Revision 1.4 2003/07/18 20:27:39 pelle * *** empty log message *** * <p/> * Revision 1.3 2003/07/17 22:33:57 pelle * Fixed various problems. Lets see how we do. I waiting for the autoincrement to work on the entries. * <p/> * Revision 1.2 2003/07/16 18:08:49 pelle * Adding the first parts of sql support. * <p/> * Revision 1.1 2003/01/25 19:14:47 pelle * The ridiculously simple SimpleLedger now passes initial test. * I've split the Transaction Class into two sub classes and made Transaction abstract. * The two new Transaction Classes reflect the state of the Transaction and their methods reflect this. */ public abstract class AbstractLedgerTest extends TestCase { static final String BOB = "bob"; static final String ALICE = "alice"; public AbstractLedgerTest(final String s) throws LowlevelLedgerException, UnknownLedgerException, SQLException, NamingException, IOException, NeuClearException { super(s); // ledger=createLedger(); } // protected void finalize() throws Throwable { // ledger.close(); // } // /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. */ protected void setUp() throws Exception { ledger = createLedger(); } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. */ protected void tearDown() throws Exception { ledger.close(); } public abstract Ledger createLedger() throws LowlevelLedgerException, UnknownLedgerException; public final void testTransfer() throws LedgerException { final double aliceBalance = ledger.getBalance(ALICE); final double bobBalance = ledger.getBalance(BOB); final double amount = 100; ledger.transfer(ALICE, BOB, amount, "LOAN"); assertEquals("ALICE BALANCE", aliceBalance - amount, ledger.getBalance(ALICE), 0); assertEquals("BOB BALANCE", bobBalance + amount, ledger.getBalance(BOB), 0); ledger.transfer(BOB, ALICE, amount, "Repayment"); assertEquals("REPAY ALICE BALANCE", aliceBalance, ledger.getBalance(ALICE), 0); assertEquals("REPAY BOB BALANCE", bobBalance, ledger.getBalance(BOB), 0); ledger.transfer(BOB, ALICE, 5, "Interest"); System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } public final void testVerifiedTransfer() throws LedgerException { // Need a positive amount in alice's account if (ledger.getAvailableBalance(ALICE) < 100) ledger.transfer("MONEY PRESS", ALICE, -ledger.getAvailableBalance(ALICE) + 100, "FUND"); final double aliceBalance = ledger.getBalance(ALICE); final double bobBalance = ledger.getBalance(BOB); final double amount = 100; assertTrue("ALICE has a balance of 100 or more", aliceBalance >= 100); ledger.verifiedTransfer(ALICE, BOB, amount, "LOAN"); assertEquals("ALICE BALANCE", aliceBalance - amount, ledger.getBalance(ALICE), 0); assertEquals("BOB BALANCE", bobBalance + amount, ledger.getBalance(BOB), 0); // Now check that it throws InsufficientFundsException try { ledger.verifiedTransfer(ALICE, BOB, ledger.getAvailableBalance(ALICE) + 10, "To much"); assertTrue("InssuficientFundsException should have been thrown", false); } catch (InsufficientFundsException e) { ; } System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } public final void testMultiTransfer() throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { final double bobBalance = ledger.getBalance(BOB); int cumulative = 0; for (int i = 0; i < 100; i++) { ledger.transfer("req" + i + System.currentTimeMillis(), "x" + i + System.currentTimeMillis(), "Issuer", "bob", i, "fund it"); cumulative += i; assertEquals("BOB BALANCE", bobBalance + cumulative, ledger.getBalance(BOB), 0); assertEquals("BOB AVAILABLE BALANCE", ledger.getBalance(BOB), ledger.getAvailableBalance(BOB), 0); } System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } public final void testBalance() throws LedgerException { System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } public final void testHoldAndExpireTransfer() throws LowlevelLedgerException, UnBalancedTransactionException, InvalidTransactionException { if (ledger.getAvailableBalance(ALICE) < 100) ledger.transfer("MONEY PRESS", ALICE, -ledger.getAvailableBalance(ALICE) + 100, "FUND"); final double aliceBalance = ledger.getBalance(ALICE); final double bobBalance = ledger.getBalance(BOB); final double amount = 100; System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); ledger.hold(ALICE, BOB, new Date(System.currentTimeMillis() + 5000), amount, "LOAN"); assertEquals("ALICE BALANCE", aliceBalance, ledger.getBalance(ALICE), 0); assertEquals("BOB BALANCE", bobBalance, ledger.getBalance(BOB), 0); assertEquals("ALICE Available BALANCE", aliceBalance - amount, ledger.getAvailableBalance(ALICE), 0); assertEquals("BOB Available BALANCE", bobBalance, ledger.getAvailableBalance(BOB), 0); try { Thread.currentThread().sleep(5000); } catch (InterruptedException e) { ; } assertEquals("ALICE BALANCE EXPIRED", aliceBalance, ledger.getBalance(ALICE), 0); assertEquals("BOB BALANCE EXPIRED", bobBalance, ledger.getBalance(BOB), 0); assertEquals("ALICE Available BALANCE EXPIRED", aliceBalance, ledger.getAvailableBalance(ALICE), 0); assertEquals("BOB Available BALANCE EXPIRED", bobBalance, ledger.getAvailableBalance(BOB), 0); System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } public final void testHoldAndCancelTransfer() throws LowlevelLedgerException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException { if (ledger.getAvailableBalance(ALICE) < 100) ledger.transfer("MONEY PRESS", ALICE, -ledger.getAvailableBalance(ALICE) + 100, "FUND"); final double aliceBalance = ledger.getBalance(ALICE); final double bobBalance = ledger.getBalance(BOB); final double amount = 100; System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); PostedHeldTransaction tran = ledger.hold(ALICE, BOB, new Date(System.currentTimeMillis() + 5000), amount, "LOAN"); assertEquals("ALICE BALANCE", aliceBalance, ledger.getBalance(ALICE), 0); assertEquals("BOB BALANCE", bobBalance, ledger.getBalance(BOB), 0); assertEquals("ALICE Available BALANCE", aliceBalance - amount, ledger.getAvailableBalance(ALICE), 0); assertEquals("BOB Available BALANCE", bobBalance, ledger.getAvailableBalance(BOB), 0); ledger.performCancelHold(tran); assertEquals("ALICE BALANCE CANCELLED", aliceBalance, ledger.getBalance(ALICE), 0); assertEquals("BOB BALANCE CANCELLED", bobBalance, ledger.getBalance(BOB), 0); assertEquals("ALICE Available BALANCE CANCELLED", aliceBalance, ledger.getAvailableBalance(ALICE), 0); assertEquals("BOB Available BALANCE CANCELLED", bobBalance, ledger.getAvailableBalance(BOB), 0); System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } public final void testHoldAndCompleteTransfer() throws LowlevelLedgerException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, TransactionExpiredException { if (ledger.getAvailableBalance(ALICE) < 100) ledger.transfer("MONEY PRESS", ALICE, -ledger.getAvailableBalance(ALICE) + 100, "FUND"); final double aliceBalance = ledger.getBalance(ALICE); final double bobBalance = ledger.getBalance(BOB); final double amount = 100; System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); PostedHeldTransaction tran = ledger.hold(ALICE, BOB, new Date(System.currentTimeMillis() + 5000), amount, "LOAN"); assertEquals("ALICE BALANCE", aliceBalance, ledger.getBalance(ALICE), 0); assertEquals("BOB BALANCE", bobBalance, ledger.getBalance(BOB), 0); assertEquals("ALICE Available BALANCE", aliceBalance - amount, ledger.getAvailableBalance(ALICE), 0); assertEquals("BOB Available BALANCE", bobBalance, ledger.getAvailableBalance(BOB), 0); ledger.performCompleteHold(tran, 100, "done"); assertEquals("ALICE BALANCE CANCELLED", aliceBalance - amount, ledger.getBalance(ALICE), 0); assertEquals("BOB BALANCE CANCELLED", bobBalance + amount, ledger.getBalance(BOB), 0); assertEquals("ALICE Available BALANCE CANCELLED", aliceBalance - amount, ledger.getAvailableBalance(ALICE), 0); assertEquals("BOB Available BALANCE CANCELLED", bobBalance + amount, ledger.getAvailableBalance(BOB), 0); System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } public final void testHoldAndInsufficientFunds() throws LowlevelLedgerException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException { final double aliceBalance = ledger.getBalance(ALICE); final double bobBalance = ledger.getBalance(BOB); final double amount = 100; System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); // Now check that it throws InsufficientFundsException try { ledger.hold(ALICE, BOB, new Date(System.currentTimeMillis() + 5000), ledger.getAvailableBalance(ALICE) + 10, "To much"); assertTrue("InssuficientFundsException should have been thrown", false); } catch (InsufficientFundsException e) { ; } System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } protected Ledger ledger; } --- NEW FILE: SimpleLedgerTest.java --- package org.neuclear.ledger; import org.neuclear.commons.NeuClearException; import org.neuclear.ledger.simple.SimpleLedger; import javax.naming.NamingException; import java.io.IOException; import java.sql.SQLException; /** * Created by IntelliJ IDEA. * User: pelleb * Date: Jul 16, 2003 * Time: 12:58:30 PM * To change this template use Options | File Templates. */ public final class SimpleLedgerTest extends AbstractLedgerTest { public SimpleLedgerTest(final String s) throws LowlevelLedgerException, UnknownLedgerException, SQLException, NamingException, IOException, NeuClearException { super(s); } public final Ledger createLedger() { return new SimpleLedger("test"); } } |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:18:43
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11636/src/java/org/neuclear/ledger/simple Added Files: SimpleLedger.java Log Message: Added simple ledger for unit testing and in memory use --- NEW FILE: SimpleLedger.java --- package org.neuclear.ledger.simple; /** * $Id: SimpleLedger.java,v 1.1 2004/03/22 20:08:24 pelle Exp $ * $Log: SimpleLedger.java,v $ * Revision 1.1 2004/03/22 20:08:24 pelle * Added simple ledger for unit testing and in memory use * * Revision 1.3 2003/11/21 04:43:20 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:17:31 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/09/20 23:16:20 pelle * First revision of neuclear-ledger in /cvsroot/neuclear * Older versions can be found /cvsroot/neuclear * * Revision 1.12 2003/08/06 16:41:22 pelle * Fixed a few implementation bugs with regards to the Held Transactions * * Revision 1.11 2003/08/01 21:59:47 pelle * More changes to the way helds are managed. * * Revision 1.10 2003/07/29 22:57:50 pelle * New version with refactored support for HeldTransactions. * Please note that this causes a sql exception when adding held_item rows. * * Revision 1.9 2003/07/23 18:17:52 pelle * Added support for display names in the books. * * Revision 1.8 2003/07/23 17:19:26 pelle * Ledgers now have a required display name. * * Revision 1.7 2003/07/21 18:35:15 pelle * Completed Exception handling refactoring * * Revision 1.6 2003/07/18 20:27:39 pelle * *** empty log message *** * * Revision 1.5 2003/07/17 21:21:08 pelle * Most SQLLedger methods have been implemented (Now on to debugging them) * * Revision 1.4 2003/01/25 23:58:00 pelle * Added some new testcases for testing the versioning code. * These picked up some errors in SimpleLedger that were fixed. * * Revision 1.3 2003/01/25 19:14:47 pelle * The ridiculously simple SimpleLedger now passes initial test. * I've split the Transaction Class into two sub classes and made Transaction abstract. * The two new Transaction Classes reflect the state of the Transaction and their methods reflect this. * * Revision 1.2 2003/01/18 17:18:56 pelle * Added LedgerFactory for creating new Ledger Instances * * Revision 1.1 2003/01/18 16:17:46 pelle * First checkin of the NeuClear Ledger API. * This is meant as a standardized super simple API for applications to use when posting transactions to a ledger. * Ledger's could be General Ledger's for accounting applications or Bank Account ledger's for financial applications. * */ import org.neuclear.ledger.*; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; /** * This implementation is very simple and only is meant for testing. It uses the Java Collection for the implementation and is in no way * thread safe or supportive of transactions. */ public final class SimpleLedger extends Ledger { public SimpleLedger(final String name) { super(name); id = name; ledger = new LinkedHashMap(); held = new LinkedHashMap(); books = new HashMap(); } /** * The basic interface for creating Transactions in the database. * The implementing class takes this transacion information and stores it with an automatically generated uniqueid. * This id is returned as an identifier of the transaction. * * @param trans Transaction to perform * @return Unique ID * @ If there was a problem with the Transaction */ public PostedTransaction performTransaction(final UnPostedTransaction trans) throws UnBalancedTransactionException, InvalidTransactionException { if (!trans.isBalanced()) throw new UnBalancedTransactionException(this, trans); final PostedTransaction posted = new PostedTransaction(trans, new Date()); ledger.put(id, posted); return posted; } /** * Similar to a transaction but guarantees that there wont be any negative balances left after the transaction. * * @param trans Transaction to perform * @return The reference to the transaction */ public PostedTransaction performVerifiedTransfer(UnPostedTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { Iterator iter = trans.getItems(); while (iter.hasNext()) { TransactionItem item = (TransactionItem) iter.next(); if (getAvailableBalance(item.getBook()) + item.getAmount() < 0) throw new InsufficientFundsException(this, item.getBook(), item.getAmount()); } return performTransaction(trans); } /** * The basic interface for creating Transactions in the database. * The implementing class takes this transacion information and stores it with an automatically generated uniqueid. * This id is returned as an identifier of the transaction. * * @param trans Transaction to perform * @return Unique ID */ public PostedHeldTransaction performHeldTransfer(final UnPostedHeldTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { if (!trans.isBalanced()) throw new UnBalancedTransactionException(this, trans); final PostedHeldTransaction posted = new PostedHeldTransaction(trans, new Date()); held.put(posted.getId(), posted); return posted; } /** * Cancels a Held Transaction. * * @param hold * @throws org.neuclear.ledger.LowlevelLedgerException * * @throws org.neuclear.ledger.UnknownTransactionException * */ public void performCancelHold(PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException { if (held.containsKey(hold.getId())) held.remove(hold.getId()); } /** * Completes a held transaction. Which means: * cancelling the hold and performing the transfer with the given updated amount and comment. * * @param hold HeldTransaction to complete * @param amount The updatd amount. It must be <= than the amount of the hold * @param comment * @return * @throws org.neuclear.ledger.InvalidTransactionException * * @throws org.neuclear.ledger.LowlevelLedgerException * * @throws org.neuclear.ledger.TransactionExpiredException * */ public PostedTransaction performCompleteHold(PostedHeldTransaction hold, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, TransactionExpiredException { if (!held.containsKey(hold) || hold.getExpiryTime().before(new Date())) throw new TransactionExpiredException(this, hold); held.remove(hold.getId()); PostedTransaction posted = new PostedTransaction(hold, new Date(), amount, comment); ledger.put(posted.getId(), posted); return posted; } /** * Searches for a Transaction based on its Transaction ID * * @param id A valid ID * @return The Transaction object */ public Date getTransactionTime(String id) throws LowlevelLedgerException, UnknownTransactionException, InvalidTransactionException, UnknownBookException { return ((PostedTransaction) ledger.get(id)).getTransactionTime(); //To change body of implemented methods use File | Settings | File Templates. } /** * Calculate the true accounting balance at a given time. This does not take into account any held transactions, thus may not necessarily * show the Available balance.<p> * Basic Algorithm: * <ol><li>If transactiondate is AFTER balance date SKIP * <li>If Transaction DOES NOT have an expiry date its a regular transaction and ADD to balance and SKIP * </ol> * * @return the balance as a double */ public double getBalance(final String book) { double balance = 0; // Very silly slow and lazy implementation final Iterator iter = ledger.keySet().iterator(); final boolean going = true; while (iter.hasNext() && going) { final PostedTransaction tran = (PostedTransaction) ledger.get((String) iter.next()); final Iterator items = tran.getItems(); while (items.hasNext()) { final TransactionItem item = (TransactionItem) items.next(); if (item.getBook().equals(book)) balance += item.getAmount(); } } System.out.println("Book: " + book + " has a balance of: " + balance); return balance; } /** * Calculate the true accounting balance at a given time. This does not take into account any held transactions, thus may not necessarily * show the Available balance.<p> * Basic Algorithm: * <ol><li>If transactiondate is AFTER balance date SKIP * <li>If Transaction DOES NOT have an expiry date its a regular transaction and ADD to balance and SKIP * </ol> * * @return the balance as a double */ private double getHeldBalance(final String book) { double balance = 0; Date now = new Date(); // Very silly slow and lazy implementation final Iterator iter = held.keySet().iterator(); final boolean going = true; while (iter.hasNext() && going) { final PostedHeldTransaction tran = (PostedHeldTransaction) ledger.get((String) iter.next()); if (now.after(tran.getExpiryTime())) { iter.remove(); } else { final Iterator items = tran.getItems(); while (items.hasNext()) { final TransactionItem item = (TransactionItem) items.next(); if (item.getBook().equals(book)) balance += item.getAmount(); } } } System.out.println("Book: " + book + " has a balance of: " + balance); return balance; } /** * Calculate the available balance at a given time. This DOES take into account any held transactions. * Basic Algorithm: * <ol><li>If transactiondate is AFTER balance date SKIP * <li>If Transaction DOES NOT have an expiry date its a regular transaction and ADD to balance and SKIP * <li>If Transaction DOES HAVE an expiry date it is a held transaction. If Expiry date is AFTER balance date SKIP * <li>If Transaction amount is POSITIVE it is a Credit, we dont take held credits into accout on balance SKIP * <li>If Transaction Amount is NEGATIVE it is a Debit and ADD to balance * </ol> * * @return the balance as a double */ public double getAvailableBalance(final String book) { return getBalance(book) + getHeldBalance(book); } public String toString() { return "Simple Ledger: " + id; } /** * Searches for a Held Transaction based on its Transaction ID * * @param idstring A valid ID * @return The Transaction object */ public PostedHeldTransaction findHeldTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException { return (PostedHeldTransaction) held.get(idstring); } public void close() { //To change body of implemented methods use File | Settings | File Templates. } private final LinkedHashMap ledger; private final LinkedHashMap held; private final String id; } |