|
From: <pe...@us...> - 2003-10-03 23:48:35
|
Update of /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay
In directory sc8-pr-cvs1:/tmp/cvs-serv32588/src/java/org/neuclear/pay
Modified Files:
Account.java HeldPaymentReceipt.java HeldPaymentRequest.java
Issuer.java Payment.java PaymentProcessor.java
PaymentReceipt.java PaymentRequest.java
Log Message:
Did various security related updates in the pay package with regards to immutability of fields etc.
PaymentReceiver should now be operational. Real testing needs to be done including in particular setting the
private key of the Receiver.
A new class TransferGlobals contains usefull settings for making life easier in the other contract based classes.
TransferContract the signed contract is functional and has a matching TransferRequestBuilder class for programmatically creating
TransferRequests for signing.
TransferReceiptBuilder has been created for use by Payment processors. It is used in the PaymentReceiver.
Index: Account.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay/Account.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Account.java 20 Sep 2003 23:12:40 -0000 1.1.1.1
--- Account.java 3 Oct 2003 23:48:30 -0000 1.2
***************
*** 14,72 ****
public class Account {
! private Book book;
! private PaymentProcessor proc;
! Account(PaymentProcessor proc,Book book) {
! this.book=book;
! this.proc=proc;
}
! public PaymentProcessor getProc() {
return proc;
}
! Book getBook() {
return book;
}
! public String getID() {
return book.getBookID();
}
! public double getBalance() throws LowlevelLedgerException {
return book.getBalance();
}
! public double getAvailableBalance() throws LowlevelLedgerException {
return book.getAvailableBalance();
}
! public double getBalance(Date time) throws LowlevelLedgerException {
return book.getBalance(time);
}
! public double getAvailableBalance(Date time) throws LowlevelLedgerException {
return book.getAvailableBalance(time);
}
! public String getDisplayName() {
return book.getDisplayName();
}
final public PaymentReceipt pay(Account to, double amount, Date valuedate, String comment) throws UnknownBookException, UnBalancedTransactionException, InvalidTransactionException, LowlevelLedgerException, NegativePaymentException, InsufficientFundsException {
! if ( amount < 0 )
throw new NegativePaymentException(proc, amount);
! if ( getAvailableBalance(valuedate) - amount < 0 )
throw new InsufficientFundsException(proc, this, amount);
!
return proc.processPayment(new PaymentRequest(this, to, amount, valuedate, comment));
}
! final public HeldPaymentReceipt hold(Account to, double amount, Date valuedate,Date helduntil, String comment) throws UnknownBookException, UnBalancedTransactionException, InvalidTransactionException, LowlevelLedgerException, NegativePaymentException, InsufficientFundsException {
! if ( amount < 0 )
throw new NegativePaymentException(proc, amount);
! if ( getAvailableBalance(valuedate) - amount < 0 )
throw new InsufficientFundsException(proc, this, amount);
! return proc.processHeldPayment(new HeldPaymentRequest(this, to, amount, valuedate,helduntil, comment));
}
}
--- 14,73 ----
public class Account {
! private final Book book;
! private final PaymentProcessor proc;
! Account(PaymentProcessor proc, Book book) {
! this.book = book;
! this.proc = proc;
}
! public final PaymentProcessor getProc() {
return proc;
}
! final Book getBook() {
return book;
}
! final public String getID() {
return book.getBookID();
}
! final public double getBalance() throws LowlevelLedgerException {
return book.getBalance();
}
! final public double getAvailableBalance() throws LowlevelLedgerException {
return book.getAvailableBalance();
}
! final public double getBalance(Date time) throws LowlevelLedgerException {
return book.getBalance(time);
}
! final public double getAvailableBalance(Date time) throws LowlevelLedgerException {
return book.getAvailableBalance(time);
}
! final public String getDisplayName() {
return book.getDisplayName();
}
final public PaymentReceipt pay(Account to, double amount, Date valuedate, String comment) throws UnknownBookException, UnBalancedTransactionException, InvalidTransactionException, LowlevelLedgerException, NegativePaymentException, InsufficientFundsException {
! if (amount < 0)
throw new NegativePaymentException(proc, amount);
! if (getAvailableBalance(valuedate) - amount < 0)
throw new InsufficientFundsException(proc, this, amount);
!
return proc.processPayment(new PaymentRequest(this, to, amount, valuedate, comment));
}
!
! final public HeldPaymentReceipt hold(Account to, double amount, Date valuedate, Date helduntil, String comment) throws UnknownBookException, UnBalancedTransactionException, InvalidTransactionException, LowlevelLedgerException, NegativePaymentException, InsufficientFundsException {
! if (amount < 0)
throw new NegativePaymentException(proc, amount);
! if (getAvailableBalance(valuedate) - amount < 0)
throw new InsufficientFundsException(proc, this, amount);
! return proc.processHeldPayment(new HeldPaymentRequest(this, to, amount, valuedate, helduntil, comment));
}
}
Index: HeldPaymentReceipt.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay/HeldPaymentReceipt.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** HeldPaymentReceipt.java 20 Sep 2003 23:12:40 -0000 1.1.1.1
--- HeldPaymentReceipt.java 3 Oct 2003 23:48:30 -0000 1.2
***************
*** 1,8 ****
package org.neuclear.pay;
- import org.neuclear.ledger.UnBalancedTransactionException;
- import org.neuclear.ledger.InvalidTransactionException;
import org.neuclear.ledger.LowlevelLedgerException;
- import org.neuclear.ledger.UnknownBookException;
import java.util.Date;
--- 1,5 ----
***************
*** 15,19 ****
*/
public class HeldPaymentReceipt extends PaymentReceipt implements Held {
! public Date getHeldUntil() {
return req.getHeldUntil();
}
--- 12,16 ----
*/
public class HeldPaymentReceipt extends PaymentReceipt implements Held {
! public final Date getHeldUntil() {
return req.getHeldUntil();
}
***************
*** 21,35 ****
public HeldPaymentReceipt(PaymentProcessor proc, HeldPaymentRequest preq, String id) {
super(proc, preq, id);
! req=preq;
}
! public void cancel() throws LowlevelLedgerException, ExpiredHeldPaymentException {
getProc().processCancelHold(this);
}
- public PaymentReceipt complete(Date valueDate,double amount, String comment) throws LowlevelLedgerException, PaymentNotStartedException, ExpiredHeldPaymentException, PaymentLargerThanHeldException, NegativePaymentException {
! return getProc().processCompleteHold(this,valueDate,amount,comment);
}
! private HeldPaymentRequest req;
}
--- 18,34 ----
public HeldPaymentReceipt(PaymentProcessor proc, HeldPaymentRequest preq, String id) {
super(proc, preq, id);
! req = preq;
}
! public final void cancel() throws LowlevelLedgerException, ExpiredHeldPaymentException {
getProc().processCancelHold(this);
}
! public final PaymentReceipt complete(Date valueDate, double amount, String comment) throws LowlevelLedgerException, PaymentNotStartedException, ExpiredHeldPaymentException, PaymentLargerThanHeldException, NegativePaymentException {
!
! return getProc().processCompleteHold(this, valueDate, amount, comment);
}
!
! private final HeldPaymentRequest req;
}
Index: HeldPaymentRequest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay/HeldPaymentRequest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** HeldPaymentRequest.java 20 Sep 2003 23:12:40 -0000 1.1.1.1
--- HeldPaymentRequest.java 3 Oct 2003 23:48:30 -0000 1.2
***************
*** 10,23 ****
*/
public class HeldPaymentRequest extends PaymentRequest implements Held {
! public HeldPaymentRequest(Account from, Account to, double amount, Date valuedate,Date helduntil, String comment) throws NegativePaymentException {
super(from, to, amount, valuedate, comment);
! this.helduntil=helduntil;
}
! public Date getHeldUntil() {
return helduntil;
}
! private Date helduntil;
}
--- 10,24 ----
*/
public class HeldPaymentRequest extends PaymentRequest implements Held {
! public HeldPaymentRequest(Account from, Account to, double amount, Date valuedate, Date helduntil, String comment) throws NegativePaymentException {
super(from, to, amount, valuedate, comment);
! this.helduntil = helduntil;
}
! public final Date getHeldUntil() {
return helduntil;
}
!
! private final Date helduntil;
}
Index: Issuer.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay/Issuer.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Issuer.java 20 Sep 2003 23:12:40 -0000 1.1.1.1
--- Issuer.java 3 Oct 2003 23:48:30 -0000 1.2
***************
*** 12,28 ****
*/
public class Issuer extends Account {
! Issuer(PaymentProcessor proc,Book book) {
! super(proc,book);
}
! public PaymentReceipt fundAccount(Account recipient,double amount,Date valueDate) throws UnknownBookException, UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException,NegativePaymentException {
! return getProc().processPayment(new PaymentRequest(this,recipient,amount,valueDate,"Funding"));
}
! public double getCirculationBalance(Date date) throws LowlevelLedgerException {
return -getBook().getBalance(date);
}
! public double getCirculationBalance() throws LowlevelLedgerException {
return getCirculationBalance(new Date());
}
--- 12,28 ----
*/
public class Issuer extends Account {
! Issuer(PaymentProcessor proc, Book book) {
! super(proc, book);
}
! final public PaymentReceipt fundAccount(Account recipient, double amount, Date valueDate) throws UnknownBookException, UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException, NegativePaymentException {
! return getProc().processPayment(new PaymentRequest(this, recipient, amount, valueDate, "Funding"));
}
! final public double getCirculationBalance(Date date) throws LowlevelLedgerException {
return -getBook().getBalance(date);
}
! final public double getCirculationBalance() throws LowlevelLedgerException {
return getCirculationBalance(new Date());
}
Index: Payment.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay/Payment.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Payment.java 20 Sep 2003 23:12:40 -0000 1.1.1.1
--- Payment.java 3 Oct 2003 23:48:30 -0000 1.2
***************
*** 10,14 ****
public abstract class Payment {
! protected Payment() {
}
--- 10,14 ----
public abstract class Payment {
! Payment() {
}
Index: PaymentProcessor.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay/PaymentProcessor.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PaymentProcessor.java 20 Sep 2003 23:12:40 -0000 1.1.1.1
--- PaymentProcessor.java 3 Oct 2003 23:48:30 -0000 1.2
***************
*** 94,98 ****
}
! public Issuer getIssuerAccount() throws UnknownBookException, LowlevelLedgerException {
return issuerAccount;
}
--- 94,98 ----
}
! public Issuer getIssuerAccount() {
return issuerAccount;
}
***************
*** 131,136 ****
}
*/
! private Ledger ledger;
! private Issuer issuerAccount;
! private String title;
}
--- 131,136 ----
}
*/
! private final Ledger ledger;
! private final Issuer issuerAccount;
! private final String title;
}
Index: PaymentReceipt.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay/PaymentReceipt.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PaymentReceipt.java 20 Sep 2003 23:12:40 -0000 1.1.1.1
--- PaymentReceipt.java 3 Oct 2003 23:48:30 -0000 1.2
***************
*** 10,44 ****
*/
public class PaymentReceipt extends Payment {
! private PaymentRequest preq;
! private String id;
! private PaymentProcessor proc;
! PaymentReceipt(PaymentProcessor proc,PaymentRequest preq,String id) {
! this.preq=preq;
! this.id=id;
! this.proc=proc;
}
! public double getAmount() {
return preq.getAmount();
}
! public Date getValuedate() {
return preq.getValuedate();
}
! public Account getTo() {
return preq.getTo();
}
! public Account getFrom() {
return preq.getFrom();
}
! public PaymentProcessor getProc() {
return proc;
}
! public String getId() {
return id;
}
--- 10,45 ----
*/
public class PaymentReceipt extends Payment {
! private final PaymentRequest preq;
! private final String id;
! private final PaymentProcessor proc;
! PaymentReceipt(PaymentProcessor proc, PaymentRequest preq, String id) {
! this.preq = preq;
! this.id = id;
! this.proc = proc;
}
! public final double getAmount() {
return preq.getAmount();
}
! public final Date getValuedate() {
return preq.getValuedate();
}
! public final Account getTo() {
return preq.getTo();
}
! public final Account getFrom() {
return preq.getFrom();
}
! public final PaymentProcessor getProc() {
return proc;
}
!
! public final String getId() {
return id;
}
Index: PaymentRequest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay/PaymentRequest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PaymentRequest.java 20 Sep 2003 23:12:40 -0000 1.1.1.1
--- PaymentRequest.java 3 Oct 2003 23:48:30 -0000 1.2
***************
*** 10,46 ****
*/
public class PaymentRequest extends Payment {
! private double amount;
! private Date valuedate;
! private Account to;
! private Account from;
! private String comment = "";
! public PaymentRequest( Account from, Account to, double amount, Date valuedate, String comment ) throws NegativePaymentException{
! if (amount<0)
throw new NegativePaymentException(from.getProc(), amount);
! this.from=from;
! this.to=to;
! this.amount=amount;
! this.valuedate=valuedate;
! this.comment = comment;
}
! public double getAmount() {
return amount;
}
! public Date getValuedate() {
return valuedate;
}
! public Account getTo() {
return to;
}
! public Account getFrom() {
return from;
}
!
! public String getComment() {
return comment;
}
--- 10,46 ----
*/
public class PaymentRequest extends Payment {
! private final double amount;
! private final Date valuedate;
! private final Account to;
! private final Account from;
! private final String comment;
! public PaymentRequest(Account from, Account to, double amount, Date valuedate, String comment) throws NegativePaymentException {
! if (amount < 0)
throw new NegativePaymentException(from.getProc(), amount);
! this.from = from;
! this.to = to;
! this.amount = amount;
! this.valuedate = valuedate;
! this.comment = (comment != null) ? comment : "";
}
! public final double getAmount() {
return amount;
}
! public final Date getValuedate() {
return valuedate;
}
! public final Account getTo() {
return to;
}
! public final Account getFrom() {
return from;
}
!
! public final String getComment() {
return comment;
}
|