Update of /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/contracts
In directory sc8-pr-cvs1:/tmp/cvs-serv5679/src/java/org/neuclear/asset/contracts
Modified Files:
Asset.java AssetTransactionContract.java
CancelHeldTransferReceipt.java CancelHeldTransferRequest.java
CompleteHeldTransferRequest.java HeldTransferReceipt.java
HeldTransferRequest.java TransferContract.java
TransferReceipt.java TransferRequest.java
Log Message:
Updated all the Contracts to use the new security model.
Index: Asset.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/contracts/Asset.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Asset.java 19 Nov 2003 23:32:19 -0000 1.7
--- Asset.java 20 Nov 2003 16:01:59 -0000 1.8
***************
*** 5,12 ****
import org.neuclear.commons.NeuClearException;
import org.neuclear.commons.Utility;
! import org.neuclear.id.Identity;
! import org.neuclear.id.NSTools;
! import org.neuclear.id.NamedObjectReader;
! import org.neuclear.id.SignedNamedObject;
import org.neuclear.senders.SoapSender;
import org.neuclear.xml.xmlsec.KeyInfo;
--- 5,9 ----
import org.neuclear.commons.NeuClearException;
import org.neuclear.commons.Utility;
! import org.neuclear.id.*;
import org.neuclear.senders.SoapSender;
import org.neuclear.xml.xmlsec.KeyInfo;
***************
*** 37,40 ****
--- 34,40 ----
$Id$
$Log$
+ Revision 1.8 2003/11/20 16:01:59 pelle
+ Updated all the Contracts to use the new security model.
+
Revision 1.7 2003/11/19 23:32:19 pelle
Signers now can generatekeys via the generateKey() method.
***************
*** 91,103 ****
*/
public class Asset extends Identity {
! private Asset(String name, Identity signatory, Timestamp timestamp, String digest, String repository, String signer, String logger, String receiver, PublicKey pub, String assetController, int decimalpoint, double minimumTransaction) throws NeuClearException {
! super(name, signatory, timestamp, digest, repository, signer, logger, receiver, pub);
this.assetController = assetController;
! this.decimal = decimalpoint;
! this.multiplier = (int) Math.round(Math.pow(10, -decimalpoint));
! this.minimumTransaction = minimumTransaction;
}
! public String getControllerURL() {
return assetController;
}
--- 91,104 ----
*/
public class Asset extends Identity {
! protected Asset(SignedNamedCore core, String repository, String signer, String logger, String receiver, PublicKey pub, String assetController, int decimal, double minimumTransaction) throws NeuClearException {
! super(core, repository, signer, logger, receiver, pub);
this.assetController = assetController;
! this.decimal = decimal;
! this.multiplier = (int) Math.round(Math.pow(10, -decimal));
! this.minimumTransaction=minimumTransaction;
}
!
! public final String getControllerURL() {
return assetController;
}
***************
*** 110,114 ****
* @throws NeuClearException
*/
! public SignedNamedObject send(SignedNamedObject obj) throws NeuClearException {
return SoapSender.quickSend(assetController, obj);
}
--- 111,115 ----
* @throws NeuClearException
*/
! public final SignedNamedObject send(SignedNamedObject obj) throws NeuClearException {
return SoapSender.quickSend(assetController, obj);
}
***************
*** 120,124 ****
* @return
*/
! public boolean isValidAmount(double amount) {
return amount >= minimumTransaction;
}
--- 121,125 ----
* @return
*/
! public final boolean isValidAmount(double amount) {
return amount >= minimumTransaction;
}
***************
*** 130,134 ****
* @return
*/
! public double round(double amount) {
if (amount < minimumTransaction)
return minimumTransaction;
--- 131,135 ----
* @return
*/
! public final double round(double amount) {
if (amount < minimumTransaction)
return minimumTransaction;
***************
*** 146,150 ****
* @return
*/
! public SignedNamedObject read(Element elem, String name, Identity signatory, String digest, Timestamp timestamp) throws NeuClearException, XMLSecurityException {
if (!elem.getNamespace().equals(AssetGlobals.createNameSpace()))
throw new UnsupportedOperationException("");
--- 147,151 ----
* @return
*/
! public final SignedNamedObject read(SignedNamedCore core, Element elem) throws NeuClearException, XMLSecurityException {
if (!elem.getNamespace().equals(AssetGlobals.createNameSpace()))
throw new UnsupportedOperationException("");
***************
*** 163,168 ****
double minimum = (!Utility.isEmpty(min)) ? Double.parseDouble(min) : 0;
! return new Asset(name, signatory, timestamp, digest, repository, signer, logger, receiver, pub, assetController, decimal, minimum);
}
--- 164,170 ----
double minimum = (!Utility.isEmpty(min)) ? Double.parseDouble(min) : 0;
! return new Asset(core, repository, signer, logger, receiver, pub, assetController, decimal, minimum);
}
+
Index: AssetTransactionContract.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/contracts/AssetTransactionContract.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** AssetTransactionContract.java 19 Nov 2003 23:32:20 -0000 1.4
--- AssetTransactionContract.java 20 Nov 2003 16:01:59 -0000 1.5
***************
*** 8,11 ****
--- 8,12 ----
import org.neuclear.id.NamedObjectReader;
import org.neuclear.id.SignedNamedObject;
+ import org.neuclear.id.SignedNamedCore;
import org.neuclear.id.resolver.NSResolver;
import org.neuclear.receiver.UnsupportedTransaction;
***************
*** 21,24 ****
--- 22,28 ----
* $Id$
* $Log$
+ * Revision 1.5 2003/11/20 16:01:59 pelle
+ * Updated all the Contracts to use the new security model.
+ *
* Revision 1.4 2003/11/19 23:32:20 pelle
* Signers now can generatekeys via the generateKey() method.
***************
*** 48,56 ****
private final Asset asset;
! public AssetTransactionContract(String name, Identity signer, Timestamp timestamp, String digest, Asset asset) throws NeuClearException {
! super(name, signer, timestamp, digest);
this.asset = asset;
}
public final Asset getAsset() {
return asset;
--- 52,61 ----
private final Asset asset;
! AssetTransactionContract(SignedNamedCore core, Asset asset) throws NeuClearException {
! super(core);
this.asset = asset;
}
+
public final Asset getAsset() {
return asset;
***************
*** 64,68 ****
* @return
*/
! public SignedNamedObject read(Element elem, String name, Identity signatory, String digest, Timestamp timestamp) throws NeuClearException {
if (elem.getNamespaceURI().equals(TransferGlobals.XFER_NSURI))
throw new UnsupportedTransaction(null);
--- 69,73 ----
* @return
*/
! public final SignedNamedObject read(SignedNamedCore core, Element elem) throws NeuClearException {
if (elem.getNamespaceURI().equals(TransferGlobals.XFER_NSURI))
throw new UnsupportedTransaction(null);
***************
*** 71,77 ****
String holdid = elem.attributeValue("holdid");
if (elem.getName().equals(TransferGlobals.CANCEL_TAGNAME))
! return new CancelHeldTransferRequest(name, signatory, timestamp, digest, asset, holdid);
if (elem.getName().equals(TransferGlobals.CANCEL_RCPT_TAGNAME))
! return new CancelHeldTransferReceipt(name, signatory, timestamp, digest, asset, holdid);
double amount = Double.parseDouble(elem.attributeValue("amount"));
--- 76,82 ----
String holdid = elem.attributeValue("holdid");
if (elem.getName().equals(TransferGlobals.CANCEL_TAGNAME))
! return new CancelHeldTransferRequest(core, asset, holdid);
if (elem.getName().equals(TransferGlobals.CANCEL_RCPT_TAGNAME))
! return new CancelHeldTransferReceipt(core, asset, holdid);
double amount = Double.parseDouble(elem.attributeValue("amount"));
***************
*** 80,84 ****
String comment = elem.attributeValue("comment");
if (elem.getName().equals(TransferGlobals.XFER_TAGNAME))
! return new TransferRequest(name, signatory, timestamp, digest, asset, to, amount, valuetime, comment);
Date helduntil = null;
--- 85,89 ----
String comment = elem.attributeValue("comment");
if (elem.getName().equals(TransferGlobals.XFER_TAGNAME))
! return new TransferRequest(core, asset, to, amount, valuetime, comment);
Date helduntil = null;
***************
*** 86,101 ****
helduntil = TimeTools.parseTimeStamp(elem.attributeValue("valuetime"));
if (elem.getName().equals(TransferGlobals.HELD_XFER_TAGNAME))
! return new HeldTransferRequest(name, signatory, timestamp, digest, asset, to, amount, valuetime, comment, helduntil);
Identity from = NSResolver.resolveIdentity(elem.attributeValue("sender"));
String reqid = elem.attributeValue("reqid");
if (elem.getName().equals(TransferGlobals.XFER_RCPT_TAGNAME))
! return new TransferReceipt(name, signatory, timestamp, digest, asset, from, to, reqid, amount, valuetime, comment);
if (elem.getName().equals(TransferGlobals.HELD_XFER_RCPT_TAGNAME))
! return new HeldTransferReceipt(name, signatory, timestamp, digest, asset, from, to, reqid, amount, valuetime, comment, helduntil);
if (elem.getName().equals(TransferGlobals.COMPLETE_TAGNAME))
! return new CompleteHeldTransferRequest(name, signatory, timestamp, digest, asset, from, to, amount, valuetime, comment, holdid);
throw new UnsupportedTransaction(null);
--- 91,106 ----
helduntil = TimeTools.parseTimeStamp(elem.attributeValue("valuetime"));
if (elem.getName().equals(TransferGlobals.HELD_XFER_TAGNAME))
! return new HeldTransferRequest(core, asset, to, amount, valuetime, comment, helduntil);
Identity from = NSResolver.resolveIdentity(elem.attributeValue("sender"));
String reqid = elem.attributeValue("reqid");
if (elem.getName().equals(TransferGlobals.XFER_RCPT_TAGNAME))
! return new TransferReceipt(core, asset, from, to, reqid, amount, valuetime, comment);
if (elem.getName().equals(TransferGlobals.HELD_XFER_RCPT_TAGNAME))
! return new HeldTransferReceipt(core, asset, from, to, reqid, amount, valuetime, comment, helduntil);
if (elem.getName().equals(TransferGlobals.COMPLETE_TAGNAME))
! return new CompleteHeldTransferRequest(core, asset, from, to, amount, valuetime, comment, holdid);
throw new UnsupportedTransaction(null);
Index: CancelHeldTransferReceipt.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/contracts/CancelHeldTransferReceipt.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CancelHeldTransferReceipt.java 10 Nov 2003 17:42:07 -0000 1.1
--- CancelHeldTransferReceipt.java 20 Nov 2003 16:01:59 -0000 1.2
***************
*** 4,7 ****
--- 4,8 ----
import org.neuclear.id.Identity;
import org.neuclear.id.SignedNamedObject;
+ import org.neuclear.id.SignedNamedCore;
import java.sql.Timestamp;
***************
*** 13,26 ****
* Time: 5:35:26 PM
*/
! public class CancelHeldTransferReceipt extends AssetTransactionContract{
! CancelHeldTransferReceipt(String name, Identity signer, Timestamp timestamp, String digest,
! Asset asset, String holdid) throws NeuClearException {
! super(name, signer, timestamp, digest,asset);
! this.holdid=holdid;
}
!
! public String getHoldId() {
return holdid;
}
--- 14,25 ----
* Time: 5:35:26 PM
*/
! public final class CancelHeldTransferReceipt extends AssetTransactionContract{
! CancelHeldTransferReceipt(SignedNamedCore core, Asset asset, String holdid) throws NeuClearException {
! super(core, asset);
! this.holdid = holdid;
}
! public final String getHoldId() {
return holdid;
}
Index: CancelHeldTransferRequest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/contracts/CancelHeldTransferRequest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CancelHeldTransferRequest.java 10 Nov 2003 17:42:07 -0000 1.1
--- CancelHeldTransferRequest.java 20 Nov 2003 16:01:59 -0000 1.2
***************
*** 4,7 ****
--- 4,8 ----
import org.neuclear.id.Identity;
import org.neuclear.id.SignedNamedObject;
+ import org.neuclear.id.SignedNamedCore;
import java.sql.Timestamp;
***************
*** 13,26 ****
* Time: 5:35:26 PM
*/
! public class CancelHeldTransferRequest extends AssetTransactionContract{
! public CancelHeldTransferRequest(String name, Identity signer, Timestamp timestamp, String digest,
! Asset asset, String holdid) throws NeuClearException {
! super(name, signer, timestamp, digest,asset);
! this.holdid=holdid;
}
!
! public String getHoldId() {
return holdid;
}
--- 14,25 ----
* Time: 5:35:26 PM
*/
! public final class CancelHeldTransferRequest extends AssetTransactionContract{
! CancelHeldTransferRequest(SignedNamedCore core, Asset asset, String holdid) throws NeuClearException {
! super(core, asset);
! this.holdid = holdid;
}
! public final String getHoldId() {
return holdid;
}
Index: CompleteHeldTransferRequest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/contracts/CompleteHeldTransferRequest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CompleteHeldTransferRequest.java 10 Nov 2003 17:42:07 -0000 1.1
--- CompleteHeldTransferRequest.java 20 Nov 2003 16:01:59 -0000 1.2
***************
*** 3,6 ****
--- 3,7 ----
import org.neuclear.commons.NeuClearException;
import org.neuclear.id.Identity;
+ import org.neuclear.id.SignedNamedCore;
import java.sql.Timestamp;
***************
*** 12,30 ****
* Time: 5:35:26 PM
*/
! public class CompleteHeldTransferRequest extends TransferContract {
!
! CompleteHeldTransferRequest(String name, Identity signer, Timestamp timestamp, String digest,
! Asset asset, Identity from,Identity to, double amount, Date valuetime, String comment,String holdid) throws NeuClearException {
! super(name, signer, timestamp, digest, asset, to, amount, valuetime, comment);
! this.from=from;
! this.holdid=holdid;
}
-
public final Identity getFrom() {
return from;
}
! public String getHoldId() {
return holdid;
}
--- 13,28 ----
* Time: 5:35:26 PM
*/
! public final class CompleteHeldTransferRequest extends TransferContract {
! CompleteHeldTransferRequest(SignedNamedCore core, Asset asset, Identity from, Identity to, double amount, Date valuetime, String comment, String holdid) throws NeuClearException {
! super(core, asset, to, amount, valuetime, comment);
! this.from = from;
! this.holdid = holdid;
}
public final Identity getFrom() {
return from;
}
! public final String getHoldId() {
return holdid;
}
Index: HeldTransferReceipt.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/contracts/HeldTransferReceipt.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** HeldTransferReceipt.java 10 Nov 2003 17:42:07 -0000 1.2
--- HeldTransferReceipt.java 20 Nov 2003 16:01:59 -0000 1.3
***************
*** 3,6 ****
--- 3,7 ----
import org.neuclear.commons.NeuClearException;
import org.neuclear.id.Identity;
+ import org.neuclear.id.SignedNamedCore;
import java.sql.Timestamp;
***************
*** 12,19 ****
* Time: 11:59:36 AM
*/
! public class HeldTransferReceipt extends TransferReceipt implements Held {
! HeldTransferReceipt(String name, Identity signer, Timestamp timestamp, String digest, Asset asset, Identity from, Identity to, String reqid, double amount, Date valuetime, String comment, Date helduntil) throws NeuClearException {
! super(name, signer, timestamp, digest, asset, from, to, reqid, amount, valuetime, comment);
this.helduntil = helduntil;
}
--- 13,20 ----
* Time: 11:59:36 AM
*/
! public final class HeldTransferReceipt extends TransferReceipt implements Held {
! HeldTransferReceipt(SignedNamedCore core, Asset asset, Identity from, Identity to, String reqid, double amount, Date valuetime, String comment, Date helduntil) throws NeuClearException {
! super(core, asset, from, to, reqid, amount, valuetime, comment);
this.helduntil = helduntil;
}
Index: HeldTransferRequest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/contracts/HeldTransferRequest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** HeldTransferRequest.java 8 Nov 2003 01:39:58 -0000 1.1
--- HeldTransferRequest.java 20 Nov 2003 16:01:59 -0000 1.2
***************
*** 3,6 ****
--- 3,7 ----
import org.neuclear.commons.NeuClearException;
import org.neuclear.id.Identity;
+ import org.neuclear.id.SignedNamedCore;
import java.sql.Timestamp;
***************
*** 12,18 ****
* Time: 12:01:03 PM
*/
! public class HeldTransferRequest extends TransferRequest implements Held {
! public HeldTransferRequest(String name, Identity signer, Timestamp timestamp, String digest, Asset asset, Identity to, double amount, Date valuetime, String comment, Date helduntil) throws NeuClearException {
! super(name, signer, timestamp, digest, asset, to, amount, valuetime, comment);
this.helduntil = helduntil;
}
--- 13,19 ----
* Time: 12:01:03 PM
*/
! public final class HeldTransferRequest extends TransferRequest implements Held {
! HeldTransferRequest(SignedNamedCore core, Asset asset, Identity to, double amount, Date valuetime, String comment, Date helduntil) throws NeuClearException {
! super(core, asset, to, amount, valuetime, comment);
this.helduntil = helduntil;
}
Index: TransferContract.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/contracts/TransferContract.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TransferContract.java 11 Nov 2003 21:17:19 -0000 1.3
--- TransferContract.java 20 Nov 2003 16:01:59 -0000 1.4
***************
*** 5,8 ****
--- 5,9 ----
import org.neuclear.id.NamedObjectReader;
import org.neuclear.id.SignedNamedObject;
+ import org.neuclear.id.SignedNamedCore;
import org.neuclear.id.resolver.NSResolver;
import org.neuclear.receiver.UnsupportedTransaction;
***************
*** 44,54 ****
*/
public abstract class TransferContract extends AssetTransactionContract {
! TransferContract(String name, Identity signer, Timestamp timestamp, String digest,
! Asset asset, Identity to, double amount,Date valuetime,String comment) throws NeuClearException {
! super(name, signer, timestamp, digest,asset);
! this.to = to;
this.amount = amount;
- this.valuetime = valuetime;
this.comment = (comment != null) ? comment : "";
}
--- 45,54 ----
*/
public abstract class TransferContract extends AssetTransactionContract {
! TransferContract(SignedNamedCore core, Asset asset, Identity to, double amount, Date valuetime, String comment) throws NeuClearException {
! super(core, asset);
this.amount = amount;
this.comment = (comment != null) ? comment : "";
+ this.to = to;
+ this.valuetime = valuetime;
}
Index: TransferReceipt.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/contracts/TransferReceipt.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TransferReceipt.java 10 Nov 2003 17:42:07 -0000 1.2
--- TransferReceipt.java 20 Nov 2003 16:01:59 -0000 1.3
***************
*** 3,6 ****
--- 3,7 ----
import org.neuclear.commons.NeuClearException;
import org.neuclear.id.Identity;
+ import org.neuclear.id.SignedNamedCore;
import java.sql.Timestamp;
***************
*** 16,31 ****
private final String reqid;
! TransferReceipt(String name, Identity signer, Timestamp timestamp, String digest, Asset asset, Identity from, Identity to, String reqid, double amount, Date valuetime, String comment) throws NeuClearException {
! super(name, signer, timestamp, digest, asset, to, amount, valuetime, comment);
this.from = from;
this.reqid = reqid;
}
-
public final Identity getFrom() {
return from;
}
! public String getRequestId() {
return reqid;
}
--- 17,31 ----
private final String reqid;
! TransferReceipt(SignedNamedCore core, Asset asset, Identity from, Identity to, String reqid, double amount, Date valuetime, String comment) throws NeuClearException {
! super(core, asset, to, amount, valuetime, comment);
this.from = from;
this.reqid = reqid;
}
public final Identity getFrom() {
return from;
}
! public final String getRequestId() {
return reqid;
}
Index: TransferRequest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/contracts/TransferRequest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TransferRequest.java 10 Nov 2003 17:42:07 -0000 1.2
--- TransferRequest.java 20 Nov 2003 16:01:59 -0000 1.3
***************
*** 3,6 ****
--- 3,7 ----
import org.neuclear.commons.NeuClearException;
import org.neuclear.id.Identity;
+ import org.neuclear.id.SignedNamedCore;
import java.sql.Timestamp;
***************
*** 14,21 ****
public class TransferRequest extends TransferContract {
! TransferRequest(String name, Identity signer, Timestamp timestamp, String digest, Asset asset, Identity to, double amount, Date valuetime, String comment) throws NeuClearException {
! super(name, signer, timestamp, digest, asset, to, amount, valuetime, comment);
}
-
public final Identity getFrom() {
--- 15,21 ----
public class TransferRequest extends TransferContract {
! TransferRequest(SignedNamedCore core, Asset asset, Identity to, double amount, Date valuetime, String comment) throws NeuClearException {
! super(core, asset, to, amount, valuetime, comment);
}
public final Identity getFrom() {
|