webfunds.sox
Class SmartIssuer

java.lang.Object
  |
  +--webfunds.utils.Debug
        |
        +--webfunds.sox.SmartIssuer

public class SmartIssuer
extends Debug
implements Issuer, IssuerFinder

Pretend to be a single SOX Server "Issuer", but actually manage through a list of equivalent entry points into the same virtual server. Hold a bunch of URLs, invoke objects on them on demand, and switch whenever a problem is detected. Name needs to change away from Issuer which is more oriented to money issuance than SOX Service.


Field Summary
protected  java.security.cert.Certificate cert
           
protected  SimpleIssuer current
           
protected  long deviation
           
protected  java.util.Vector others
           
protected  SimpleIssuer[] servers
           
protected  int size
           
protected  long timediff
          This is the difference between local time and the server's time.
protected  java.util.Vector urls
           
protected  int which
           
 
Fields inherited from class webfunds.utils.Debug
bug, debugAll, logfix
 
Constructor Summary
SmartIssuer(java.lang.String[] rawUrls, java.security.cert.Certificate operCert, java.io.PrintWriter bug)
          Create a new Issuer object The Issuer object will normally be cached by the caller, but is not usefully stored on disk.
 
Method Summary
 int checkNet()
          Try some net hits.
protected  void checkTimes()
           
 java.util.Vector convertToURLs(java.lang.String[] stringURLs)
          Convert a list of strings to URLs.
 Issuer getIssuer(ItemId id)
          For a single server scenario, this works as an IssuerFinder, by simply returning self.
 void getReady()
          Do the things necessary for being ready for a request.
 long getTimeDeviation()
          A likely deviation.
 long getTimeDifference()
          Undefined how accurate it is.
 byte[] request(Request req)
          Issue a request.
 void setOtherURLs(java.lang.String[] rawUrls)
          Add a list of non-Issuer URLs that should return something.
 void startSimpleServers(java.util.Vector urls)
          Do the things necessary for being ready for a request.
 java.lang.String toString()
           
 
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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

urls

protected java.util.Vector urls

others

protected java.util.Vector others

which

protected int which

size

protected int size

cert

protected java.security.cert.Certificate cert

current

protected SimpleIssuer current

servers

protected SimpleIssuer[] servers

timediff

protected long timediff
This is the difference between local time and the server's time. It is used to set time values to within a short range as a possible defence against replay attacks. It is not really relied upon by any application, but is useful to have for payment window settings. (Deposit replay attack is protected by the unique id.) The time should be persistant so that offline payments can be prepared.

deviation

protected long deviation
Constructor Detail

SmartIssuer

public SmartIssuer(java.lang.String[] rawUrls,
                   java.security.cert.Certificate operCert,
                   java.io.PrintWriter bug)
            throws SOXIssuerException
Create a new Issuer object The Issuer object will normally be cached by the caller, but is not usefully stored on disk. This call is passive, call getReady() to cause action.
Parameters:
name - our name for the issuer
signer - the [operator] certificate which signs the server's [server] certificate
agent - the comms agent that sends requests at the transport layer
Method Detail

setOtherURLs

public void setOtherURLs(java.lang.String[] rawUrls)
Add a list of non-Issuer URLs that should return something.

convertToURLs

public java.util.Vector convertToURLs(java.lang.String[] stringURLs)
Convert a list of strings to URLs. Ignores malformed ones.

getIssuer

public Issuer getIssuer(ItemId id)
For a single server scenario, this works as an IssuerFinder, by simply returning self.
Specified by:
getIssuer in interface IssuerFinder
Tags copied from interface: IssuerFinder
Returns:
a working Issuer, or null if none found.?

startSimpleServers

public void startSimpleServers(java.util.Vector urls)
Do the things necessary for being ready for a request. On return, current is set to a hopefully valid Issuer.

getReady

public void getReady()
              throws SOXLaterException,
                     SOXIssuerException
Do the things necessary for being ready for a request. On return, current is set to a hopefully valid Issuer.
Specified by:
getReady in interface Issuer

request

public byte[] request(Request req)
               throws SOXLaterException,
                      SOXIssuerException
Description copied from interface: Issuer
Issue a request.
Specified by:
request in interface Issuer
Tags copied from interface: Issuer
Returns:
the reply packet

checkNet

public int checkNet()
             throws SOXLaterException
Try some net hits.

getTimeDifference

public long getTimeDifference()
Description copied from interface: Issuer
Undefined how accurate it is. When in doubt, return 0. to adjust, subtract this number from local time
Specified by:
getTimeDifference in interface Issuer
Tags copied from interface: Issuer
Returns:
milliseconds local is ahead of the issuer

getTimeDeviation

public long getTimeDeviation()
Description copied from interface: Issuer
A likely deviation. Add this number to latest times, subtract from earliest.
Specified by:
getTimeDeviation in interface Issuer
Tags copied from interface: Issuer
Returns:
milliseconds of possible inaccuracy

checkTimes

protected void checkTimes()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object