ecash.internet
Class ECashBuyer

java.lang.Object
  |
  +--ecash.internet.ECashGen
        |
        +--ecash.internet.ECashBuyer

public class ECashBuyer
extends ECashGen

Extension of the ECashGen class which adds specific methods for a buyer.

Author:
Michel Deriaz
See Also:
ECashGen, ECashBank, ECashSeller

Field Summary
 
Fields inherited from class ecash.internet.ECashGen
BANK_PORT, CHEAT_AMOUNTS_NOT_ALL_THE_SAME, CHEAT_NOTE_REUSED_BY_BUYER, CHEAT_NOTE_REUSED_BY_SELLER, CHEAT_WRONG_PASSWORD, CHEAT_WRONG_REVEALED_NOTES, CHEAT_WRONG_RIS, CHEAT_WRONG_SIGNATURE, CONNECTION_CLOSED_BY_SERVER, KEY_NOT_AVAILABLE, NOTES_EXP_SYNTAX_ERROR, NOTES_NOT_AVAILABLE, OK, OP_BUY, OP_DEPOSIT, OP_GET_KEY, OP_PAY, SELLER_PORT, SERVER_NOT_READY, TRANS_OK
 
Constructor Summary
ECashBuyer(ECashBuyerListener listener)
          Creates an ECashBuyer and loads the constants with the Const class.
 
Method Summary
 CreditDebitReport buy(java.lang.String bankAddress, java.lang.String bankAccount, char[] password, java.lang.String notesExp)
          Creates some notes and ask the bank to sign them.
 java.util.Vector getAmountList()
          Returns the list of all the amounts of the different notes.
 ECashBuyerState getState()
          Returns an ECashBuyerState object.
 int pay(java.lang.String sellerAddress, java.lang.String nickname, java.lang.String notesExp)
          Sends some notes to a seller.
 void setState(ECashBuyerState state)
          Initializes the class with the specified state.
 
Methods inherited from class ecash.internet.ECashGen
checkIfNotesAvailable, close, getKey, getKey, getREGEXP, handshakeClient, handshakeServer, hasBankKey, receiveCrypted, sendCrypted, sendCrypted, setKey, stopServer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ECashBuyer

public ECashBuyer(ECashBuyerListener listener)
Creates an ECashBuyer and loads the constants with the Const class.

Parameters:
listener - the class that implements the ECashBuyerListener interface
Method Detail

getState

public ECashBuyerState getState()
Returns an ECashBuyerState object. The idea is to write this object on a hard-disk (using Tools.writeObject()) and retrieve it through the setState() method next time the program is loaded (using Tools.readObject()).

Returns:
the current state
See Also:
ECashBuyerState

setState

public void setState(ECashBuyerState state)
Initializes the class with the specified state.

Parameters:
state - the state
See Also:
getState(), ECashBuyerState

getAmountList

public java.util.Vector getAmountList()
Returns the list of all the amounts of the different notes. Each entry of this Vector is a String.

Returns:
the list of all the amounts from the different notes

buy

public CreditDebitReport buy(java.lang.String bankAddress,
                             java.lang.String bankAccount,
                             char[] password,
                             java.lang.String notesExp)
Creates some notes and ask the bank to sign them.

Parameters:
bankAddress - the address of the bank, for example "124.123.132.233"
bankAccount - the account number
password - the password of the account
notesExp - the notes expression describing which notes must be created.
Returns:
a report describing the operation
See Also:
CreditDebitReport

pay

public int pay(java.lang.String sellerAddress,
               java.lang.String nickname,
               java.lang.String notesExp)
Sends some notes to a seller. Returns an int that represents how the operation succeeded. Value can be
ECashGen.OK,
ECashGen.NOTES_EXP_SYNTAX_ERROR,
ECashGen.NOTES_NOT_AVAILABLE,
ECashGen.SERVER_NOT_READY or
ECashGen.CONNECTION_CLOSED_BY_SERVER.

Parameters:
sellerAddress - the address of the seller, for example "124.123.132.233"
nickname - the name which will be sended, allowing the seller to identify the paiement.
notesExp - the notes expression describing which notes must be sended.
Returns:
an integer describing the success of the operation
See Also:
ECashGen