|
From: <pe...@us...> - 2003-10-03 23:48:36
|
Update of /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay/contracts
In directory sc8-pr-cvs1:/tmp/cvs-serv32588/src/java/org/neuclear/pay/contracts
Modified Files:
TransferContract.java
Added Files:
TransferGlobals.java TransferReceipt.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.
--- NEW FILE: TransferGlobals.java ---
package org.neuclear.pay.contracts;
import org.dom4j.*;
/*
NeuClear Distributed Transaction Clearing Platform
(C) 2003 Pelle Braendgaard
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: TransferGlobals.java,v 1.1 2003/10/03 23:48:29 pelle Exp $
$Log: TransferGlobals.java,v $
Revision 1.1 2003/10/03 23:48:29 pelle
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.
*/
/**
*
* User: pelleb
* Date: Oct 3, 2003
* Time: 3:55:06 PM
*/
public final class TransferGlobals {
private TransferGlobals() {
// Instantiation is not allowed
}
public static Namespace createXferNameSpace() {
return DocumentHelper.createNamespace(XFER_NSPREFIX, XFER_NSURI);
}
public static QName createQName(String name) {
return DocumentHelper.createQName(name, createXferNameSpace());
}
public static Attribute createAttribute(Element elem, String name, String value) {
return DocumentHelper.createAttribute(elem, createQName(name), value);
}
public static Element createElement(String name, String value) {
return DocumentHelper.createElement(createQName(name));
}
public static final String XFER_TAGNAME = "TransferRequest";
public static final String XFER_RCPT_TAGNAME = "TransferReceipt";
public static final String XFER_NSPREFIX = "xfer";
public static final String XFER_NSURI = "http://neudist.org/neu/xfer";
}
--- NEW FILE: TransferReceipt.java ---
package org.neuclear.pay.contracts;
/*
NeuClear Distributed Transaction Clearing Platform
(C) 2003 Pelle Braendgaard
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: TransferReceipt.java,v 1.1 2003/10/03 23:48:29 pelle Exp $
$Log: TransferReceipt.java,v $
Revision 1.1 2003/10/03 23:48:29 pelle
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.
*/
/**
*
* User: pelleb
* Date: Oct 3, 2003
* Time: 2:00:28 PM
*/
public class TransferReceipt {
}
Index: TransferContract.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay/contracts/TransferContract.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TransferContract.java 26 Sep 2003 23:51:32 -0000 1.1
--- TransferContract.java 3 Oct 2003 23:48:29 -0000 1.2
***************
*** 5,8 ****
--- 5,9 ----
import org.neuclear.id.NamedObjectReader;
import org.neuclear.id.SignedNamedObject;
+ import org.neuclear.receiver.UnsupportedTransaction;
import org.neudist.utils.NeudistException;
***************
*** 43,61 ****
}
! public double getAmount() {
return amount;
}
! public String getAsset() {
return asset;
}
! public String getRecipient() {
return toaccount;
}
! private double amount;
! private String toaccount;
! private String asset;
public static class Reader implements NamedObjectReader {
--- 44,62 ----
}
! public final double getAmount() {
return amount;
}
! public final String getAsset() {
return asset;
}
! public final String getRecipient() {
return toaccount;
}
! private final double amount;
! private final String toaccount;
! private final String asset;
public static class Reader implements NamedObjectReader {
***************
*** 66,69 ****
--- 67,74 ----
*/
public SignedNamedObject read(Element elem, String name, Identity signatory, String digest, Timestamp timestamp) throws NeudistException {
+ if (!(elem.getName().equals(TransferGlobals.XFER_TAGNAME) &&
+ elem.getNamespaceURI().equals(TransferGlobals.XFER_NSURI)))
+ throw new UnsupportedTransaction(null);
+
double amount = Double.parseDouble(elem.attributeValue("amount"));
String asset = elem.attributeValue("asset");
|