webfunds.sox
Class Account

java.lang.Object
  |
  +--webfunds.sox.Encodable
        |
        +--webfunds.sox.Account

public class Account
extends Encodable

This class contains all information needed about an account in order to be able to generate authentication information, except perhaps for holding a key passphrase, which is not stored in the Store (only in a runtime object).

See Also:
Serialized Form

Field Summary
protected  java.lang.String appl
          The Application string - can be set by a super application.
protected  IssuerFinder finder
          Subaccounts need some way to find an Issuer for an Item.
protected  long flags
          The Application flags - can be set by a super application.
protected  AccountId id
          The account id (which must match the public key fingerprint)
protected  java.security.PrivateKey key
          The private key that authorises account transactions.
protected  java.lang.String name
          The account name, can be assigned locally.
protected  java.security.PublicKey pubKey
          The public key that verifies account transactions.
protected  int req_version
           
protected  java.util.Hashtable subs
          Each subaccount is one-to-one with an item.
static int VERSION
          The version of the encoded object: 6 - added record of registrations 5 - added application string.
 
Constructor Summary
Account(byte[] data)
          Recover an Account object from a byte array.
Account(java.io.InputStream is)
          Recover an Account from an input stream.
Account(java.security.PublicKey pub, java.security.PrivateKey key)
          Create a new Account object
 
Method Summary
 void decode(java.io.InputStream is)
           
 void encode(java.io.OutputStream os)
           
 boolean equals(java.lang.Object obj)
           
static Account example()
           
 java.lang.String fp()
           
 java.lang.String getApplication()
           
 IssuerFinder getFinder()
           
 long getFlags()
           
 AccountId getId()
           
static Account getInstance()
           
static Account getInstance(int bits)
          Make a valid account.
 Issuer getIssuer(ItemId id)
           
 ItemId[] getItemIds()
           
 java.security.PrivateKey getKey()
           
 java.lang.String getName()
           
 java.security.PublicKey getPublicKey()
           
 SubAccount getSub(ItemId item)
           
 SubAccount[] getSubAccounts()
           
static Account getTestInstance()
           
 void insertSub(SubAccount sub)
          To add a sub into the account.
 boolean isFlags(long f)
           
static void main(java.lang.String[] arg)
           
 void newSub(SubAccount sub)
          To add a new sub into the account.
 void removeSubAccount(ItemId item)
          Only within this object, caller is responsible for other objects / persistant copies...
 void setApplication(java.lang.String appl)
           
 void setFinder(IssuerFinder f)
           
 void setFlags(long f)
           
 void setName(java.lang.String name)
           
 byte[] sign(byte[] b)
          Sign a block of data.
 void sign(Request req)
          Sign a Request.
 boolean subExists(ItemId item)
           
 java.lang.String toString()
          Convert this object to a string
 
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

VERSION

public static final int VERSION
The version of the encoded object: 6 - added record of registrations 5 - added application string. 4 - keys not certs. 3 - added separate sub accounts.

req_version

protected int req_version

name

protected java.lang.String name
The account name, can be assigned locally. Note the fingerprint of the public key, stored in id, is also a name.

appl

protected java.lang.String appl
The Application string - can be set by a super application. Should not be touched by SOX, just transported. A cheap way of avoiding extend.

flags

protected long flags
The Application flags - can be set by a super application. SOX: 1-16 Trader: 17-24

pubKey

protected java.security.PublicKey pubKey
The public key that verifies account transactions.

key

protected java.security.PrivateKey key
The private key that authorises account transactions.

id

protected AccountId id
The account id (which must match the public key fingerprint)

subs

protected java.util.Hashtable subs
Each subaccount is one-to-one with an item. An account can have many subaccounts.

finder

protected IssuerFinder finder
Subaccounts need some way to find an Issuer for an Item. The Issuer doesn't do anything until asked.
Constructor Detail

Account

public Account(java.security.PublicKey pub,
               java.security.PrivateKey key)
        throws SOXAccountException
Create a new Account object
Parameters:
pub - the public key for authentication
key - the private key used for account authorisation
SOXAccountException - the key was bad

Account

public Account(byte[] data)
        throws SOXPacketException
Recover an Account object from a byte array.
Parameters:
SOXPacketException - the data was bad

Account

public Account(java.io.InputStream is)
        throws SOXPacketException
Recover an Account from an input stream.
Parameters:
SOXPacketException - the data was bad
Method Detail

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

getApplication

public java.lang.String getApplication()

setApplication

public void setApplication(java.lang.String appl)

getFlags

public long getFlags()

setFlags

public void setFlags(long f)

isFlags

public boolean isFlags(long f)

getPublicKey

public java.security.PublicKey getPublicKey()

getKey

public java.security.PrivateKey getKey()

getId

public AccountId getId()
Returns:
The id for this account

getFinder

public IssuerFinder getFinder()

setFinder

public void setFinder(IssuerFinder f)

getIssuer

public Issuer getIssuer(ItemId id)
                 throws SOXIssuerException,
                        SOXLaterException

getInstance

public static Account getInstance()
                           throws SOXAccountException
Returns:
a new, empty, valid account.

getTestInstance

public static Account getTestInstance()
                               throws SOXAccountException
Returns:
a Test Account ONLY!

getInstance

public static Account getInstance(int bits)
                           throws SOXAccountException
Make a valid account.
Returns:
a new, empty, valid account.

sign

public byte[] sign(byte[] b)
            throws java.security.KeyException
Sign a block of data.
Returns:
a signature from this key on the data

sign

public void sign(Request req)
          throws SOXKeyException
Sign a Request. As it is the most likely thing that the SOX Account is called upon to do, it makes sense for the Account to know how to do it.

getSubAccounts

public SubAccount[] getSubAccounts()

getItemIds

public ItemId[] getItemIds()

removeSubAccount

public void removeSubAccount(ItemId item)
Only within this object, caller is responsible for other objects / persistant copies...

subExists

public boolean subExists(ItemId item)

getSub

public SubAccount getSub(ItemId item)
Returns:
the SubAccount for item, else null if not there

insertSub

public void insertSub(SubAccount sub)
To add a sub into the account. Passive, no initialisation.

newSub

public void newSub(SubAccount sub)
            throws SOXSubAccountException,
                   SOXAccountException
To add a new sub into the account.

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,
                   SOXPacketException
Overrides:
decode in class Encodable

equals

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

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()

example

public static Account example()

main

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