net.i2p.data
Class Destination

java.lang.Object
  extended by net.i2p.data.DataStructureImpl
      extended by net.i2p.data.KeysAndCert
          extended by net.i2p.data.Destination
All Implemented Interfaces:
Serializable, DataStructure
Direct Known Subclasses:
VerifiedDestination

public class Destination
extends KeysAndCert

Defines an end point in the I2P network. The Destination may move around in the network, but messages sent to the Destination will find it Note that the public (encryption) key is essentially unused, since "end-to-end" encryption was removed in 0.6. The public key in the LeaseSet is used instead. The first bytes of the public key are used for the IV for leaseset encryption, but that encryption is poorly designed and should be deprecated. As of 0.9.9 this data structure is immutable after the two keys and the certificate are set; attempts to change them will throw an IllegalStateException.

Author:
jrandom
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.i2p.data.KeysAndCert
_certificate, _padding, _publicKey, _signingKey
 
Constructor Summary
Destination()
           
Destination(String s)
          alternative constructor which takes a base64 string representation
 
Method Summary
static void clearCache()
          Clear the cache.
static Destination create(InputStream in)
          Pull from cache or return new
 boolean equals(Object o)
           
 int hashCode()
          the signing key has enough randomness in it to use it by itself for speed
 int readBytes(byte[] source, int offset)
          deprecated was used only by Packet.java in streaming, now unused Warning - used by i2p-bote.
 int size()
           
 String toBase32()
          For convenience.
 String toBase64()
          Cache it.
 int writeBytes(byte[] target, int offset)
          Deprecated, used only by Packet.java in streaming.
 
Methods inherited from class net.i2p.data.KeysAndCert
calculateHash, getCertificate, getHash, getPadding, getPublicKey, getSigningPublicKey, getSigType, readBytes, setCertificate, setPadding, setPublicKey, setSigningPublicKey, toString, writeBytes
 
Methods inherited from class net.i2p.data.DataStructureImpl
fromBase64, fromByteArray, read, toByteArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Destination

public Destination()

Destination

public Destination(String s)
            throws DataFormatException
alternative constructor which takes a base64 string representation

Parameters:
s - a Base64 representation of the destination, as (eg) is used in hosts.txt
Throws:
DataFormatException
Method Detail

create

public static Destination create(InputStream in)
                          throws DataFormatException,
                                 IOException
Pull from cache or return new

Throws:
DataFormatException
IOException
Since:
0.9.9

writeBytes

public int writeBytes(byte[] target,
                      int offset)
Deprecated, used only by Packet.java in streaming. Broken for sig types P521 and RSA before 0.9.15

Returns:
the written length (NOT the new offset)

readBytes

public int readBytes(byte[] source,
                     int offset)
              throws DataFormatException
deprecated was used only by Packet.java in streaming, now unused Warning - used by i2p-bote. Does NOT support alternate key types. DSA-SHA1 only.

Throws:
IllegalStateException - if data already set
DataFormatException

size

public int size()

toBase64

public String toBase64()
Cache it. Useful in I2PTunnelHTTPServer where it is added to the headers

Specified by:
toBase64 in interface DataStructure
Overrides:
toBase64 in class DataStructureImpl
Returns:
null on error
Since:
0.9.9

toBase32

public String toBase32()
For convenience.

Returns:
"{52 chars}.b32.i2p" or null if fields not set.
Since:
0.9.14

clearCache

public static void clearCache()
Clear the cache.

Since:
0.9.9

equals

public boolean equals(Object o)
Overrides:
equals in class KeysAndCert

hashCode

public int hashCode()
Description copied from class: KeysAndCert
the signing key has enough randomness in it to use it by itself for speed

Overrides:
hashCode in class KeysAndCert