infoservice
Class InfoServiceCommands

java.lang.Object
  extended by infoservice.InfoServiceCommands
All Implemented Interfaces:
JWSInternalCommands

public final class InfoServiceCommands
extends java.lang.Object
implements JWSInternalCommands

This is the implementation of all commands the InfoService supports.


Nested Class Summary
private  class InfoServiceCommands.HTTPResponseGetter
           
 
Field Summary
private  IInfoServiceAgreementAdapter m_agreementAdapter
           
private  InfoServiceCommands.HTTPResponseGetter m_cascadeResponseGetter
           
private  DynamicCommandsExtension m_dynamicExtension
           
private  InfoServiceCommands.HTTPResponseGetter m_isResponseGetter
           
private  InfoServiceCommands.HTTPResponseGetter m_javaVersionResponseGetter
           
private  InfoServiceCommands.HTTPResponseGetter m_messageResponseGetter
           
private  Database m_statusinfoDB
           
 
Constructor Summary
InfoServiceCommands()
           
 
Method Summary
private  HttpResponseStructure addJapForwarder(byte[] a_postData, java.net.InetAddress a_sourceAddress)
          Adds a new JAP forwarder to the database of JAP forwarders.
private  HttpResponseStructure cascadePostHelo(byte[] a_postData, int a_encoding)
          This method is called, when we receive data from a mixcascade (first mix) or when we receive data from a remote infoservice, which posts data about a mixcascade.
private  HttpResponseStructure cascadePostStatus(byte[] a_postData)
          This method is called, when we receive data from a mixcascade about the status or when we receive data from a remote infoservice, which posts data about mixcascade status.
private  HttpResponseStructure echoIP(java.net.InetAddress a_sourceAddress)
           
private  HttpResponseStructure fetchAllMixes()
          Sends the complete list of all known mixes to the client.
private  HttpResponseStructure fetchAvailableMixes()
          Constructs an XML structure containing a list of all free mixes we know.
private  HttpResponseStructure getCascadeInfo(int a_supportedEncodings, java.lang.String a_cascadeId)
          Sends the XML encoded mixcascade entry the ID given by cascadeId to the client.
private  HttpResponseStructure getInfoServiceInfo(java.lang.String a_infoserviceId)
           
private  HttpResponseStructure getJapForwarder()
          Gets a forwarder entry (encoded with a captcha) from the JAP forwarder database.
private  HttpResponseStructure getJnlpFile(java.lang.String a_fileName, int a_httpMethod)
          Sends the JNLP files for the JAP development or release version to the JAP client or any other system which makes a Java WebStart request.
private  HttpResponseStructure getMixminionNodesList()
          Sends the complete list of all known mixminion nodes to the client.
private  HttpResponseStructure getProxyAddresses()
          This function sends the addresses of the proxy servers at the end of the cascades as plain text to the client.
private  HttpResponseStructure getTorNodesList(int a_supportedEncodings)
          Sends the complete list of all known tor nodes to the client.
private  HttpResponseStructure humanGetStatus()
          Sends a generated HTML file with all status entrys to the client.
private  HttpResponseStructure infoServerPostHelo(byte[] a_postData)
          This method is called, when we receive data directly from a infoservice or when we receive data from a remote infoservice, which posts data about another infoservice.
private  HttpResponseStructure japFetchPaymentInstanceInfo(java.lang.String a_piID)
          Sends info about a special payment instance to the client.
private  HttpResponseStructure japFetchPaymentInstances()
          Sends the complete list of all known payment instances to the client.
private  HttpResponseStructure japGetCascadeStatus(java.lang.String a_cascadeId)
          Sends the XML encoded status of the mixcascade with the ID given by cascadeId.
private  HttpResponseStructure japGetCurrentJapVersion()
          Sends the version number of the current minimum required JAP client software as an XML structure.
private  HttpResponseStructure japGetMix(java.lang.String a_mixId)
          Sends the XML encoded mix entry for the specified ID to the client.
private  HttpResponseStructure japPostCurrentJapVersion(byte[] a_postData)
          This method is called, when we receive data from another infoservice with the minimum required JAP client version.
private  HttpResponseStructure messagePost(byte[] a_postData, int a_encoding)
           
private  HttpResponseStructure mixPostConfigure(byte[] a_postData)
          This method is called, when we receive data from a mix which wants to get configured automatically (inserted in a auto-configure-cascade).
private  HttpResponseStructure mixPostHelo(byte[] a_postData)
          This method is called, when we receive data from a non-free mix or when we receive data from a remote infoservice, which posts data about a non-free mix.
private  HttpResponseStructure paymentInstancePostHelo(byte[] a_postData)
          This method is called, when we receive data from a payment instance or when we receive data from a remote infoservice, which posts data about another payment instance.
private  HttpResponseStructure postJnlpFile(java.lang.String a_fileName, byte[] a_postData)
          This method is called, when we receive data from another infoservice with the current japRelease.jnlp or japDevelopment.jnlp Java WebStart files.
private  HttpResponseStructure postLatestJavaVersions(byte[] a_postData)
          This method is called, when we receive data from another infoservice with the lastest java version for a specific vendor.
 HttpResponseStructure processCommand(int method, int a_supportedEncodings, java.lang.String command, byte[] postData, java.net.InetAddress a_sourceAddress)
          This is the handler for processing the InfoService commands.
private  HttpResponseStructure renewJapForwarder(byte[] a_postData)
          Renews the entry of a JAP forwarder in the database of JAP forwarders.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_isResponseGetter

private final InfoServiceCommands.HTTPResponseGetter m_isResponseGetter

m_cascadeResponseGetter

private final InfoServiceCommands.HTTPResponseGetter m_cascadeResponseGetter

m_messageResponseGetter

private final InfoServiceCommands.HTTPResponseGetter m_messageResponseGetter

m_javaVersionResponseGetter

private final InfoServiceCommands.HTTPResponseGetter m_javaVersionResponseGetter

m_agreementAdapter

private IInfoServiceAgreementAdapter m_agreementAdapter

m_dynamicExtension

private DynamicCommandsExtension m_dynamicExtension

m_statusinfoDB

private Database m_statusinfoDB
Constructor Detail

InfoServiceCommands

public InfoServiceCommands()
Method Detail

infoServerPostHelo

private HttpResponseStructure infoServerPostHelo(byte[] a_postData)
This method is called, when we receive data directly from a infoservice or when we receive data from a remote infoservice, which posts data about another infoservice.

Parameters:
a_postData - The data we have received.
Returns:
The HTTP response for the client.

paymentInstancePostHelo

private HttpResponseStructure paymentInstancePostHelo(byte[] a_postData)
This method is called, when we receive data from a payment instance or when we receive data from a remote infoservice, which posts data about another payment instance.

Parameters:
a_postData - The data we have received.
Returns:
The HTTP response for the client.

japFetchPaymentInstanceInfo

private HttpResponseStructure japFetchPaymentInstanceInfo(java.lang.String a_piID)
Sends info about a special payment instance to the client.

Returns:
The HTTP response for the client.

japFetchPaymentInstances

private HttpResponseStructure japFetchPaymentInstances()
Sends the complete list of all known payment instances to the client.

Returns:
The HTTP response for the client.

cascadePostHelo

private HttpResponseStructure cascadePostHelo(byte[] a_postData,
                                              int a_encoding)
This method is called, when we receive data from a mixcascade (first mix) or when we receive data from a remote infoservice, which posts data about a mixcascade.

Parameters:
a_postData - The data we have received.
a_encoding - the encoding chosen by the client
Returns:
The HTTP response for the client.

messagePost

private HttpResponseStructure messagePost(byte[] a_postData,
                                          int a_encoding)

mixPostHelo

private HttpResponseStructure mixPostHelo(byte[] a_postData)
This method is called, when we receive data from a non-free mix or when we receive data from a remote infoservice, which posts data about a non-free mix.

Parameters:
a_postData - The data we have received.
Returns:
The HTTP response for the client.

mixPostConfigure

private HttpResponseStructure mixPostConfigure(byte[] a_postData)
This method is called, when we receive data from a mix which wants to get configured automatically (inserted in a auto-configure-cascade). If the mix is already assigned to a mixcascade, we will send back the XML structure of the cascade the mix now belongs to. This makes it possible for the mix to connect his neighbours.

Parameters:
a_postData - The data we have received.
Returns:
The HTTP response for the client.

japGetMix

private HttpResponseStructure japGetMix(java.lang.String a_mixId)
Sends the XML encoded mix entry for the specified ID to the client.

Parameters:
a_mixId - The ID of the requested mix.
Returns:
The HTTP response for the client.

cascadePostStatus

private HttpResponseStructure cascadePostStatus(byte[] a_postData)
This method is called, when we receive data from a mixcascade about the status or when we receive data from a remote infoservice, which posts data about mixcascade status.

Parameters:
a_postData - The data we have received.
Returns:
The HTTP response for the client.

japGetCascadeStatus

private HttpResponseStructure japGetCascadeStatus(java.lang.String a_cascadeId)
Sends the XML encoded status of the mixcascade with the ID given by cascadeId. It uses the original version (as the infoservice has received it) of the XML structure.

Parameters:
a_cascadeId - The ID of the mixcascade.
Returns:
The HTTP response for the client.

postLatestJavaVersions

private HttpResponseStructure postLatestJavaVersions(byte[] a_postData)
This method is called, when we receive data from another infoservice with the lastest java version for a specific vendor.

Parameters:
a_postData - The data we have received.
Returns:
The HTTP response for the client.

humanGetStatus

private HttpResponseStructure humanGetStatus()
Sends a generated HTML file with all status entrys to the client. This function is not used by the JAP client. It's intended to use with a webbrowser to see the status of all cascades.

Returns:
The HTTP response for the client.

fetchAllMixes

private HttpResponseStructure fetchAllMixes()
Sends the complete list of all known mixes to the client. This command is not used by the JAP client. It's just a comfort function to see all currently working mixes.

Returns:
The HTTP response for the client.

fetchAvailableMixes

private HttpResponseStructure fetchAvailableMixes()
Constructs an XML structure containing a list of all free mixes we know. Those mixes were announced to us via the '/configure' method and are currently not assigned to any cascade.

Returns:
The HTTP response for the client.

getCascadeInfo

private HttpResponseStructure getCascadeInfo(int a_supportedEncodings,
                                             java.lang.String a_cascadeId)
Sends the XML encoded mixcascade entry the ID given by cascadeId to the client.

Parameters:
a_cascadeId - The ID of the requested mixcascade.
a_supportedEncodings - defines the encoding supported by the client (deflate, gzip,...)
Returns:
The HTTP response for the client.

getInfoServiceInfo

private HttpResponseStructure getInfoServiceInfo(java.lang.String a_infoserviceId)

echoIP

private HttpResponseStructure echoIP(java.net.InetAddress a_sourceAddress)

getTorNodesList

private HttpResponseStructure getTorNodesList(int a_supportedEncodings)
Sends the complete list of all known tor nodes to the client. This command is used by the JAP clients with tor integration. If we don't have a current tor nodes list, we return -1 and the client will get an http error. So the client will ask another infoservice.

Parameters:
a_supportedEncodings - defines the encoding supported by the client (deflate, gzip,...)
Returns:
The HTTP response for the client.

getMixminionNodesList

private HttpResponseStructure getMixminionNodesList()
Sends the complete list of all known mixminion nodes to the client. This command is used by the JAP clients with mixminion integration. If we don't have a current mixminion nodes list, we return -1 and the client will get an http error. So the client will ask another infoservice.

Returns:
The HTTP response for the client.

addJapForwarder

private HttpResponseStructure addJapForwarder(byte[] a_postData,
                                              java.net.InetAddress a_sourceAddress)
Adds a new JAP forwarder to the database of JAP forwarders. But first we verify the connection, if this is successful we add the entry and send the forwarder entry ID back to the forwarder. So he knows under which ID he can renew the entry.

Parameters:
a_postData - The data we have received.
a_sourceAddress - The internet address where the request was coming from. We use this for checking the connection to the forwarder.
Returns:
The HTTP response for the client.

renewJapForwarder

private HttpResponseStructure renewJapForwarder(byte[] a_postData)
Renews the entry of a JAP forwarder in the database of JAP forwarders. We write back some status information, whether it was successful.

Parameters:
a_postData - The data we have received.
Returns:
The HTTP response for the client.

getJapForwarder

private HttpResponseStructure getJapForwarder()
Gets a forwarder entry (encoded with a captcha) from the JAP forwarder database. If we have such a database, but there is no data in it, we send back an answer with the error description. If this infoservice doesn't have a primary forwarder list, we aks all known infoservices with such a list for an entry, until we get an entry from one of them or we asked all and no one has a JAP forwarder entry. In this case we send also an answer with the error description back to the client.

Returns:
The HTTP response for the client.

japPostCurrentJapVersion

private HttpResponseStructure japPostCurrentJapVersion(byte[] a_postData)
This method is called, when we receive data from another infoservice with the minimum required JAP client version.

Parameters:
a_postData - The data we have received.
Returns:
The HTTP response for the client.

japGetCurrentJapVersion

private HttpResponseStructure japGetCurrentJapVersion()
Sends the version number of the current minimum required JAP client software as an XML structure.

Returns:
The HTTP response for the client.

postJnlpFile

private HttpResponseStructure postJnlpFile(java.lang.String a_fileName,
                                           byte[] a_postData)
This method is called, when we receive data from another infoservice with the current japRelease.jnlp or japDevelopment.jnlp Java WebStart files.

Parameters:
a_fileName - The filename of the JNLP file (full path starting with / + filename).
a_postData - The data we have received.
Returns:
The HTTP response for the client.

getJnlpFile

private HttpResponseStructure getJnlpFile(java.lang.String a_fileName,
                                          int a_httpMethod)
Sends the JNLP files for the JAP development or release version to the JAP client or any other system which makes a Java WebStart request.

Parameters:
a_fileName - The filename of the requested JNLP file (full path starting with / + filename).
a_httpMethod - Describes the HTTP method (can be GET or HEAD, see constants in Constants.java). Java WebStart requests firstly only the header without the content and the asks a second time for the whole thing (header + content).
Returns:
The HTTP response for the client.

getProxyAddresses

private HttpResponseStructure getProxyAddresses()
This function sends the addresses of the proxy servers at the end of the cascades as plain text to the client. The info about the proxies comes from the configuration property file and from the information given by Last Mixes.

Returns:
The HTTP response for the client.

processCommand

public HttpResponseStructure processCommand(int method,
                                            int a_supportedEncodings,
                                            java.lang.String command,
                                            byte[] postData,
                                            java.net.InetAddress a_sourceAddress)
This is the handler for processing the InfoService commands.

Specified by:
processCommand in interface JWSInternalCommands
Parameters:
method - The HTTP method used within the request from the client. See the REQUEST_METHOD constants in anon.infoservice.Constants.
a_supportedEncodings - The HTTP encodings supported by the client. See the HTTP_ENCODING constants in HttpResonseStructure.
command - The URL requested from the client within the HTTP request. Normally this should be an absolute path with a filename.
postData - The HTTP content data (maybe of size 0), if the request was an HTTP POST. If the HTTP method was not POST, this value is always null.
a_sourceAddress - The internet address from where we have received the request. It is the address of the other end of the socket connection, so maybe it is only the address of a proxy.
Returns:
The response to send back to the client. This value is null, if the request cannot be handled by this implementation (maybe because of an invalid command, ...).