webfunds.sox
Class SubAccount

java.lang.Object
  |
  +--webfunds.sox.Encodable
        |
        +--webfunds.sox.SubAccount
Direct Known Subclasses:
ValueAccount

public abstract class SubAccount
extends Encodable

SubAccount handles an Item for an account, and relies on the parent Account for the key.

See Also:
Serialized Form

Field Summary
protected  Account acct
          Parent account.
protected static int ACTIVE
           
protected static int FROZEN
           
protected  Issuer issuer
          Is capable of sending requests to the server.
protected  ItemId itemId
          The item identifier - contract hash - of this account.
protected static int NEW
           
protected static int REGISTERED
           
protected  int reqNo
          The request number (for this session)
protected static int RETRY
           
protected  int status
          Status of subaccount.
 
Constructor Summary
SubAccount(byte[] data)
           
SubAccount(java.io.InputStream is)
           
SubAccount(ItemId itemId)
          Create a new SubAccount object.
 
Method Summary
 java.util.Date adjustTime(java.util.Date tim, boolean earliest)
          always works, might be ultra conservative deprecated? not really used, SOX shouldn't know about Dates.
 long adjustTime(long tim, boolean earliest)
          always works, might be ultra conservative
protected  void checkFrozen(java.lang.String s)
          Handy to save lots of exception calls User is not supposed to call this, but maybe the software doesn't care.
protected  void checkNet()
          Handy to save lots of exception calls
 void decode(java.io.InputStream is)
           
 void delete()
          Call this to delete.
protected  Reply doRequest(Request req)
          Sort out exceptions.
protected  Reply doRequest(Request req, boolean retry)
          Convert the request into a reply.
 void encode(java.io.OutputStream os)
           
 boolean equals(java.lang.Object obj)
           
 java.lang.String fp()
           
 void freeze()
          Call this to freeze the subaccount.
 Account getAccount()
           
 Issuer getIssuer()
           
 ItemId getItemId()
           
 int getStatus()
           
 void init()
          Initialise the subaccount, after adding into the accout.
 boolean isActive()
           
 boolean isFrozen()
           
 boolean isNew()
           
 boolean isRegistered()
           
 boolean isRetry()
           
 void logmsg(java.lang.String s)
           
 java.lang.String[] nym(long flags, java.lang.String[] names)
          Send some details to turn the registered key into a Nym.
 AccountId register()
          Register a new certificate with the server
protected  byte[] requestExtra(Request req)
          Sorts out exceptions.
 void setAccount(Account acct)
           
 void setIssuer(Issuer issuer)
           
 java.lang.String toString()
          Convert this object to a string
 MailItem[] update(MailId[] mails)
          Update the mail by sending confirmations to the server, and getting new items of mail back in the reply.
 
Methods inherited from class webfunds.sox.Encodable
decode, encode, main, 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

issuer

protected Issuer issuer
Is capable of sending requests to the server.

itemId

protected ItemId itemId
The item identifier - contract hash - of this account.

acct

protected Account acct
Parent account. It knows where to find SOXServers.

reqNo

protected transient int reqNo
The request number (for this session)

NEW

protected static final int NEW

REGISTERED

protected static final int REGISTERED

ACTIVE

protected static final int ACTIVE

RETRY

protected static final int RETRY

FROZEN

protected static final int FROZEN

status

protected int status
Status of subaccount.
Constructor Detail

SubAccount

public SubAccount(ItemId itemId)
Create a new SubAccount object. A subaccount manages the SOX requests and replies for a particular item (and therefore a particular server), which is (normally) a Ricardian contract hash. A subaccount is normally part of an account, which holds the keys.
Parameters:
acct - the account that holds authentication keys
itemid - the identifier for this subaccount

SubAccount

public SubAccount(byte[] data)
           throws SOXPacketException

SubAccount

public SubAccount(java.io.InputStream is)
           throws SOXPacketException
Method Detail

getItemId

public ItemId getItemId()

setAccount

public void setAccount(Account acct)

getAccount

public Account getAccount()

isNew

public boolean isNew()

isRegistered

public boolean isRegistered()

isActive

public boolean isActive()

isRetry

public boolean isRetry()

isFrozen

public boolean isFrozen()

getStatus

public int getStatus()

logmsg

public void logmsg(java.lang.String s)

getIssuer

public Issuer getIssuer()
                 throws SOXSubAccountException,
                        SOXLaterException
Returns:
an issuer for use with this subaccount.

setIssuer

public void setIssuer(Issuer issuer)
Returns:
an issuer for use with this subaccount.

adjustTime

public java.util.Date adjustTime(java.util.Date tim,
                                 boolean earliest)
always works, might be ultra conservative deprecated? not really used, SOX shouldn't know about Dates.
Returns:
an adjusted Date

adjustTime

public long adjustTime(long tim,
                       boolean earliest)
always works, might be ultra conservative
Returns:
an adjusted long time

init

public void init()
          throws SOXSubAccountException,
                 SOXLaterException,
                 SOXKeyException
Initialise the subaccount, after adding into the accout. Extending classes should override this if the actions taken are not useful: register()

register

public AccountId register()
                   throws SOXSubAccountException,
                          SOXLaterException,
                          SOXKeyException
Register a new certificate with the server
Returns:
the account id used for the certificate

requestExtra

protected byte[] requestExtra(Request req)
                       throws SOXSubAccountException,
                              SOXLaterException
Sorts out exceptions.

update

public MailItem[] update(MailId[] mails)
                  throws SOXSubAccountException,
                         SOXLaterException,
                         SOXKeyException,
                         SOXPacketException
Update the mail by sending confirmations to the server, and getting new items of mail back in the reply. Do this whenever expecting something to come back. The server will duplicate the important replies into the mail box, in case replies don't make it. C.f., receipts.

nym

public java.lang.String[] nym(long flags,
                              java.lang.String[] names)
                       throws SOXSubAccountException,
                              SOXLaterException,
                              SOXKeyException,
                              SOXArgsException,
                              SOXRequestException
Send some details to turn the registered key into a Nym. I'm not sure where this belongs as yet...
Throws:
SOXArgsException - if item in payment is invalid
SOXLaterException - if there is no ability to talk to the server
SOXSubAccountException - if something goes wrong with access
SOXKeyException - if something goes wrong with signing

doRequest

protected Reply doRequest(Request req,
                          boolean retry)
                   throws SOXSubAccountException,
                          SOXRequestException,
                          SOXLaterException,
                          SOXKeyException
Convert the request into a reply. This catches a number of local snafus that are reported by the SOX Server, corrects them, and retries. As there are a number of SOX Server used by this account it is hard to keep track of who has registered where (bearing in mind that there are few issuers, and many contracts). So, we do it by feedback for the moment.
Parameters:
retry - true if this call is already recursive

doRequest

protected Reply doRequest(Request req)
                   throws SOXSubAccountException,
                          SOXLaterException
Sort out exceptions. There's a problem here. No positive ack is delivered for failure, so can't tell whether it is positive failure or lost/failures.

freeze

public void freeze()
Call this to freeze the subaccount.

delete

public void delete()
            throws SOXSubAccountException
Call this to delete. A no-op.

checkFrozen

protected void checkFrozen(java.lang.String s)
                    throws SOXSubAccountException
Handy to save lots of exception calls User is not supposed to call this, but maybe the software doesn't care.

checkNet

protected void checkNet()
                 throws SOXLaterException
Handy to save lots of exception calls

encode

public void encode(java.io.OutputStream os)
            throws java.io.IOException
Overrides:
encode in class Encodable

decode

public void decode(java.io.InputStream is)
            throws java.io.IOException
Overrides:
decode in class Encodable

toString

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

fp

public java.lang.String fp()

equals

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