|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.data.DataStructureImpl
net.i2p.data.DatabaseEntry
public abstract class DatabaseEntry
Base implementation of common methods for the two data structures that are stored in the netDb, i.e. LeaseSet and RouterInfo. Implemented in 0.8.2 and retrofitted over LeaseSet and RouterInfo. This consolidates some common code and makes it easier to implement the NetDB and I2NP without doing instanceof all over the place.
DatabaseEntries have a SHA256 hash, a routing key, a timestamp, and signatures.
Do not reuse objects. Many of the setters and other methods contain checks to prevent altering a DatabaseEntry after it is signed. This protects the netdb, messages that contain DatabaseEntries, and the object itself from simple causes of corruption, by throwing IllegalStateExceptions. These checks are not necessarily thread-safe, and are not guaranteed to catch all possible means of corruption. Beware of other avenues of corruption, such as directly modifying data stored in byte[] objects.
Field Summary | |
---|---|
protected Hash |
_currentRoutingKey
|
protected long |
_routingKeyGenMod
|
protected Signature |
_signature
|
static int |
KEY_TYPE_LEASESET
|
static int |
KEY_TYPE_ROUTERINFO
these are the same as in i2np's DatabaseStoreMessage |
Constructor Summary | |
---|---|
DatabaseEntry()
|
Method Summary | |
---|---|
protected abstract byte[] |
getBytes()
Returns the raw payload data, excluding the signature, to be signed by sign(). |
abstract long |
getDate()
A common interface to the timestamp of the two subclasses. |
Hash |
getHash()
A common interface to the Hash of the two subclasses. |
abstract KeysAndCert |
getKeysAndCert()
Get the keys and the cert Identical to getDestination() in LeaseSet, and getIdentity() in RouterInfo. |
Hash |
getRoutingKey()
Get the routing key for the structure using the current modifier in the RoutingKeyGenerator. |
Signature |
getSignature()
Retrieve the proof that the identity stands behind the info here |
protected SigningPublicKey |
getSigningPublicKey()
Identical to getDestination().getSigningPublicKey() in LeaseSet, and getIdentity().getSigningPublicKey() in RouterInfo. |
abstract int |
getType()
Get the type of the data structure. |
void |
setRoutingKey(Hash key)
Deprecated. unused |
void |
setSignature(Signature signature)
Configure the proof that the entity stands behind the info here |
void |
sign(SigningPrivateKey key)
Sign the structure using the supplied signing key |
boolean |
validateRoutingKey()
|
protected boolean |
verifySignature()
This is the same as isValid() in RouterInfo or verifySignature() in LeaseSet. |
Methods inherited from class net.i2p.data.DataStructureImpl |
---|
calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.i2p.data.DataStructure |
---|
readBytes, writeBytes |
Field Detail |
---|
public static final int KEY_TYPE_ROUTERINFO
public static final int KEY_TYPE_LEASESET
protected volatile Signature _signature
protected volatile Hash _currentRoutingKey
protected volatile long _routingKeyGenMod
Constructor Detail |
---|
public DatabaseEntry()
Method Detail |
---|
public abstract long getDate()
public abstract KeysAndCert getKeysAndCert()
public Hash getHash()
public abstract int getType()
protected abstract byte[] getBytes() throws DataFormatException
DataFormatException
public Hash getRoutingKey()
IllegalStateException
- if not in RouterContextpublic void setRoutingKey(Hash key)
public boolean validateRoutingKey()
IllegalStateException
- if not in RouterContextpublic Signature getSignature()
public void setSignature(Signature signature)
IllegalStateException
- if already signedpublic void sign(SigningPrivateKey key) throws DataFormatException
IllegalStateException
- if already signed
DataFormatException
protected SigningPublicKey getSigningPublicKey()
protected boolean verifySignature()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |