public class PayAccount extends java.lang.Object implements IXMLEncodable
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:
Modifier and Type | Field and Description |
---|---|
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 boolean |
m_bLocked |
private boolean |
m_bStatusUnknown |
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 long |
m_tBlocked |
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_ACCOUNT_INFO_UPDATE |
private java.lang.Object |
SYNC_BYTES |
private static long |
TIMEOUT_BLOCKED |
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 |
FIELD_XML_ELEMENT_CONTAINER_NAME, FIELD_XML_ELEMENT_NAME, XML_ATTR_ID, XML_ATTR_LANGUAGE, XML_ATTR_VERSION
Constructor and Description |
---|
PayAccount(org.w3c.dom.Element elemRoot,
IMiscPasswordReader a_passwordReader) |
PayAccount(XMLAccountCertificate certificate,
IMyPrivateKey privateKey,
PaymentInstanceDBEntry theBI,
XMLGenericText terms,
boolean a_bLock)
Creates a
PayAccount Object from the account certificate and the
private key. |
Modifier and Type | Method and Description |
---|---|
void |
addAccountListener(IAccountListener listener) |
long |
addCostConfirmation(XMLEasyCC cc,
boolean a_bForcedAdd) |
private long |
addCostConfirmation(XMLEasyCC cc,
boolean a_bForcedAdd,
boolean a_bFireChanged)
addCostConfirmation
|
void |
addMessageListener(IMessageListener listener) |
void |
addTransCert(XMLTransCert cert) |
static boolean |
canDoMonthlyOverusage(PayAccount a_account,
java.sql.Timestamp a_tNow) |
boolean |
canDoMonthlyOverusage(java.sql.Timestamp a_tNow) |
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) |
XMLAccountInfo |
fetchAccountInfo(boolean a_bForce)
Requests an AccountInfo XML structure from the BI.
|
XMLAccountInfo |
fetchAccountInfo(boolean a_bForce,
int a_connectionTimeout) |
void |
fireChangeEvent() |
private void |
fireMessageReceived(PayMessage message) |
private void |
fireMessageRemoved(PayMessage message) |
XMLAccountCertificate |
getAccountCertificate() |
XMLAccountInfo |
getAccountInfo() |
long |
getAccountNumber()
Returns the account's accountnumber
|
java.lang.String |
getAffiliate() |
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()
The bytes that have been transferred over the current service.
|
long |
getCurrentCredit()
Returns the current credit (i. e. deposit - spent) as counted by the Jap
itself.
|
long |
getCurrentCreditCalculated() |
long |
getCurrentCreditCalculatedAlsoNegative() |
long |
getCurrentCreditFromBalance() |
double |
getCurrentOverusageFactor(java.sql.Timestamp a_tNow) |
long |
getCurrentSpent()
returns totalBytes - getCurrentCredit() in BYTES or 0 if no accountInfo is given.
|
long |
getDeposit()
Returns the initial amount of the account (i. e. the sum of all incoming
payment)
|
java.lang.String |
getPIID() |
IMyPrivateKey |
getPrivateKey()
Returns the private key or null if the account is encrypted and not usable.
|
IMyPublicKey |
getPublicKey() |
XMLGenericText |
getTerms() |
java.util.Calendar |
getTermsDate() |
Transaction |
getTransaction() |
java.util.Vector |
getTransCerts()
Returns a vector with all transfer certificates
|
long |
getVolumeBytesMonthly() |
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 |
isBlocked() |
boolean |
isCharged() |
boolean |
isCharged(java.sql.Timestamp a_time)
Returns true if this account currently has a positive and usable balance.
|
boolean |
isLocked() |
boolean |
isSamePaymentInstance(java.lang.String a_PIID) |
boolean |
isStatusUnknown() |
boolean |
isTransactionExpired() |
boolean |
isUsed() |
boolean |
isWaitingForTransaction() |
void |
removeMessageListener(IMessageListener listener) |
XMLAccountInfo |
requestMonthlyOverusage() |
void |
resetCurrentBytes() |
protected void |
setAccountInfo(XMLAccountInfo info)
This is not just a setter method.
|
void |
setBackupDone(long a_backupTime) |
void |
setBlocked(boolean a_bBlock) |
private void |
setBlocked(boolean a_bBlock,
boolean a_bFireChanged) |
protected void |
setStatusUnknown(boolean a_bStatusUnknown) |
void |
setTerms(XMLGenericText xmlTerms) |
private void |
setValues(org.w3c.dom.Element elemRoot,
IMiscPasswordReader a_passwordReader) |
boolean |
shouldUpdateAccountInfo() |
java.lang.String |
toString() |
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,
boolean a_bDoNotDeactivate) |
void |
unlock() |
protected 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
|
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 static final long TIMEOUT_BLOCKED
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 boolean m_bLocked
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.lang.Object SYNC_ACCOUNT_INFO_UPDATE
private long m_tBlocked
private boolean m_bStatusUnknown
private java.util.Calendar m_termsDate
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
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, boolean a_bLock)
PayAccount
Object from the account certificate and the
private key.certificate
- account certificate issued by the BIprivateKey
- the private keypublic boolean isWaitingForTransaction()
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 objectjava.lang.Exception
public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
toXmlElement
in interface IXMLEncodable
a_doc
- a documentpublic org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc, java.lang.String a_password, boolean a_bDoNotDeactivate)
public void addTransCert(XMLTransCert cert) throws java.lang.Exception
java.lang.Exception
protected void setAccountInfo(XMLAccountInfo info) throws java.lang.Exception
info
- XMLAccountInfojava.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()
public boolean isCharged(java.sql.Timestamp a_time)
public boolean isSamePaymentInstance(java.lang.String a_PIID)
public boolean isBackupDone()
public long getBackupTime()
public void setBackupDone(long a_backupTime)
protected void setStatusUnknown(boolean a_bStatusUnknown)
public boolean isStatusUnknown()
public boolean hasAccountInfo()
public XMLAccountCertificate getAccountCertificate()
public java.sql.Timestamp getCreationTime()
public java.sql.Timestamp getBalanceValidTime()
public IMyPrivateKey getPrivateKey()
public IMyPublicKey getPublicKey()
public long getDeposit()
public Transaction getTransaction()
public long getCurrentCreditCalculated()
public boolean isUsed()
public long getCurrentCreditCalculatedAlsoNegative()
public long getCurrentCreditFromBalance()
public java.lang.String toString()
toString
in class java.lang.Object
public void unlock()
public boolean isLocked()
public boolean isBlocked()
public void setBlocked(boolean a_bBlock)
private void setBlocked(boolean a_bBlock, boolean a_bFireChanged)
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()
protected void updateCurrentBytes(long a_additionalBytes)
public long getCurrentBytes()
public long addCostConfirmation(XMLEasyCC cc, boolean a_bForcedAdd) throws java.lang.Exception
java.lang.Exception
private long addCostConfirmation(XMLEasyCC cc, boolean a_bForcedAdd, boolean a_bFireChanged) throws java.lang.Exception
java.lang.Exception
public void addAccountListener(IAccountListener listener)
public void addMessageListener(IMessageListener listener)
public void removeMessageListener(IMessageListener listener)
public void fireChangeEvent()
private void fireMessageReceived(PayMessage message)
private void fireMessageRemoved(PayMessage message)
public java.lang.String getAffiliate()
public XMLBalance getBalance()
public XMLAccountInfo 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 XMLAccountInfo fetchAccountInfo(boolean a_bForce, int a_connectionTimeout) throws java.lang.SecurityException, java.lang.Exception
java.lang.SecurityException
java.lang.Exception
public static boolean canDoMonthlyOverusage(PayAccount a_account, java.sql.Timestamp a_tNow)
public long getVolumeBytesMonthly()
public double getCurrentOverusageFactor(java.sql.Timestamp a_tNow)
public boolean canDoMonthlyOverusage(java.sql.Timestamp a_tNow)
public boolean isAccountInfoUpdated()
public boolean shouldUpdateAccountInfo()
public XMLTransCert charge(XMLGenericStrings a_parameters) throws java.lang.SecurityException, java.lang.Exception
accountNumber
- account numberjava.lang.Exception
java.lang.SecurityException
- if the account is encrypted an not usablepublic void updated()
public java.lang.String getPIID()
public PaymentInstanceDBEntry getBI()
public XMLAccountInfo requestMonthlyOverusage() throws java.lang.Exception
java.lang.Exception
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
Copyright © 2023. All rights reserved.