infoservice.japforwarding
Class ForwarderDBEntry

java.lang.Object
  extended by anon.infoservice.AbstractDatabaseEntry
      extended by infoservice.japforwarding.ForwarderDBEntry

public class ForwarderDBEntry
extends AbstractDatabaseEntry

This is the implementation of a JAP forwarder entry, which can be stored in the forwarder database.


Field Summary
private static int CAPTCHA_KEY_BITS
          This is the number of bits of an AES key, which are embedded within a captcha.
private static int EXTRA_KEY_BITS
          This is the number of extra key bits (maybe 0), which are not embedded in the captcha.
private  long m_creationTimeStamp
          Stores the time when this ForwarderDBEntry was created.
private  java.net.InetAddress m_forwarderAddress
          Stores the internet address of the forwarder.
private  byte[] m_forwarderData
          Stores the plain data which are used when generating the cipher data with the captcha key.
private  int m_forwarderPort
          Stores the port number of the forwarder.
private  java.lang.String m_id
          Stores the ID for this ForwarderDBEntry.
 
Fields inherited from class anon.infoservice.AbstractDatabaseEntry
XML_LAST_UPDATE
 
Constructor Summary
  ForwarderDBEntry(java.net.InetAddress a_forwarderAddress, int a_forwarderPort)
          Creates a new ForwarderDBEntry.
private ForwarderDBEntry(java.net.InetAddress a_forwarderAddress, int a_forwarderPort, byte[] a_forwarderData, java.lang.String a_id)
          This internal constructor is needed for creating a clone of a ForwarderDBEntry, needed for updating the forwarder database.
 
Method Summary
 org.w3c.dom.Element createCaptchaNode()
          Creates the JapForwarder node with the captcha data included.
 java.lang.String getId()
          Returns a unique ID for this forwarder database entry.
 long getLastUpdate()
          Returns the time in milliseconds when this db entry was created from the origin instance.
 ForwarderDBEntry getUpdateClone()
          Returns a clone of this ForwarderDBEntry.
 long getVersionNumber()
          Returns the time when this ForwarderDBEntry was created.
 
Methods inherited from class anon.infoservice.AbstractDatabaseEntry
getCreationTime, getExpireTime, isNewerThan, isUserDefined, resetCreationTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CAPTCHA_KEY_BITS

private static final int CAPTCHA_KEY_BITS
This is the number of bits of an AES key, which are embedded within a captcha. This value must be a multiple of 8. Also this number plus the number of extra key bits have not to be bigger than 128 (the sum of CAPTCHA_KEY_BITS + EXTRA_KEY_BITS should be less than 128 because the difference between 128 and that sum is used as redundancy to show the blockee, whether he has solved the captcha correctly or not, so that sum shouldn't be bigger than around 90). Whether we can create a captcha with this number of embedded bits, depends also on the used captcha implementation. We try to create a captcha with the number of embedded bits as near as possible to this value.

See Also:
Constant Field Values

EXTRA_KEY_BITS

private static final int EXTRA_KEY_BITS
This is the number of extra key bits (maybe 0), which are not embedded in the captcha. If the number of key bits embedded in the captcha is very small, the attacker could solve the captcha via a brute-force attack. Because of the redundancy in the 128 bit AES block, he would know, when he has broken the captcha. With this extra key bits, we can make the attack more expensive because the attacker has to do the brute-force attack over the captcha key bits and the extra key bits. But a normal blockee doesn't know those extra key bits too. He has also to do a brute-force tryout, but only over those extra key bits. So this value shouldn't be to big, around 16 should be ok. Keep in mind that if you use extra key bits, the blockee needs some redundancy for verifying that he has found the right extra key. So the sum of CAPTCHA_KEY_BITS + EXTRA_KEY_BITS shouldn't be bigger than 90. The EXTRA_KEY_BITS need not!!! to be a multiple of 8.

See Also:
Constant Field Values

m_forwarderAddress

private java.net.InetAddress m_forwarderAddress
Stores the internet address of the forwarder. At the moment only IPv4 addresses are supported.


m_forwarderPort

private int m_forwarderPort
Stores the port number of the forwarder.


m_forwarderData

private byte[] m_forwarderData
Stores the plain data which are used when generating the cipher data with the captcha key. It's a 128 bit data block (for encryption with AES). The bytes 0 ... 9 are always 0, the bytes 10 ... 13 are the IP address of the forwarder in network byte order, the highest order byte is byte 10. The bytes 14, 15 are the port of the forwarder, where byte 14 is the highest order byte.


m_id

private java.lang.String m_id
Stores the ID for this ForwarderDBEntry. It's a Base64 encoded String of a 128 bit random number.


m_creationTimeStamp

private long m_creationTimeStamp
Stores the time when this ForwarderDBEntry was created. This value is used to determine the more recent entry, if two entries are compared (higher version number -> more recent entry).

Constructor Detail

ForwarderDBEntry

public ForwarderDBEntry(java.net.InetAddress a_forwarderAddress,
                        int a_forwarderPort)
                 throws java.lang.Exception
Creates a new ForwarderDBEntry. Also an ID is generated for this entry. The ID is a 128 bit random number, stored as a Base64 encoded string. This constructor can throw an Exception but this should never happen.

Parameters:
a_forwarderAddress - The internet address of the forwarder. At the moment, only IPv4 addresses are supported.
a_forwarderPort - The port number the forwarder listens on.
Throws:
java.lang.Exception

ForwarderDBEntry

private ForwarderDBEntry(java.net.InetAddress a_forwarderAddress,
                         int a_forwarderPort,
                         byte[] a_forwarderData,
                         java.lang.String a_id)
This internal constructor is needed for creating a clone of a ForwarderDBEntry, needed for updating the forwarder database. The creation time is set to the current system time.

Parameters:
a_forwarderAddress - The internet address of the forwarder.
a_forwarderPort - The port number the forwarder listens on.
a_forwarderData - The data block with the IP and port of the forwarder, which is used for AES encryption.
a_id - The ID of this forwarder database entry.
Method Detail

getUpdateClone

public ForwarderDBEntry getUpdateClone()
Returns a clone of this ForwarderDBEntry. The clone is identical to this instance except the creation time, which is set to the current time, and the updates number, which is rised by 1.

Returns:
The clone of this entry needed for updating the forwarder database.

getId

public java.lang.String getId()
Returns a unique ID for this forwarder database entry. It's a Base64 encoded string of a 128 bit random number.

Specified by:
getId in class AbstractDatabaseEntry
Returns:
The ID of this forwarder database entry.

getLastUpdate

public long getLastUpdate()
Description copied from class: AbstractDatabaseEntry
Returns the time in milliseconds when this db entry was created from the origin instance.

Specified by:
getLastUpdate in class AbstractDatabaseEntry
Returns:
the time in milliseconds when this db entry was created from the origin instance

getVersionNumber

public long getVersionNumber()
Returns the time when this ForwarderDBEntry was created.

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

createCaptchaNode

public org.w3c.dom.Element createCaptchaNode()
                                      throws java.lang.Exception
Creates the JapForwarder node with the captcha data included. This node can be transferd to the blockee, who can solve the captcha and gets the forwarder information, which is encoded with the key embedded in the captcha. This method creates everything needed for transfer to the blockee. The method can throw an Exception, when there is something wrong with the XML transformation, but this should never happen.

Returns:
The JapForwarder node for transfer to the blockee.
Throws:
java.lang.Exception