anon.infoservice
Class StatusInfo

java.lang.Object
  extended by anon.infoservice.AbstractDatabaseEntry
      extended by anon.infoservice.StatusInfo
All Implemented Interfaces:
IVerifyable, IDistributable, IXMLEncodable

public final class StatusInfo
extends AbstractDatabaseEntry
implements IDistributable, IVerifyable, IXMLEncodable

Holds the information of a mixcascade status.


Field Summary
static int ANON_LEVEL_MAX
           
static int ANON_LEVEL_MIN
           
private  int m_anonLevel
          This is the calculated anonymity level (from number of active users, current traffic and cascade length).
private  MultiCertPath m_certPath
          The certificate path
private  int m_currentRisk
          Stores the current risk for using this mix cascade.
private  long m_lastUpdate
          Time (see System.currentTimeMillis()) when the mixcascade (first mix) has sent this status message.
private  java.lang.String m_mixCascadeId
          This is the ID of the mixcascade to which this status belongs.
private  long m_mixedPackets
          This is the number of packets, which are mixed through the cascade since their startup.
private  int m_nrOfActiveUsers
          Stores the number of active users in the corresponding mixcascade.
private  XMLSignature m_signature
          The signature of the StatusInfo
private  java.lang.String m_statusXmlData
          Stores the XML description which we forward to other infoservices (the same as we have received).
private  byte[] m_statusXmlDataBytes
          Stores the XML description as byte-array for fast processing
private  int m_trafficSituation
          Stores the current traffic situation for the mixcascade.
static java.lang.String XML_ELEMENT_CONTAINER_NAME
           
static java.lang.String XML_ELEMENT_NAME
           
 
Fields inherited from class anon.infoservice.AbstractDatabaseEntry
XML_ATTR_LAST_UPDATE, XML_LAST_UPDATE
 
Fields inherited from interface anon.infoservice.IDistributable
FIELD_HTTP_REQUEST_STRING, FIELD_HTTP_SERIALS_REQUEST_STRING
 
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
  StatusInfo(org.w3c.dom.Element a_statusNode)
          Creates a new StatusInfo from XML description (MixCascadeStatus node).
  StatusInfo(org.w3c.dom.Element a_statusNode, long a_timeout)
          Creates a new StatusInfo from XML description (MixCascadeStatus node).
private StatusInfo(java.lang.String a_mixCascadeId, int a_nrOfActiveUsers, int a_currentRisk, int a_trafficSituation, long a_mixedPackets, int a_anonLevel)
          Constructs a StatusInfo out of the single values.
 
Method Summary
 boolean checkId()
           
static StatusInfo createDummyStatusInfo(java.lang.String a_mixCascadeId)
          Returns a new StatusInfo with dummy values (everything is set to -1).
 org.w3c.dom.Node generateMixCascadeCurrentStatus()
          This is a compatibility method for the creation of the CurrentStatus in the MixCascade XML structure for old JAP clients.
private  org.w3c.dom.Element generateXmlRepresentation()
          Generates an XML representation for this StatusInfo entry.
 int getAnonLevel()
          Returns the calculated anonymity level (from number of active users, current traffic and cascade length).
 MultiCertPath getCertPath()
           
 int getCurrentRisk()
          Returns the current risk for using this mix cascade.
 java.lang.String getHtmlTableLine(boolean a_bPassiveMode)
          Returns a HTML table line with the data of this StatusDBEntry.
 java.lang.String getId()
          Returns the mixcascade ID of this status.
 long getLastUpdate()
          Returns the time (see System.currentTimeMillis()), when the mixcascade has sent this StatusInfo to an InfoService.
 long getMixedPackets()
          Returns the number of packets, which are mixed through the cascade since their startup.
 int getNrOfActiveUsers()
          Returns the number of active users in the corresponding mixcascade.
 byte[] getPostData()
          This returns the data, which are posted to other InfoServices.
 int getPostEncoding()
          Returns the content encoding of the post data.
 java.lang.String getPostFile()
          This returns the filename (InfoService command), where this status entry is posted at other infoservices.
 XMLSignature getSignature()
           
 java.lang.String getStatusXmlData()
          Returns the XML structure of this status entry as we received it.
 int getTrafficSituation()
          Returns the current traffic situation for the mixcascade.
 long getVersionNumber()
          Returns the time when this StatusInfo was created by the origin mixcascade (or by the JAP client if it is a dummy entry).
static java.lang.String getXmlElementName()
          Returns the name of the XML element corresponding to this class ("MixCascadeStatus").
 boolean isValid()
          Returns if the object is valid at this time
 boolean isVerified()
          Returns if the object has been verified by checking its signature(s).
 org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
          Returns an XML Node of the current StatusInfo using the stored XML String
 
Methods inherited from class anon.infoservice.AbstractDatabaseEntry
deletePersistence, getCreationTime, getExpireTime, isNewerThan, isPersistanceDeletionAllowed, isUserDefined, resetCreationTime
 
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
See Also:
Constant Field Values

XML_ELEMENT_CONTAINER_NAME

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

ANON_LEVEL_MIN

public static final int ANON_LEVEL_MIN
See Also:
Constant Field Values

ANON_LEVEL_MAX

public static final int ANON_LEVEL_MAX
See Also:
Constant Field Values

m_mixCascadeId

private java.lang.String m_mixCascadeId
This is the ID of the mixcascade to which this status belongs.


m_lastUpdate

private long m_lastUpdate
Time (see System.currentTimeMillis()) when the mixcascade (first mix) has sent this status message.


m_nrOfActiveUsers

private int m_nrOfActiveUsers
Stores the number of active users in the corresponding mixcascade.


m_currentRisk

private int m_currentRisk
Stores the current risk for using this mix cascade. This is a value between 0 an 100 and it is calculated by the mixcascade in contrast to the anonlevel, which is calculated by the JAP client.


m_trafficSituation

private int m_trafficSituation
Stores the current traffic situation for the mixcascade.


m_mixedPackets

private long m_mixedPackets
This is the number of packets, which are mixed through the cascade since their startup.


m_anonLevel

private int m_anonLevel
This is the calculated anonymity level (from number of active users, current traffic and cascade length). It is a value between 0 and 5.


m_statusXmlData

private java.lang.String m_statusXmlData
Stores the XML description which we forward to other infoservices (the same as we have received). This XML description is also used by recent versions of the JAP client (>= 00.02.016) when fetching the status info. We are using a string representation here because it is much faster if we don't need to process the XML tree everytime a client requests the current status.


m_statusXmlDataBytes

private byte[] m_statusXmlDataBytes
Stores the XML description as byte-array for fast processing


m_signature

private XMLSignature m_signature
The signature of the StatusInfo


m_certPath

private MultiCertPath m_certPath
The certificate path

Constructor Detail

StatusInfo

public StatusInfo(org.w3c.dom.Element a_statusNode)
           throws java.lang.Exception
Creates a new StatusInfo from XML description (MixCascadeStatus node). There is no anonymity level calculated for the new status entry -> getAnonLevel() will return -1. This constructor should only be called within the context of the infoservice. Beware of creating a constructor (Element, long), as Database.loadFromXML will then use an unlimited timeout!

Parameters:
a_statusNode - The MixCascadeStatus node from an XML document.
Throws:
java.lang.Exception

StatusInfo

public StatusInfo(org.w3c.dom.Element a_statusNode,
                  long a_timeout)
           throws java.lang.Exception
Creates a new StatusInfo from XML description (MixCascadeStatus node).

Parameters:
a_statusNode - The MixCascadeStatus node from an XML document.
a_mixCascadeLength - The number of mixes in the mixcascade. We need this for calculating the anonymity level. If this value is smaller than 0, no anonymity level is calculated and getAnonLevel() will return -1.
a_timeout - A timeout.
Throws:
java.lang.Exception

StatusInfo

private StatusInfo(java.lang.String a_mixCascadeId,
                   int a_nrOfActiveUsers,
                   int a_currentRisk,
                   int a_trafficSituation,
                   long a_mixedPackets,
                   int a_anonLevel)
Constructs a StatusInfo out of the single values. The creation time (last update) is set to the current system time.

Parameters:
a_mixCascadeId - The ID of the mixcascade this StatusInfo belongs to.
a_nrOfActiveUsers - The number of active users in the cascade.
a_currentRisk - The risk calculated by the cascade (between 0 and 100).
a_trafficSituation - The amount of traffic in the cascade.
a_mixedPackets - The number of packets the cascade has mixed since startup.
a_anonLevel - The anonymity level calculated by the JAP client (between 0 and 5).
Method Detail

createDummyStatusInfo

public static StatusInfo createDummyStatusInfo(java.lang.String a_mixCascadeId)
Returns a new StatusInfo with dummy values (everything is set to -1). The LastUpdate time is set to the current system time. This function is used every time, we can't get the StatusInfo from the infoservice of when a new MixCascade is constructed. This method is only used within the context of the JAP client.

Parameters:
a_mixCascadeId - The ID of the MixCascade the StatusInfo belongs to.
Returns:
The new dummy StatusInfo.

getXmlElementName

public static java.lang.String getXmlElementName()
Returns the name of the XML element corresponding to this class ("MixCascadeStatus").

Returns:
The name of the XML element corresponding to this class.

getId

public java.lang.String getId()
Returns the mixcascade ID of this status.

Specified by:
getId in interface IDistributable
Specified by:
getId in class AbstractDatabaseEntry
Returns:
The mixcascade ID of this status.

getLastUpdate

public long getLastUpdate()
Returns the time (see System.currentTimeMillis()), when the mixcascade has sent this StatusInfo to an InfoService.

Specified by:
getLastUpdate in class AbstractDatabaseEntry
Returns:
The send time of this StatusInfo from the mixcascade.

getVersionNumber

public long getVersionNumber()
Returns the time when this StatusInfo was created by the origin mixcascade (or by the JAP client if it is a dummy entry).

Specified by:
getVersionNumber in class AbstractDatabaseEntry
Returns:
A version number which is used to determine the more recent status entry, if two entries are compared (higher version number -> more recent entry).

getNrOfActiveUsers

public int getNrOfActiveUsers()
Returns the number of active users in the corresponding mixcascade.

Returns:
The number of active users in the corresponding mixcascade.

getCurrentRisk

public int getCurrentRisk()
Returns the current risk for using this mix cascade. This is a value between 0 an 100 and it is calculated by the mixcascade in contrast to the anonlevel, which is calculated by the JAP client.

Returns:
The current risk for the mixcascade.

getTrafficSituation

public int getTrafficSituation()
Returns the current traffic situation for the mixcascade.

Returns:
The current traffic situation for the mixcascade.

getMixedPackets

public long getMixedPackets()
Returns the number of packets, which are mixed through the cascade since their startup.

Returns:
The number of mixed packets.

getAnonLevel

public int getAnonLevel()
Returns the calculated anonymity level (from number of active users, current traffic and cascade length). It is a value between ANON_LEVEL_MIN and ANON_LEVEL_MAX. If it is < 0, the anonymity level is unknown.

Returns:
The current anonymity level.

isVerified

public boolean isVerified()
Description copied from interface: IVerifyable
Returns if the object has been verified by checking its signature(s).

Specified by:
isVerified in interface IVerifyable
Returns:
if the object has been verified by checking its signature(s)

isValid

public boolean isValid()
Description copied from interface: IVerifyable
Returns if the object is valid at this time

Specified by:
isValid in interface IVerifyable
Returns:
if the object is valid at this time

getSignature

public XMLSignature getSignature()

getCertPath

public MultiCertPath getCertPath()
Specified by:
getCertPath in interface IVerifyable

checkId

public boolean checkId()

getPostFile

public java.lang.String getPostFile()
This returns the filename (InfoService command), where this status entry is posted at other infoservices. It's always '/feedback'. This method is used within the context of the infoservice when this status entry is forwarded to other infoservices.

Specified by:
getPostFile in interface IDistributable
Returns:
The filename where the information about this StatusInfo is posted at other InfoServices when this entry is forwarded.

getPostData

public byte[] getPostData()
This returns the data, which are posted to other InfoServices. It's the whole XML structure of this status entry.

Specified by:
getPostData in interface IDistributable
Returns:
The data, which are posted to other InfoServices when this entry is forwarded.

getPostEncoding

public int getPostEncoding()
Description copied from interface: IDistributable
Returns the content encoding of the post data.

Specified by:
getPostEncoding in interface IDistributable
Returns:
the content encoding of the post data

getStatusXmlData

public java.lang.String getStatusXmlData()
Returns the XML structure of this status entry as we received it.

Returns:
The original XML data of this status entry.

getHtmlTableLine

public java.lang.String getHtmlTableLine(boolean a_bPassiveMode)
Returns a HTML table line with the data of this StatusDBEntry. This method is called within the context of the infoservice by InfoServiceCommands.humanGetStatus().

Returns:
A HTML table line with the data of this status entry.

generateMixCascadeCurrentStatus

public org.w3c.dom.Node generateMixCascadeCurrentStatus()
This is a compatibility method for the creation of the CurrentStatus in the MixCascade XML structure for old JAP clients.

Returns:
The CurrentStatus node for this status entry.

generateXmlRepresentation

private org.w3c.dom.Element generateXmlRepresentation()
Generates an XML representation for this StatusInfo entry.

Returns:
The generated XML representation for this StatusInfo.

toXmlElement

public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
Returns an XML Node of the current StatusInfo using the stored XML String

Specified by:
toXmlElement in interface IXMLEncodable
Parameters:
a_doc - a document
Returns:
the XML node