anon.infoservice
Class InfoServiceHolder

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

public class InfoServiceHolder
extends java.util.Observable
implements 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.


Nested Class Summary
private  class InfoServiceHolder.InformationFetcher
           
 
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
           
private static int GET_CASCADEINFO
           
private static int GET_EXIT_ADDRESSES
           
private static int GET_FORWARDER
          Function number for fetchInformation() - getForwarder().
private static int GET_INFOSERVICE_SERIALS
           
private static int GET_INFOSERVICES
          Function number for fetchInformation() - getInfoServices().
private static int GET_JAPVERSIONINFO
          Function number for fetchInformation() - getJAPVersionInfo().
private static int GET_LATEST_JAVA
           
private static int GET_LATEST_JAVA_SERIALS
           
private static int GET_MESSAGE_SERIALS
           
private static int GET_MESSAGES
           
private static int GET_MIXCASCADE_SERIALS
           
private static int GET_MIXCASCADES
          Function number for fetchInformation() - getMixCascades().
private static int GET_MIXINFO
          Function number for fetchInformation() - getMixInfo().
private static int GET_MIXINFOS
          Function number for fetchInformation() - getMixInfo().
private static int GET_MIXMINIONNODESLIST
          Function number for fetchInformation() - getMixminionNodesList().
private static int GET_NEWVERSIONNUMBER
          Function number for fetchInformation() - getNewVersionNumber().
private static int GET_PAYMENT_INSTANCE
          Function number for fetchInformation() - getPaymentInstance().
private static int GET_PAYMENT_INSTANCES
          Function number for fetchInformation() - getPaymentInstances().
private static int GET_PERFORMANCE_INFO
           
private static int GET_STATUSINFO
          Function number for fetchInformation() - getStatusInfo().
private static int GET_STATUSINFO_TIMEOUT
           
private static int GET_TC_SERIALS
           
private static int GET_TC_TEMPLATE
           
private static int GET_TC_TEMPLATES
           
private static int GET_TCS
           
private static int GET_TORNODESLIST
          Function number for fetchInformation() - getTorNodesList().
private static java.lang.String[] GETS
           
private  boolean m_changeInfoServices
          Stores, whether there is an automatic change of infoservice after failure.
private  int m_nrAskedInfoServices
           
private  ThreadPool m_poolFetchInformation
          Allows only 3 concurrent update operations.
private  InfoServiceDBEntry m_preferredInfoService
          Stores the preferred InfoService.
static int MAXIMUM_OF_ASKED_INFO_SERVICES
           
private static InfoServiceHolder ms_infoServiceHolderInstance
          Stores the instance of InfoServiceHolder (Singleton).
private static java.lang.String XML_ATTR_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
 
Constructor Summary
private InfoServiceHolder()
          This creates a new instance of InfoServiceHolder.
 
Method Summary
private  java.lang.Object fetchInformation(int functionNumber, java.util.Vector arguments)
          Fetches every information from the infoservices.
private static void filterServiceContext(java.util.Hashtable serviceObjects, java.lang.String context)
          helper function that filters service objects matching the specified service context.
 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()
           
 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)
           
 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

GET_MIXCASCADES

private static final int GET_MIXCASCADES
Function number for fetchInformation() - getMixCascades().

See Also:
Constant Field Values

GET_INFOSERVICES

private static final int GET_INFOSERVICES
Function number for fetchInformation() - getInfoServices().

See Also:
Constant Field Values

GET_MIXINFO

private static final int GET_MIXINFO
Function number for fetchInformation() - getMixInfo().

See Also:
Constant Field Values

GET_STATUSINFO

private static final int GET_STATUSINFO
Function number for fetchInformation() - getStatusInfo().

See Also:
Constant Field Values

GET_NEWVERSIONNUMBER

private static final int GET_NEWVERSIONNUMBER
Function number for fetchInformation() - getNewVersionNumber().

See Also:
Constant Field Values

GET_JAPVERSIONINFO

private static final int GET_JAPVERSIONINFO
Function number for fetchInformation() - getJAPVersionInfo().

See Also:
Constant Field Values

GET_TORNODESLIST

private static final int GET_TORNODESLIST
Function number for fetchInformation() - getTorNodesList().

See Also:
Constant Field Values

GET_FORWARDER

private static final int GET_FORWARDER
Function number for fetchInformation() - getForwarder().

See Also:
Constant Field Values

GET_PAYMENT_INSTANCES

private static final int GET_PAYMENT_INSTANCES
Function number for fetchInformation() - getPaymentInstances().

See Also:
Constant Field Values

GET_PAYMENT_INSTANCE

private static final int GET_PAYMENT_INSTANCE
Function number for fetchInformation() - getPaymentInstance().

See Also:
Constant Field Values

GET_MIXMINIONNODESLIST

private static final int GET_MIXMINIONNODESLIST
Function number for fetchInformation() - getMixminionNodesList().

See Also:
Constant Field Values

GET_CASCADEINFO

private static final int GET_CASCADEINFO
See Also:
Constant Field Values

GET_LATEST_JAVA

private static final int GET_LATEST_JAVA
See Also:
Constant Field Values

GET_INFOSERVICE_SERIALS

private static final int GET_INFOSERVICE_SERIALS
See Also:
Constant Field Values

GET_MIXCASCADE_SERIALS

private static final int GET_MIXCASCADE_SERIALS
See Also:
Constant Field Values

GET_MESSAGES

private static final int GET_MESSAGES
See Also:
Constant Field Values

GET_LATEST_JAVA_SERIALS

private static final int GET_LATEST_JAVA_SERIALS
See Also:
Constant Field Values

GET_MESSAGE_SERIALS

private static final int GET_MESSAGE_SERIALS
See Also:
Constant Field Values

GET_STATUSINFO_TIMEOUT

private static final int GET_STATUSINFO_TIMEOUT
See Also:
Constant Field Values

GET_PERFORMANCE_INFO

private static final int GET_PERFORMANCE_INFO
See Also:
Constant Field Values

GET_TC_TEMPLATE

private static final int GET_TC_TEMPLATE
See Also:
Constant Field Values

GET_TCS

private static final int GET_TCS
See Also:
Constant Field Values

GET_TC_SERIALS

private static final int GET_TC_SERIALS
See Also:
Constant Field Values

GET_EXIT_ADDRESSES

private static final int GET_EXIT_ADDRESSES
See Also:
Constant Field Values

GET_TC_TEMPLATES

private static final int GET_TC_TEMPLATES
See Also:
Constant Field Values

GET_MIXINFOS

private static final int GET_MIXINFOS
Function number for fetchInformation() - getMixInfo().

See Also:
Constant Field Values

GETS

private static final java.lang.String[] GETS

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

XML_ATTR_ASKED_INFO_SERVICES

private static final java.lang.String XML_ATTR_ASKED_INFO_SERVICES
See Also:
Constant Field Values

ms_infoServiceHolderInstance

private static InfoServiceHolder ms_infoServiceHolderInstance
Stores the instance of InfoServiceHolder (Singleton).


m_poolFetchInformation

private ThreadPool m_poolFetchInformation
Allows only 3 concurrent update operations.


m_preferredInfoService

private InfoServiceDBEntry m_preferredInfoService
Stores the preferred InfoService. This InfoService is asked first for every information.


m_changeInfoServices

private boolean m_changeInfoServices
Stores, whether there is an automatic change of infoservice after failure. If this value is set to false, only the preferred infoservice is used.


m_nrAskedInfoServices

private int m_nrAskedInfoServices
Constructor Detail

InfoServiceHolder

private InfoServiceHolder()
This creates a new instance of InfoServiceHolder. This is only used for setting some values. Use InfoServiceHolder.getInstance() for getting an instance of this class.

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.

fetchInformation

private java.lang.Object fetchInformation(int functionNumber,
                                          java.util.Vector arguments)
Fetches every information from the infoservices. If we can't get the information from the preferred infoservice, all other known infoservices are asked automatically until an infoservice has the information. If we can't get the information from any infoservice, an Exception is thrown.

Parameters:
functionNumber - Specifies the InfoService function to call. Look at the constants defined in this class.
arguments - If an InfoService function needs arguments, these are in here.
Returns:
The needed information.

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 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 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 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

filterServiceContext

private static void filterServiceContext(java.util.Hashtable serviceObjects,
                                         java.lang.String context)
helper function that filters service objects matching the specified service context. In case of a mismatch the service object will be removed from the specified serviceObjects table.

Parameters:
serviceObjects - table of service objects to be filtered
context - the service context that the service objects must match