|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--webfunds.utils.Debug
|
+--webfunds.ricardian.Contract
Ricardian Contract Base Class Rewritten from the sox.Contract and the Perl equivalents. Refer to: http://www.systemics.com/docs/ricardo/issuer/contract.html for the specification of a contract.
| Field Summary | |
static java.lang.String |
BEGIN
|
protected static int |
BOND_TYPE
|
static java.lang.String |
BOND_WORD
Recognised section names (they appear in the contract with square brackets on a line by themselves). |
static int |
CANHASH_CURRENT
|
static int |
CANHASH_WHITE_BUG
|
protected byte[] |
contractData
|
protected static int |
CURRENCY_TYPE
|
static java.lang.String |
CURRENCY_WORD
Recognised section names (they appear in the contract with square brackets on a line by themselves). |
protected java.text.DecimalFormat |
decimalFormat
|
protected java.lang.String |
decimalFormatPattern
|
static java.lang.String |
END
|
protected static java.lang.String |
errors
|
protected double |
factor
|
static java.lang.String |
FIELD_CONTRACT
|
static java.lang.String |
FIELD_OPERATOR
|
static java.lang.String |
FIELD_SERVER
|
static java.lang.String |
FIELD_TOP_LEVEL
|
protected IniFileReader |
fields
|
protected java.lang.String |
fileName
|
protected ItemId |
id
|
protected byte[] |
localData
|
protected java.lang.String |
logfix
|
protected java.lang.String |
mixedModeErrors
|
protected IniFileReader |
myFile
|
protected java.lang.String |
name
|
static java.lang.String |
PGP_BEGIN
|
static java.lang.String |
PGP_END
|
protected int |
power
|
static java.lang.String |
SECT_APPL
Recognised section names (they appear in the contract with square brackets on a line by themselves). |
static java.lang.String |
SECT_ISSUE
Recognised section names (they appear in the contract with square brackets on a line by themselves). |
static java.lang.String |
SECT_KEYS
Recognised section names (they appear in the contract with square brackets on a line by themselves). |
static java.lang.String |
SECT_LOCAL
Recognised section names (they appear in the contract with square brackets on a line by themselves). |
protected static int |
SERVER_TYPE
|
static java.lang.String |
SERVER_WORD
Recognised section names (they appear in the contract with square brackets on a line by themselves). |
protected static int |
SHARE_TYPE
|
static java.lang.String |
SHARE_WORD
Recognised section names (they appear in the contract with square brackets on a line by themselves). |
protected java.lang.String |
type
|
protected static int |
UNKNOWN_TYPE
|
protected byte[] |
userData
|
static java.lang.String |
USERID_CONTRACT
OpenPGP User Id tags - special Ricardian strings that indicate what this key is used for. |
static java.lang.String |
USERID_OPERATOR
OpenPGP User Id tags - special Ricardian strings that indicate what this key is used for. |
static java.lang.String |
USERID_SERVER
OpenPGP User Id tags - special Ricardian strings that indicate what this key is used for. |
static java.lang.String |
USERID_TOP_LEVEL
OpenPGP User Id tags - special Ricardian strings that indicate what this key is used for. |
static java.lang.String |
X509_BEGIN
|
static java.lang.String |
X509_END
|
| Fields inherited from class webfunds.utils.Debug |
bug,
debugAll,
logfix |
| Constructor Summary | |
Contract(byte[] cData,
byte[] lData,
byte[] yData)
A new Contract, made out of the contract data and any local/user data (null or empty is ok). |
|
| Method Summary | |
static byte[] |
doCanonicalDigest(byte[] txt)
Do a canonical hash on the data. |
static byte[] |
doCanonicalDigest(byte[] txt,
int version)
Do a canonical hash on the data. |
boolean |
equals(java.lang.Object obj)
only checks the contract hash, does not test local file or fuz file! |
static void |
error(java.lang.String e)
|
java.lang.String |
fileNameFromDigest(byte[] hash)
|
protected void |
flushMyFile()
|
java.lang.String[] |
getAllNames()
A contract is known by many names, including the hash and local name. |
double |
getAmount(long units)
Return the Unit of Account, e.g., dollars. |
java.lang.String |
getApplicationName()
Get the application-set name, if any. |
java.lang.String[] |
getArray(java.lang.String section,
java.lang.String item)
Get an array named item from section. |
static java.lang.String |
getBase(java.lang.String contract)
Take a string, interpret it is a Ricardian Contract, and extract out the base - the part from the BEGIN SIG to the keys. |
java.lang.String |
getContentErrors()
|
java.lang.String |
getContents()
|
static Contract |
getContract(byte[] con,
byte[] loc,
byte[] my)
Take the data, work out which type of contract it is, and invoke that object. |
static Contract |
getContract(java.io.File contractfile)
Read in a contract given a filename. |
static Contract |
getContract(java.net.URL contracturl)
Read in a contract given a URL |
java.text.DecimalFormat |
getDecimalFormat()
Get a DecimalFormat object suitable for this Contract. |
java.lang.String |
getDecimalFormatPattern()
Get the DecimalFormatpattern. |
static java.lang.String |
getErrors()
|
double |
getFactor()
|
java.lang.String |
getField(java.lang.String section,
java.lang.String item)
Get a field named item from section. |
java.lang.String |
getFileName()
|
ItemId |
getId()
|
ItemId |
getItemId()
|
java.lang.String |
getName()
Get the single best name for display of this contract. |
java.lang.String |
getNameOfUnitOfAccount()
Needs more support from the contract to do properly. |
java.lang.String |
getNameOfUnitOfContract()
Needs more support from the contract to do properly. |
static java.security.cert.Certificate |
getOpenPGPCertFromString(java.lang.String text,
java.lang.String name,
int errno,
java.lang.String userIdTag)
|
int |
getPower()
|
java.lang.String |
getPrintableAmount(long qty)
Get a printable string in unit of account. |
static java.lang.String |
getRoot(java.lang.String name)
|
java.lang.String[] |
getSectionItems(java.lang.String section)
Get the fieldnames in a section Doesn't look in myFile. |
java.lang.String[] |
getSectionNames()
Get all the section names. |
protected java.security.cert.Certificate |
getServerCert()
This is the SOX Server [operator] key. |
java.lang.String |
getSymbol()
Get the single shortest name for display of this contract. |
int |
getType()
getType - returns type of this contract. |
static int |
getType(byte[] contractData)
Work out what type of contract this is. |
java.lang.String |
getUniqueName()
|
long |
getUnits(double amount)
Return the Unit of Contract, e.g., cents. |
double |
getUnitsOfAccount(long units)
Consider casting the result to a float to clean FP errors. |
long |
getUnitsOfContract(double amount)
unitsOfAccount = dollars, unitsOfContract = cents |
static java.security.cert.Certificate |
getX509CertFromString(java.lang.String text,
java.lang.String name,
int errno)
|
int |
hashCode()
|
protected boolean |
isChanged(java.io.File f,
byte[] data)
|
boolean |
isPower()
|
static void |
main(java.lang.String[] arg)
|
static byte[] |
prepareContractForCanonicalDigest(byte[] data,
int v)
This method prepares data to be canonically hashed: + all lines end with \r\n + all trailing whitespace is removed (codes <= BEFORE AFTER SIGNED USED ARMOURY.PREPAREDATATOSIGN(). |
static byte[] |
prepareContractForCanonicalDigest2(byte[] data)
|
void |
readAndSetPower()
Units of account / contract used to be part of the Currency contract, but have been since widened to be a basic function of all contracts (at least, as far as decimal goes). |
void |
removeFiles()
Remove these files - only - from the store. |
void |
removeFiles(java.io.File dir)
Remove these files - only - from dir. |
protected void |
removeFiles(java.io.File dir,
java.lang.String name)
Given a root name, remove all my files from dir. |
void |
reSaveAsFile(Contract contract)
re-Save the contract if it has changed. |
void |
reSaveAsFile(java.io.File dir,
Contract contract)
|
static void |
resetErrors()
|
void |
saveAsFile(java.io.File dir)
Save the contract into file(s) rooted in a unique name. |
void |
saveAsFile(java.io.File dir,
java.lang.String name)
Save the contract into file(s) rooted in name. |
protected void |
saveFile(java.io.File f,
byte[] data)
Save a file. |
void |
setApplicationName(java.lang.String name)
Applications can add their own name for GUIs. |
void |
setDecimalFormat(java.text.DecimalFormat d)
|
void |
setDecimalFormatPattern(java.lang.String s)
Set the DecimalFormat(pattern) for all future get calls. |
void |
setField(java.lang.String section,
java.lang.String item,
java.lang.String value)
Set a field that can be recorded and returned. |
protected void |
setPower(int p)
|
java.lang.String |
toString()
|
boolean |
verifyContract()
Verify that the contract is signed correctly by the cert. |
boolean |
verifyOpenPGPSignatures()
Verify that the OpenPGP contract is signed correctly and that all certs match our current path goodness criteria: 1. |
boolean |
verifyX509Signatures()
Verify that the x509 contract is signed correctly and that all certs match our current path goodness criteria. |
| Methods inherited from class webfunds.utils.Debug |
debug,
debug,
debug,
debug,
err,
getDebug,
logend,
logmsg,
logstart,
logword |
| Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
| Field Detail |
public static final java.lang.String SECT_ISSUE
public static final java.lang.String SECT_KEYS
public static final java.lang.String SECT_LOCAL
public static final java.lang.String SECT_APPL
public static final java.lang.String CURRENCY_WORD
public static final java.lang.String BOND_WORD
public static final java.lang.String SHARE_WORD
public static final java.lang.String SERVER_WORD
protected static final int CURRENCY_TYPE
protected static final int BOND_TYPE
protected static final int SHARE_TYPE
protected static final int SERVER_TYPE
protected static final int UNKNOWN_TYPE
protected byte[] contractData
protected byte[] localData
protected byte[] userData
protected IniFileReader fields
protected IniFileReader myFile
protected ItemId id
protected java.lang.String name
protected java.lang.String fileName
protected java.lang.String type
protected int power
protected double factor
protected java.lang.String decimalFormatPattern
protected java.text.DecimalFormat decimalFormat
protected java.lang.String logfix
protected java.lang.String mixedModeErrors
public static final int CANHASH_WHITE_BUG
public static final int CANHASH_CURRENT
protected static java.lang.String errors
public static final java.lang.String BEGIN
public static final java.lang.String X509_BEGIN
public static final java.lang.String PGP_BEGIN
public static final java.lang.String END
public static final java.lang.String X509_END
public static final java.lang.String PGP_END
public static final java.lang.String USERID_TOP_LEVEL
public static final java.lang.String USERID_CONTRACT
public static final java.lang.String USERID_SERVER
public static final java.lang.String USERID_OPERATOR
public static final java.lang.String FIELD_TOP_LEVEL
public static final java.lang.String FIELD_CONTRACT
public static final java.lang.String FIELD_SERVER
public static final java.lang.String FIELD_OPERATOR
| Constructor Detail |
public Contract(byte[] cData,
byte[] lData,
byte[] yData)
throws ContractException
| Method Detail |
public int getPower()
public boolean isPower()
protected void setPower(int p)
public double getFactor()
public void readAndSetPower()
throws ContractException
public void setDecimalFormatPattern(java.lang.String s)
public void setDecimalFormat(java.text.DecimalFormat d)
public java.lang.String getDecimalFormatPattern()
public java.text.DecimalFormat getDecimalFormat()
public java.lang.String getPrintableAmount(long qty)
public long getUnitsOfContract(double amount)
public double getUnitsOfAccount(long units)
public java.lang.String getNameOfUnitOfContract()
public java.lang.String getNameOfUnitOfAccount()
public java.lang.String fileNameFromDigest(byte[] hash)
public java.lang.String getContentErrors()
public static byte[] doCanonicalDigest(byte[] txt)
throws ContractException
txt - is the file data
public static byte[] doCanonicalDigest(byte[] txt,
int version)
throws ContractException
version - 3 is current
2 is without trailing whitespace strippedpublic static java.lang.String getErrors()
public static void resetErrors()
public static void error(java.lang.String e)
public static byte[] prepareContractForCanonicalDigest(byte[] data,
int v)
throws ContractException
data - the original data
public static byte[] prepareContractForCanonicalDigest2(byte[] data)
throws java.io.IOException
public static Contract getContract(byte[] con,
byte[] loc,
byte[] my)
throws ContractException
public static Contract getContract(java.io.File contractfile)
throws ContractException
contractfile - name
public static java.lang.String getRoot(java.lang.String name)
throws ContractException
name - is the filename or URL (string)
public static Contract getContract(java.net.URL contracturl)
throws ContractException
contractfile - name with .asc suffix
public static int getType(byte[] contractData)
throws ContractException
public int getType()
public ItemId getId()
public ItemId getItemId()
public java.lang.String getUniqueName()
public java.lang.String getFileName()
public java.lang.String getName()
public java.lang.String getSymbol()
public java.lang.String[] getAllNames()
public void setApplicationName(java.lang.String name)
throws ContractException
public java.lang.String getApplicationName()
protected java.security.cert.Certificate getServerCert()
throws ContractException
public static java.security.cert.Certificate getOpenPGPCertFromString(java.lang.String text,
java.lang.String name,
int errno,
java.lang.String userIdTag)
throws ContractException
public static java.security.cert.Certificate getX509CertFromString(java.lang.String text,
java.lang.String name,
int errno)
throws ContractException
public boolean verifyContract()
throws ContractException
public boolean verifyOpenPGPSignatures()
throws ContractException
public boolean verifyX509Signatures()
throws ContractException
public long getUnits(double amount)
public double getAmount(long units)
public void setField(java.lang.String section,
java.lang.String item,
java.lang.String value)
throws ContractException
public java.lang.String getField(java.lang.String section,
java.lang.String item)
public java.lang.String[] getArray(java.lang.String section,
java.lang.String item)
public java.lang.String[] getSectionItems(java.lang.String section)
public java.lang.String[] getSectionNames()
public void removeFiles()
public void removeFiles(java.io.File dir)
protected void removeFiles(java.io.File dir,
java.lang.String name)
public void saveAsFile(java.io.File dir)
throws java.io.IOException
public void saveAsFile(java.io.File dir,
java.lang.String name)
throws java.io.IOException
public void reSaveAsFile(java.io.File dir,
Contract contract)
throws java.io.IOException
public void reSaveAsFile(Contract contract)
throws java.io.IOException
protected void saveFile(java.io.File f,
byte[] data)
throws java.io.IOException
protected boolean isChanged(java.io.File f,
byte[] data)
throws java.io.IOException
protected void flushMyFile()
throws java.io.IOException
public java.lang.String getContents()
throws java.io.IOException
public int hashCode()
public boolean equals(java.lang.Object obj)
public java.lang.String toString()
public static java.lang.String getBase(java.lang.String contract)
throws ContractException
public static void main(java.lang.String[] arg)
throws ContractException,
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||