webfunds.sox
Class DepositRequest

java.lang.Object
  |
  +--webfunds.sox.Encodable
        |
        +--webfunds.sox.Request
              |
              +--webfunds.sox.DepositRequest

public class DepositRequest
extends Request

This class represents a deposit request, used by a SOX client to deposit a payment into an account. DepositRequest are usually created from a Payment object and a description string, and then signed.

See Also:
Serialized Form

Field Summary
static int DEPOSIT_LOCAL_VERS
          The version of the encoded deposit request.
static int DEPOSIT_not_used_yet
          The version of the encoded deposit request.
static int DEPOSIT_ORIGINAL
          The version of the encoded deposit request.
static int DEPOSIT_WITHDRAW
          The version of the encoded deposit request.
protected  byte[] depositDesc
          A description (can be anything, although very long lengths may be refused by some issuers and clients) of what the payment is for.
protected  java.lang.String depositId
          An identifier for this deposit request Note: although a java String is used, this identifier should only contain 8-bit ascii characters, following the same rules as that of the payment id (pid).
static java.lang.String name
           
protected  byte[] payBuf
           
protected  AbstractPayment payment
          The payment to be deposited (as originally created by the payer) (was Payment).
protected  AbstractPayment proto
          The payment to be withdrawn, paid for with above payment (as originally created by the payer, added at DEPOSIT_WITHDRAW-bis).
protected  byte[] protoBuf
           
protected  int protocolState
          The state of the protocol that the caller wants to (re)start this request processing in.
protected  int typeOfPayment
          The type of payment that the caller wants to withdraw, where the type is a number from PaymentFactory.
protected  int version
           
 
Fields inherited from class webfunds.sox.Request
account, REQ_not_used_yet, REQ_ORIGINAL, REQ_SUBS_ADD_V, req_version, REQ_VERSION, requestId, sig, timestamp
 
Constructor Summary
DepositRequest(byte[] depositReqData)
          Construct a deposit request object from a byte array that was previously returned from the encode() method of a deposit request object.
DepositRequest(java.io.InputStream is)
          Construct a deposit request object from data on an input stream that was previously returned from the encode() method of a deposit request object.
DepositRequest(java.lang.String requestId, AccountId acc, AbstractPayment payment, AbstractPayment proto, java.lang.String depositId, byte[] desc)
          Create an unsigned withdrawal request, to get a token payment signed.
DepositRequest(java.lang.String requestId, AccountId acc, AbstractPayment payment, java.lang.String depositId, byte[] desc)
          Create an unsigned deposit request This constructor is the one usually called by SOX clients.
 
Method Summary
protected static void cycle()
           
 void decode(java.io.InputStream is)
          Recover this deposit request object with the values from a deposit request on the input stream (such as might be sent by the encode() method of a deposit request object).
 void encode(java.io.OutputStream os)
          Encode a deposit request to an output stream, suitable for using with RequestPacket to send to remote servers (which use the decode() method to re-construct the object).
 boolean equals(java.lang.Object object)
           
 Reply errorReply(int e)
          Get a Reply with Errors set.
static DepositRequest example()
           
 byte[] getDepositDesc()
          Get the description for this deposit request
 java.lang.String getDepositId()
          Get the identifier on this deposit request Note: although a java String is used, this identifier should only contain 8-bit ascii characters.
 ItemId getItem()
          Get the type of item (or "currency") on the payment (this is [almost certainly] the message digest of a ricardian contract).
 java.lang.String getName()
          Returns the name of the packet as it goes on the wire.
 AbstractPayment getPay()
           
 Payment getPayment()
          Get the payment to be deposited.
 byte[] getPaymentDesc()
          Get the description on the payment
 java.lang.String getPaymentId()
          Get the identifier on the payment, as originally created by the payer.
 AbstractPayment getProto()
          Get the proto payment to be signed, if a withdrawal.
 int getProtocolState()
           
 long getQty()
          Get the quantity of the item on the payment
 AccountId getSource()
          Get the account to which the payment is made.
 AccountId getTarget()
          Get the account from which the transaction was drawn.
 int getTypeOfPayment()
           
 int getVersion()
           
 DepositReply goodReply(MailItem mail)
           
protected static void input()
           
static void main(java.lang.String[] args)
           
protected static void output()
           
protected static void readWrite()
           
 void setProtocolState(int state)
           
 void setTypeOfPayment(int type)
           
 void setVersion(int v)
           
 java.lang.String toAscii()
           
 java.lang.String toString()
          Convert this object to a human readable string
 java.lang.String vString()
           
 
Methods inherited from class webfunds.sox.Request
getAccountId, getRequestId, getRequestVersion, getTimestamp, isSigned, reconstructReply, setRequestVersion, setSignature, verify
 
Methods inherited from class webfunds.sox.Encodable
decode, encode, readByteArray, readCertificate, readProperties, readString, writeByteArray, writeCertificate, writeProperties, writeString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEPOSIT_ORIGINAL

public static final int DEPOSIT_ORIGINAL
The version of the encoded deposit request. 1 - original, as delivered, but virtual, number not present in packet 2 - add version number to this DepositRequest (and all others). 3 - withdrawal - can exchange one payment for another 4 - use me next Originally, in Request.VERSION == 2, there were no local versions. We'll call that VERS == 1.

DEPOSIT_LOCAL_VERS

public static final int DEPOSIT_LOCAL_VERS
The version of the encoded deposit request. 1 - original, as delivered, but virtual, number not present in packet 2 - add version number to this DepositRequest (and all others). 3 - withdrawal - can exchange one payment for another 4 - use me next Originally, in Request.VERSION == 2, there were no local versions. We'll call that VERS == 1.

DEPOSIT_WITHDRAW

public static final int DEPOSIT_WITHDRAW
The version of the encoded deposit request. 1 - original, as delivered, but virtual, number not present in packet 2 - add version number to this DepositRequest (and all others). 3 - withdrawal - can exchange one payment for another 4 - use me next Originally, in Request.VERSION == 2, there were no local versions. We'll call that VERS == 1.

DEPOSIT_not_used_yet

public static final int DEPOSIT_not_used_yet
The version of the encoded deposit request. 1 - original, as delivered, but virtual, number not present in packet 2 - add version number to this DepositRequest (and all others). 3 - withdrawal - can exchange one payment for another 4 - use me next Originally, in Request.VERSION == 2, there were no local versions. We'll call that VERS == 1.

version

protected int version

name

public static final java.lang.String name

payment

protected AbstractPayment payment
The payment to be deposited (as originally created by the payer) (was Payment).

payBuf

protected byte[] payBuf

proto

protected AbstractPayment proto
The payment to be withdrawn, paid for with above payment (as originally created by the payer, added at DEPOSIT_WITHDRAW-bis).

protoBuf

protected byte[] protoBuf

depositId

protected java.lang.String depositId
An identifier for this deposit request Note: although a java String is used, this identifier should only contain 8-bit ascii characters, following the same rules as that of the payment id (pid).

depositDesc

protected byte[] depositDesc
A description (can be anything, although very long lengths may be refused by some issuers and clients) of what the payment is for. This field is provided by the payee when the payment is deposited. One interesting use of this field is for providing the payee with a key that "unlocks" a protected software package.

typeOfPayment

protected int typeOfPayment
The type of payment that the caller wants to withdraw, where the type is a number from PaymentFactory. Defaults to PaymentFactory.NONE, meaning that this is a straight Deposit request. Added for version DEPOSIT_WITHDRAW.

protocolState

protected int protocolState
The state of the protocol that the caller wants to (re)start this request processing in. The contents are undefined here, it depends on the protocol implied by the type of Payment requested. This might be redundant (use Payment instead), or too simplistic (as Payment is signed, it can't be changed ...). We'll see. Added for version DEPOSIT_WITHDRAW.
Constructor Detail

DepositRequest

public DepositRequest(java.lang.String requestId,
                      AccountId acc,
                      AbstractPayment payment,
                      java.lang.String depositId,
                      byte[] desc)
Create an unsigned deposit request This constructor is the one usually called by SOX clients.
Parameters:
requestId - the request identifier (must be unique)
acc - the despositor's account
payment - the payment to be deposited
depositId - the deposit request identifier (must be unique)
desc - depositor's description of what this transaction is for

DepositRequest

public DepositRequest(java.lang.String requestId,
                      AccountId acc,
                      AbstractPayment payment,
                      AbstractPayment proto,
                      java.lang.String depositId,
                      byte[] desc)
Create an unsigned withdrawal request, to get a token payment signed.
Parameters:
requestId - the request identifier (must be unique)
acc - the despositor's account
payment - the payment to be deposited, pays for proto
proto - the payment to be withdrawn, paid for by payment
depositId - the deposit request identifier (must be unique)
desc - depositor's description of what this transaction is for

DepositRequest

public DepositRequest(byte[] depositReqData)
               throws SOXPacketException
Construct a deposit request object from a byte array that was previously returned from the encode() method of a deposit request object. If the signature is not present in the encoded data, the created request will be unsigned.
Parameters:
depositReqData - the previously encoded request

DepositRequest

public DepositRequest(java.io.InputStream is)
               throws SOXPacketException
Construct a deposit request object from data on an input stream that was previously returned from the encode() method of a deposit request object. If the signature is not present in the encoded data, the created request will be unsigned.
Method Detail

getVersion

public int getVersion()
Overrides:
getVersion in class Request

setVersion

public void setVersion(int v)

getName

public java.lang.String getName()
Description copied from class: Request
Returns the name of the packet as it goes on the wire.
Overrides:
getName in class Request

getPayment

public Payment getPayment()
Get the payment to be deposited.

getPay

public AbstractPayment getPay()

getProto

public AbstractPayment getProto()
Get the proto payment to be signed, if a withdrawal.

getPaymentId

public java.lang.String getPaymentId()
Get the identifier on the payment, as originally created by the payer. Note: although a java String is used, this identifier should only contain 8-bit ascii characters.

getTarget

public AccountId getTarget()
Get the account from which the transaction was drawn.

getSource

public AccountId getSource()
Get the account to which the payment is made.

getItem

public ItemId getItem()
Get the type of item (or "currency") on the payment (this is [almost certainly] the message digest of a ricardian contract).

getQty

public long getQty()
Get the quantity of the item on the payment

getPaymentDesc

public byte[] getPaymentDesc()
Get the description on the payment

getDepositId

public java.lang.String getDepositId()
Get the identifier on this deposit request Note: although a java String is used, this identifier should only contain 8-bit ascii characters.

getDepositDesc

public byte[] getDepositDesc()
Get the description for this deposit request

getTypeOfPayment

public int getTypeOfPayment()

setTypeOfPayment

public void setTypeOfPayment(int type)

getProtocolState

public int getProtocolState()

setProtocolState

public void setProtocolState(int state)

errorReply

public Reply errorReply(int e)
Get a Reply with Errors set.
Overrides:
errorReply in class Request
Tags copied from class: Request
Parameters:
err - is the error number to set the reply to

goodReply

public DepositReply goodReply(MailItem mail)

encode

public void encode(java.io.OutputStream os)
            throws java.io.IOException
Encode a deposit request to an output stream, suitable for using with RequestPacket to send to remote servers (which use the decode() method to re-construct the object).
Overrides:
encode in class Request
Parameters:
os - the stream on which to send the output

decode

public void decode(java.io.InputStream is)
            throws java.io.IOException,
                   SOXPacketException
Recover this deposit request object with the values from a deposit request on the input stream (such as might be sent by the encode() method of a deposit request object).
Overrides:
decode in class Request
Parameters:
is - the stream containing the encoded deposit request

toAscii

public java.lang.String toAscii()
                         throws java.io.IOException

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class Request

toString

public java.lang.String toString()
Convert this object to a human readable string
Overrides:
toString in class Request

vString

public java.lang.String vString()

example

public static DepositRequest example()

main

public static void main(java.lang.String[] args)

cycle

protected static void cycle()
                     throws java.lang.Exception

output

protected static void output()
                      throws java.lang.Exception

readWrite

protected static void readWrite()
                         throws java.lang.Exception

input

protected static void input()
                     throws java.lang.Exception