anon.infoservice
Class InfoServiceHolder

java.lang.Object
  extended by java.util.Observable
      extended by anon.infoservice.InfoServiceHolder
All Implemented Interfaces:
anon.util.IXMLEncodable

public class InfoServiceHolder
extends java.util.Observable
implements anon.util.IXMLEncodable

This class holds the instances of the InfoService class for the JAP client and is a singleton. The instance of this class is observable and will send a notification with an InfoServiceHolderMessage, if the preferred InfoService or the InfoService management policy were changed.


Field Summary
static boolean DEFAULT_INFOSERVICE_CHANGES
          This defines, whether there is an automatic change of infoservice after failure as default.
static int DEFAULT_OF_ASKED_INFO_SERVICES
           
static int MAXIMUM_OF_ASKED_INFO_SERVICES
           
static java.lang.String XML_ELEM_CHANGE_INFO_SERVICES
           
static java.lang.String XML_ELEMENT_NAME
          Stores the name of the root node of the XML settings for this class.
 
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
 
Method Summary
 void getExitAddresses()
           
 org.w3c.dom.Element getForwarder()
          Downloads a forwarder entry from a infoservice.
 java.util.Hashtable getInfoServices()
          Get a Vector of all infoservices the preferred infoservice knows.
 java.util.Hashtable getInfoServiceSerials()
           
 java.util.Vector getInfoservicesWithForwarderList()
          Returns a Vector of InfoServices with all known infoservices (including the preferred infoservice), which have a forwarder list.
static InfoServiceHolder getInstance()
          Returns the instance of InfoServiceHolder (Singleton).
 JAPVersionInfo getJAPVersionInfo(int japVersionType)
          Returns the JAPVersionInfo for the specified type.
 java.util.Hashtable getLatestJavaVersions()
          Returns all known latests Java versions as JavaVersionDBEntry.
 java.util.Hashtable getLatestJavaVersionSerials()
           
 java.util.Hashtable getMessages()
           
 java.util.Hashtable getMessageSerials()
           
 MixCascade getMixCascadeInfo(java.lang.String a_cascadeID)
           
 java.util.Hashtable getMixCascades()
          Get a Vector of all mixcascades the preferred infoservice knows.
 java.util.Hashtable getMixCascades(java.lang.String context)
          same as getMixCascades but a service context that the cascades must match can be specfied.
 java.util.Hashtable getMixCascadeSerials()
           
 java.util.Hashtable getMixCascadeSerials(java.lang.String context)
          same as getMixCascadesSerials but a service context that the serials must match can be specified.
 MixInfo getMixInfo(java.lang.String mixId)
          Get the MixInfo for the mix with the given ID.
 java.util.Hashtable getMixInfos()
           
 byte[] getMixminionNodesList()
          Get the list with the mixminion nodes from the infoservice.
 JAPMinVersion getNewVersionNumber()
          Get the version String of the current JAP version from the infoservice.
 int getNumberOfAskedInfoServices()
           
 anon.pay.PaymentInstanceDBEntry getPaymentInstance(java.lang.String a_piID)
          Get information for a particular payment instance identified by a_piID
 java.util.Hashtable getPaymentInstances()
          Get a Vector of all payment instances the preferred infoservice knows.
 java.util.Hashtable getPerformanceInfos()
           
 InfoServiceDBEntry getPreferredInfoService()
          Returns the preferred InfoService.
 StatusInfo getStatusInfo(MixCascade a_cascade)
          Get the StatusInfo for the mixcascade with the given ID.
 StatusInfo getStatusInfo(MixCascade a_cascade, long a_timeout)
           
 anon.terms.template.TermsAndConditionsTemplate getTCTemplate(java.lang.String a_id)
          from preferred info service
 java.util.Hashtable getTCTemplates()
           
 java.util.Hashtable getTermsAndConditions()
           
 java.util.Hashtable getTermsAndConditionsSerials()
           
 byte[] getTorNodesList()
          Get the list with the tor nodes from the infoservice.
static java.lang.String getXmlSettingsRootNodeName()
          Returns the name of the XML node used to store all settings of the InfoServiceHolder instance.
 boolean isChangeInfoServices()
          Returns, whether there is an automatic change of infoservice after failure.
 void loadSettingsFromXml(org.w3c.dom.Element a_infoServiceManagementNode, boolean a_bForceISChange)
          Restores the settings of this instance of InfoServiceHolder with the settings stored in the specified XML node.
 void setChangeInfoServices(boolean a_changeInfoServices)
          Sets, whether there is an automatic change of infoservice after failure.
 void setNumberOfAskedInfoServices(int a_nrAskedInfoServices)
           
 void setPreferredInfoService(InfoServiceDBEntry a_preferredInfoService)
          Sets the preferred InfoService.
 void shutdown()
           
 org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
          Returns all settings (including the database of known infoservices) as an XML node.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_ELEMENT_NAME

public static final java.lang.String XML_ELEMENT_NAME
Stores the name of the root node of the XML settings for this class.

See Also:
Constant Field Values

XML_ELEM_CHANGE_INFO_SERVICES

public static final java.lang.String XML_ELEM_CHANGE_INFO_SERVICES
See Also:
Constant Field Values

MAXIMUM_OF_ASKED_INFO_SERVICES

public static final int MAXIMUM_OF_ASKED_INFO_SERVICES
See Also:
Constant Field Values

DEFAULT_OF_ASKED_INFO_SERVICES

public static final int DEFAULT_OF_ASKED_INFO_SERVICES
See Also:
Constant Field Values

DEFAULT_INFOSERVICE_CHANGES

public static final boolean DEFAULT_INFOSERVICE_CHANGES
This defines, whether there is an automatic change of infoservice after failure as default.

See Also:
Constant Field Values
Method Detail

getInstance

public static InfoServiceHolder getInstance()
Returns the instance of InfoServiceHolder (Singleton). If there is no instance, there is a new one created.

Returns:
The InfoServiceHolder instance.

shutdown

public void shutdown()

getXmlSettingsRootNodeName

public static java.lang.String getXmlSettingsRootNodeName()
Returns the name of the XML node used to store all settings of the InfoServiceHolder instance. This name can be used to find the XML node within a document when the settings shall be loaded.

Returns:
The name of the XML node created when storing the settings.

setPreferredInfoService

public void setPreferredInfoService(InfoServiceDBEntry a_preferredInfoService)
Sets the preferred InfoService. This InfoService is used every time we need data from an InfoService until there is an connection error. If we can't get a connection to any of the interfaces of this InfoService or if we get no or wrong data from this InfoService it is changed automatically.

Parameters:
a_preferredInfoService - The preferred InfoService.

getPreferredInfoService

public InfoServiceDBEntry getPreferredInfoService()
Returns the preferred InfoService. This InfoService is used every time we need data from an InfoService until there is an connection error. If we can't get a connection to any of the interfaces of this InfoService or if we get no or wrong data from this InfoService it is changed automatically.

Returns:
The preferred InfoService or null, if no preferred InfoService is set.

getNumberOfAskedInfoServices

public int getNumberOfAskedInfoServices()

setNumberOfAskedInfoServices

public void setNumberOfAskedInfoServices(int a_nrAskedInfoServices)

setChangeInfoServices

public void setChangeInfoServices(boolean a_changeInfoServices)
Sets, whether there is an automatic change of infoservice after failure. If this value is set to false, only the preferred infoservice is used.

Parameters:
a_changeInfoServices - Whether there are automatic changes of the infoservice.

isChangeInfoServices

public boolean isChangeInfoServices()
Returns, whether there is an automatic change of infoservice after failure. If this value is set to false, only the preferred infoservice is used for requests.

Returns:
Whether there are automatic changes of the infoservice.

getInfoservicesWithForwarderList

public java.util.Vector getInfoservicesWithForwarderList()
Returns a Vector of InfoServices with all known infoservices (including the preferred infoservice), which have a forwarder list.

Returns:
The Vector of all known infoservices with a forwarder list, maybe this Vector is empty.

getMixCascades

public java.util.Hashtable getMixCascades()
Get a Vector of all mixcascades the preferred infoservice knows. If we can't get a the information from preferred infoservice, another known infoservice is asked. If we have gotten a list from one infoservice, we stop asking other infoservices, so information is not a cumulative list with information from more than one infoservice. If we can't get the information from any infoservice, null is returned.

Returns:
The Vector of mixcascades.

getMixCascades

public java.util.Hashtable getMixCascades(java.lang.String context)
same as getMixCascades but a service context that the cascades must match can be specfied. If null is specified the method returns all service objects

Parameters:
context - service context that the returned cascades must match
Returns:
all cascades that match the specified service context.

getMixCascadeSerials

public java.util.Hashtable getMixCascadeSerials()

getMixCascadeSerials

public java.util.Hashtable getMixCascadeSerials(java.lang.String context)
same as getMixCascadesSerials but a service context that the serials must match can be specified. If null is specified the method returns all service serials

Parameters:
context - service context that the returned cascades must match
Returns:
all cascade serials that match the specified service context.

getTCTemplate

public anon.terms.template.TermsAndConditionsTemplate getTCTemplate(java.lang.String a_id)
from preferred info service

Returns:

getTCTemplates

public java.util.Hashtable getTCTemplates()

getTermsAndConditions

public java.util.Hashtable getTermsAndConditions()

getTermsAndConditionsSerials

public java.util.Hashtable getTermsAndConditionsSerials()

getPerformanceInfos

public java.util.Hashtable getPerformanceInfos()

getExitAddresses

public void getExitAddresses()

getPaymentInstances

public java.util.Hashtable getPaymentInstances()
Get a Vector of all payment instances the preferred infoservice knows. If we can't get a the information from preferred infoservice, another known infoservice is asked. If we have gotten a list from one infoservice, we stop asking other infoservices, so information is not a cumulative list with information from more than one infoservice. If we can't get the information from any infoservice, null is returned.

Returns:
The Vector of payment instances.

getPaymentInstance

public anon.pay.PaymentInstanceDBEntry getPaymentInstance(java.lang.String a_piID)
                                                   throws java.lang.Exception
Get information for a particular payment instance identified by a_piID

Returns:
Payment Instance information
Throws:
java.lang.Exception

getInfoServices

public java.util.Hashtable getInfoServices()
Get a Vector of all infoservices the preferred infoservice knows. If we can't get a the information from preferred infoservice, another known infoservice is asked. If we have gotten a list from one infoservice, we stop asking other infoservices, so information is not a cumulative list with information from more than one infoservice. If we can't get the information from any infoservice, null is returned.

Returns:
The Vector of infoservices.

getInfoServiceSerials

public java.util.Hashtable getInfoServiceSerials()

getMixInfo

public MixInfo getMixInfo(java.lang.String mixId)
Get the MixInfo for the mix with the given ID. If we can't get a the information from preferred infoservice, another known infoservice is asked. If we can't get the information from any infoservice, null is returned. You should not call this method directly, better call the method in MixCascade to get the MixInfo.

Parameters:
mixId - The ID of the mix to get the MixInfo for.
Returns:
The MixInfo for the mix with the given ID.

getMixInfos

public java.util.Hashtable getMixInfos()

getStatusInfo

public StatusInfo getStatusInfo(MixCascade a_cascade)
Get the StatusInfo for the mixcascade with the given ID. If we can't get a the information from preferred infoservice, another known infoservice is asked. If we can't get the information from any infoservice, null is returned. You should not call this method directly, better call the method in MixCascade to get the current status.

Parameters:
cascadeId - The ID of the mixcascade to get the StatusInfo for.
cascadeLength - The length of the mixcascade (number of mixes). We need this for calculating the AnonLevel in the StatusInfo.
Returns:
The current StatusInfo for the mixcascade with the given ID.

getStatusInfo

public StatusInfo getStatusInfo(MixCascade a_cascade,
                                long a_timeout)

getNewVersionNumber

public JAPMinVersion getNewVersionNumber()
Get the version String of the current JAP version from the infoservice. This function is called to check, whether updates of the JAP are available. If we can't get a the information from preferred infoservice, another known infoservice is asked. If we can't get the information from any infoservice, null is returned.

Returns:
The version String (fromat: nn.nn.nnn) of the current JAP version or null if the version information could not be retrieved

getLatestJavaVersions

public java.util.Hashtable getLatestJavaVersions()
Returns all known latests Java versions as JavaVersionDBEntry. If we can't get the information from any infoservice, null is returned.

Returns:
all known latests Java versions as JavaVersionDBEntry

getLatestJavaVersionSerials

public java.util.Hashtable getLatestJavaVersionSerials()

getMessages

public java.util.Hashtable getMessages()

getMessageSerials

public java.util.Hashtable getMessageSerials()

getJAPVersionInfo

public JAPVersionInfo getJAPVersionInfo(int japVersionType)
Returns the JAPVersionInfo for the specified type. The JAPVersionInfo is generated from the JNLP files received from the infoservice. If we can't get a the information from preferred infoservice, another known infoservice is asked. If we can't get the information from any infoservice, null is returned.

Parameters:
japVersionType - Selects the JAPVersionInfo (release / development). Look at the Constants in JAPVersionInfo.
Returns:
The JAPVersionInfo of the specified type.

getTorNodesList

public byte[] getTorNodesList()
Get the list with the tor nodes from the infoservice. If we can't get a the information from preferred infoservice, another known infoservice is asked. If we can't get the information from any infoservice, null is returned.

Returns:
The raw tor nodes list as it is distributed by the tor directory servers.

getMixCascadeInfo

public MixCascade getMixCascadeInfo(java.lang.String a_cascadeID)

getMixminionNodesList

public byte[] getMixminionNodesList()
Get the list with the mixminion nodes from the infoservice. If we can't get a the information from preferred infoservice, another known infoservice is asked. If we can't get the information from any infoservice, null is returned.

Returns:
The raw mixminion nodes list as it is distributed by the mixminion directory servers.

getForwarder

public org.w3c.dom.Element getForwarder()
Downloads a forwarder entry from a infoservice. If that infoservice has no forwarder list, it will ask another infoservice with such a list and returns the answer to us. If we can't get the information from preferred infoservice, another known infoservice is asked. If we can't get the information from any infoservice, null is returned.

Returns:
The JapForwarder node of the answer of the infoservice's getforwarder command.

toXmlElement

public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
Returns all settings (including the database of known infoservices) as an XML node.

Specified by:
toXmlElement in interface anon.util.IXMLEncodable
Parameters:
a_doc - The parent document for the created XML node.
Returns:
The settings of this instance of InfoServiceHolder as an XML node.

loadSettingsFromXml

public void loadSettingsFromXml(org.w3c.dom.Element a_infoServiceManagementNode,
                                boolean a_bForceISChange)
                         throws java.lang.Exception
Restores the settings of this instance of InfoServiceHolder with the settings stored in the specified XML node.

Parameters:
a_infoServiceManagementNode - The XML node for loading the settings from. The name of the needed XML node can be obtained by calling getXmlSettingsRootNodeName().
a_bForceISChange - if automatic change if IS is forced
Throws:
java.lang.Exception