|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object anon.pay.PayAccount
public class PayAccount
This class encapsulates one account and all additional data associated to one
account. This includes the key pair, the account number, the transfer certificates
for charging the account, cost confirmations and a balance certificate.
- XMLAccountcertificate (public key + additional info (creation date etc))
- Key Pair
- XMLTransCert (one per charge)
- XMLAccountInfo (XMLBalance + cost confirmations)
- XMLGenericText : contains the terms and conditions (as current at the time of account creation)
For storing the account data in a file the toXmlElement()
method is provided. It is recommended to encrypt the output of this method
before storing it to disk, because it includes the secret private key.
The XML structure is as follows:
Field Summary | |
---|---|
static long |
ACCOUNT_MAX_UPDATE_INTERVAL_MS
|
static long |
ACCOUNT_MIN_UPDATE_INTERVAL_MS
|
private XMLAccountCertificate |
m_accountCertificate
contains the account certificate |
private XMLAccountInfo |
m_accountInfo
contains the current account info (balance and cost confirmations) |
private java.util.Vector |
m_accountListeners
|
private boolean |
m_bAccountInfoUpdateRunning
|
private long |
m_currentBytes
the number of bytes which have been used but not confirmed yet |
private org.w3c.dom.Document |
m_encryptedPrivateKey
|
private long |
m_lastAccountInfoUpdate
|
private long |
m_lBackupDone
|
private java.util.Vector |
m_messageListeners
|
private long |
m_mySpent
internal value for spent bytes. |
private IMyPrivateKey |
m_privateKey
contains the private key associated with this account |
private java.lang.String |
m_strBiID
|
private XMLGenericText |
m_terms
contains the terms and conditions as gotten from the JPI when the account was created |
private java.util.Calendar |
m_termsDate
|
private PaymentInstanceDBEntry |
m_theBI
|
private java.util.Vector |
m_transCerts
contains zero or more xml transfer certificates as XMLTransCert |
static int |
MAX_KBYTES_COUNTING_AS_EMPTY
|
private static long |
NEW_ACCOUNT_EXPIRATION_TIME
|
private java.lang.Object |
SYNC_BYTES
|
private static long |
TRANSACTION_EXPIRATION
|
private static java.lang.String |
VERSION
|
private static java.lang.String |
XML_ATTR_ACTIVE
|
private static java.lang.String |
XML_BACKUP_DONE
|
static java.lang.String |
XML_ELEMENT_NAME
|
Fields inherited from interface anon.util.IXMLEncodable |
---|
FIELD_XML_ELEMENT_CONTAINER_NAME, FIELD_XML_ELEMENT_NAME, XML_ATTR_ID, XML_ATTR_LANGUAGE, XML_ATTR_VERSION |
Constructor Summary | |
---|---|
PayAccount(org.w3c.dom.Element elemRoot,
IMiscPasswordReader a_passwordReader)
|
|
PayAccount(XMLAccountCertificate certificate,
IMyPrivateKey privateKey,
PaymentInstanceDBEntry theBI,
XMLGenericText terms)
Creates a PayAccount Objekt from the account certificate and the
private key. |
Method Summary | |
---|---|
void |
addAccountListener(IAccountListener listener)
|
long |
addCostConfirmation(XMLEasyCC cc)
addCostConfirmation |
void |
addMessageListener(IMessageListener listener)
|
void |
addTransCert(XMLTransCert cert)
|
XMLTransCert |
charge(XMLGenericStrings a_parameters)
Request a transfer certificate from the BI |
static java.lang.String |
checkCouponCode(java.lang.String a_code)
|
private void |
deactivate(org.w3c.dom.Element elemKey)
|
void |
decryptPrivateKey(IMiscPasswordReader a_passwordReader)
|
private void |
decryptPrivateKey(org.w3c.dom.Node a_elemRoot,
IMiscPasswordReader a_passwordReader,
boolean a_bDeactivated)
|
boolean |
equals(java.lang.Object a_account)
|
void |
fetchAccountInfo(boolean a_bForce)
Requests an AccountInfo XML structure from the BI. |
void |
fetchAccountInfo(boolean a_bForce,
int a_connectionTimeout)
|
private void |
fireChangeEvent()
|
private void |
fireMessageReceived(PayMessage message)
|
private void |
fireMessageRemoved(PayMessage message)
|
XMLAccountCertificate |
getAccountCertificate()
|
XMLAccountInfo |
getAccountInfo()
|
long |
getAccountNumber()
Returns the account's accountnumber |
long |
getBackupTime()
|
XMLBalance |
getBalance()
getBalance |
java.sql.Timestamp |
getBalanceValidTime()
liefert zurueck, wann das Guthaben ungueltig wird (bei flatrate modellen) |
PaymentInstanceDBEntry |
getBI()
|
java.sql.Timestamp |
getCreationTime()
Liefert das Erstellungsdatum des Kontos. |
long |
getCurrentBytes()
|
long |
getCurrentCredit()
Returns the current credit (i. |
long |
getCurrentCreditCalculated()
Returns the current credit (i. |
long |
getCurrentCreditCalculatedAlsoNegative()
|
long |
getCurrentCreditFromBalance()
|
long |
getCurrentSpent()
returns totalBytes - getCurrentCredit() in BYTES or 0 if no accountInfo is given. |
long |
getDeposit()
Returns the initial amount of the account (i. |
java.lang.String |
getPIID()
|
IMyPrivateKey |
getPrivateKey()
Returns the private key or null if the account is encrypted and not usable. |
IMyPublicKey |
getPublicKey()
|
long |
getSpent()
Returns the amount already spent. |
XMLGenericText |
getTerms()
|
java.util.Calendar |
getTermsDate()
|
java.util.Vector |
getTransCerts()
Returns a vector with all transfer certificates |
boolean |
hasAccountInfo()
Returns true when an accountInfo object exists. |
boolean |
hasExpired()
|
boolean |
hasExpired(java.sql.Timestamp a_time)
|
int |
hashCode()
|
boolean |
isAccountInfoUpdated()
Returns true if the account info/balance has been updated at least once at runtime. |
boolean |
isBackupDone()
|
boolean |
isCharged(java.sql.Timestamp a_time)
Returns true if this account currently has a positive and usable balance. |
boolean |
isFlatrateActive()
|
boolean |
isTransactionExpired()
|
void |
removeMessageListener(IMessageListener listener)
|
void |
resetCurrentBytes()
|
private void |
setAccountInfo(XMLAccountInfo info)
This is not just a setter method. |
void |
setBackupDone(long a_backupTime)
|
void |
setTerms(XMLGenericText xmlTerms)
|
private void |
setValues(org.w3c.dom.Element elemRoot,
IMiscPasswordReader a_passwordReader)
|
boolean |
shouldUpdateAccountInfo()
|
org.w3c.dom.Element |
toXmlElement(org.w3c.dom.Document a_doc)
Returns the xml representation of the account |
org.w3c.dom.Element |
toXmlElement(org.w3c.dom.Document a_doc,
java.lang.String a_password)
|
void |
updateCurrentBytes(long a_additionalBytes)
|
long |
updateCurrentBytes(PacketCounter a_packetCounter)
Asks the PacketCounter for the current number of transferred bytes and updates the internal value. |
void |
updated()
Marks the account as updated so a ChangeEvent gets fired |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String XML_ELEMENT_NAME
private static final java.lang.String XML_ATTR_ACTIVE
private static final java.lang.String XML_BACKUP_DONE
public static final long ACCOUNT_MIN_UPDATE_INTERVAL_MS
public static final long ACCOUNT_MAX_UPDATE_INTERVAL_MS
private final java.lang.Object SYNC_BYTES
private static final long NEW_ACCOUNT_EXPIRATION_TIME
private static final java.lang.String VERSION
private java.util.Vector m_transCerts
private XMLAccountCertificate m_accountCertificate
private XMLAccountInfo m_accountInfo
private XMLGenericText m_terms
private IMyPrivateKey m_privateKey
private org.w3c.dom.Document m_encryptedPrivateKey
private long m_currentBytes
private java.util.Vector m_accountListeners
private java.util.Vector m_messageListeners
private long m_lBackupDone
private long m_lastAccountInfoUpdate
private boolean m_bAccountInfoUpdateRunning
private java.util.Calendar m_termsDate
private static final long TRANSACTION_EXPIRATION
public static final int MAX_KBYTES_COUNTING_AS_EMPTY
private long m_mySpent
XMLBalance
, but the value in XMLBalance is calculated
by the BI while this here is calculated by the Jap. So the value here might
be more up to date in case the XMLBalance certificate is old.
private PaymentInstanceDBEntry m_theBI
private java.lang.String m_strBiID
Constructor Detail |
---|
public PayAccount(org.w3c.dom.Element elemRoot, IMiscPasswordReader a_passwordReader) throws java.lang.Exception
java.lang.Exception
public PayAccount(XMLAccountCertificate certificate, IMyPrivateKey privateKey, PaymentInstanceDBEntry theBI, XMLGenericText terms)
PayAccount
Objekt from the account certificate and the
private key.
certificate
- account certificate issued by the BIprivateKey
- the private keyMethod Detail |
---|
public boolean isTransactionExpired()
private void setValues(org.w3c.dom.Element elemRoot, IMiscPasswordReader a_passwordReader) throws java.lang.Exception
elemRoot
- Elementa_passwordReader
- a password reader; this method adds the account number as message object
java.lang.Exception
public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
toXmlElement
in interface IXMLEncodable
a_doc
- a document
public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc, java.lang.String a_password)
public void addTransCert(XMLTransCert cert) throws java.lang.Exception
java.lang.Exception
private void setAccountInfo(XMLAccountInfo info) throws java.lang.Exception
info
- XMLAccountInfo
java.lang.Exception
public boolean equals(java.lang.Object a_account)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public long getAccountNumber()
public boolean hasExpired()
public boolean hasExpired(java.sql.Timestamp a_time)
public boolean isCharged(java.sql.Timestamp a_time)
public boolean isBackupDone()
public long getBackupTime()
public void setBackupDone(long a_backupTime)
public boolean hasAccountInfo()
public XMLAccountCertificate getAccountCertificate()
public java.sql.Timestamp getCreationTime()
public java.sql.Timestamp getBalanceValidTime()
public IMyPrivateKey getPrivateKey()
public IMyPublicKey getPublicKey()
public long getSpent()
public long getDeposit()
public long getCurrentCreditCalculated()
Pay.fetchAccountInfo(long)
first.
public long getCurrentCreditCalculatedAlsoNegative()
public long getCurrentCreditFromBalance()
public long getCurrentCredit()
updateCurrentBytes()
first.
public long getCurrentSpent()
public XMLAccountInfo getAccountInfo()
public XMLGenericText getTerms()
public void setTerms(XMLGenericText xmlTerms)
public java.util.Calendar getTermsDate()
public java.util.Vector getTransCerts()
XMLTransCert
public long updateCurrentBytes(PacketCounter a_packetCounter) throws java.lang.Exception
java.lang.Exception
public void resetCurrentBytes()
public void updateCurrentBytes(long a_additionalBytes)
public long getCurrentBytes()
public long addCostConfirmation(XMLEasyCC cc) throws java.lang.Exception
java.lang.Exception
public void addAccountListener(IAccountListener listener)
public void addMessageListener(IMessageListener listener)
public void removeMessageListener(IMessageListener listener)
private void fireChangeEvent()
private void fireMessageReceived(PayMessage message)
private void fireMessageRemoved(PayMessage message)
public XMLBalance getBalance()
public boolean isFlatrateActive()
public void fetchAccountInfo(boolean a_bForce) throws java.lang.SecurityException, java.lang.Exception
a_bForce
- if the update is forced; if not, it might be prevented by
PayAccountsFile.isBalanceAutoUpdateEnabled()
java.lang.Exception
java.lang.SecurityException
- if the account is encrypted and therefore not usablepublic void fetchAccountInfo(boolean a_bForce, int a_connectionTimeout) throws java.lang.SecurityException, java.lang.Exception
java.lang.SecurityException
java.lang.Exception
public boolean isAccountInfoUpdated()
public boolean shouldUpdateAccountInfo()
public XMLTransCert charge(XMLGenericStrings a_parameters) throws java.lang.SecurityException, java.lang.Exception
accountNumber
- account number
java.lang.Exception
java.lang.SecurityException
- if the account is encrypted an not usablepublic void updated()
public java.lang.String getPIID()
public PaymentInstanceDBEntry getBI()
public static java.lang.String checkCouponCode(java.lang.String a_code)
public void decryptPrivateKey(IMiscPasswordReader a_passwordReader) throws java.lang.Exception
java.lang.Exception
private void decryptPrivateKey(org.w3c.dom.Node a_elemRoot, IMiscPasswordReader a_passwordReader, boolean a_bDeactivated) throws java.lang.Exception
java.lang.Exception
private void deactivate(org.w3c.dom.Element elemKey) throws java.lang.Exception
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |