webfunds.sox
Class SimpleIssuer

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

public final class SimpleIssuer
extends Debug
implements Issuer

This class is a "SOX Agent" that passes basic requests to the Issuer. It should be passive until requested.


Field Summary
protected  BasicAgent basicAgent
          The agent communicating to the server (at the "basic" level)
protected  CommsAgent commsAgent
          The agent communicating to the server (at the "comms" level) Not used?
protected  java.security.PublicKey commsKey
          The communications certificate (key) for this current session.
protected  long deviation
           
protected  boolean isDead
           
protected  long lastsync
           
protected  java.lang.String logfix
           
protected  java.lang.String name
          The name of the issuer.
protected  java.lang.String reason
           
protected  int reqNo
           
protected  java.security.cert.Certificate serverCert
          The [server] certificate for this physical server.
protected  java.security.cert.Certificate signer
          The PKI is evolving...
protected  long timediff
          This is the difference between local time and the server's time.
protected  long timeLastRequest
           
 
Fields inherited from class webfunds.utils.Debug
bug, debugAll, logfix
 
Constructor Summary
SimpleIssuer(java.lang.String name, java.security.cert.Certificate signer, CommsAgent agent)
           
SimpleIssuer(java.lang.String name, java.security.cert.Certificate signer, CommsAgent agent, java.io.PrintWriter bug)
          Create a new SimpleIssuer object The SimpleIssuer object will normally be cached by the caller, but is not usefully stored on disk.
 
Method Summary
 void checkSync()
          Check the sync is reasonably new.
 java.lang.String getDead()
           
 java.lang.String getName()
          The name of this issuer
 void getReady()
          Do the things necessary for being ready for a request.
 long getTimeDeviation()
          A likely deviation.
 long getTimeDifference()
          Undefined how accurate it is.
 boolean isDead()
           
 byte[] request(Request request)
          Issue a request.
 void setAlive()
           
 void setDead()
           
 void setDead(java.lang.String s)
           
protected  void timesync()
          Do a timesync request to check on the issuer time.
 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

logfix

protected java.lang.String logfix

name

protected java.lang.String name
The name of the issuer. Not used here, just carried.

commsAgent

protected CommsAgent commsAgent
The agent communicating to the server (at the "comms" level) Not used?

basicAgent

protected BasicAgent basicAgent
The agent communicating to the server (at the "basic" level)

signer

protected java.security.cert.Certificate signer
The PKI is evolving... The [operator] certificate is the high level key used by the operator to sign and authenticate different servers in his administrative domain. It is infrequently used, the [server] keys are delegated with the task of day-to-day authentication of comms keys. The [server] key is the key that each physical server has in order to sign ephemeral (temporary, session) comms keys. The client can expected the [server] key to be around for many days, even months. It is signed by the [operator] key. Each session will request a comms key, which is made by the lower-level key exchange protocol. This comms key will be authenticated by being signed by the [server] key. The client can expect the comms key to be valid for at least one request, and hopefully more, up to many hours worth.

serverCert

protected java.security.cert.Certificate serverCert
The [server] certificate for this physical server.

commsKey

protected java.security.PublicKey commsKey
The communications certificate (key) for this current session.

reqNo

protected int reqNo

isDead

protected boolean isDead

reason

protected java.lang.String reason

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

lastsync

protected long lastsync

timeLastRequest

protected long timeLastRequest
Constructor Detail

SimpleIssuer

public SimpleIssuer(java.lang.String name,
                    java.security.cert.Certificate signer,
                    CommsAgent agent,
                    java.io.PrintWriter bug)
Create a new SimpleIssuer object The SimpleIssuer 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 certificate which signs this issuers certificate
agent - the comms agent that sends requests at the transport layer

SimpleIssuer

public SimpleIssuer(java.lang.String name,
                    java.security.cert.Certificate signer,
                    CommsAgent agent)
Method Detail

getReady

public void getReady()
              throws SOXIssuerException,
                     SOXLaterException
Do the things necessary for being ready for a request.
Specified by:
getReady in interface Issuer

getName

public java.lang.String getName()
The name of this issuer
Returns:
the name of the issuer

request

public byte[] request(Request request)
               throws SOXIssuerException,
                      SOXLaterException
Issue a request. Checks first to see if timesync is recent.
Specified by:
request in interface Issuer
Tags copied from interface: Issuer
Returns:
the reply packet

isDead

public boolean isDead()

setDead

public void setDead()

setDead

public void setDead(java.lang.String s)

setAlive

public void setAlive()

getDead

public java.lang.String getDead()

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

timesync

protected void timesync()
                 throws SOXIssuerException,
                        SOXLaterException
Do a timesync request to check on the issuer time.

checkSync

public void checkSync()
               throws SOXIssuerException,
                      SOXLaterException
Check the sync is reasonably new. If not, do a timesync. There is a presumption that is used within the requests, but that is not really the case as it only includes a timestamp which is ignored for the request code. (Historically, this was due to confusion as to which layer would prevent against replay attacks.)

toString

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