public class LeaseSet extends DatabaseEntry
LeaseSet is the fundamental routing structure in I2P, containing:
Lease Structure:
Encryption Support (Legacy):
Encryption Process:
getLease(int)Usage:
Security Considerations:
Migration Path:
| Modifier and Type | Field and Description |
|---|---|
protected byte[] | _byteifiedCached serialized byte array for performance. |
protected boolean | _checkedWhether decryption has been attempted. |
protected Destination | _destinationDestination this LeaseSet is for. |
protected PublicKey | _encryptionKeyEncryption public key for the destination. |
protected long | _lastExpirationLatest expiration time among all leases. |
protected List<Lease> | _leasesLeases must stay in the order received, or signature verification will fail. |
protected SigningPublicKey | _signingKeyRevocation or blinded signing key. |
static int | MAX_LEASESUnlimited before 0.6.3;
6 as of 0.6.3;
Increased in version 0.9. |
_signature, KEY_TYPE_ENCRYPTED_LS2, KEY_TYPE_LEASESET, KEY_TYPE_LS2, KEY_TYPE_META_LS2, KEY_TYPE_ROUTERINFO, KEY_TYPE_SERVICE_LIST, KEY_TYPE_SERVICE_RECORD| Constructor and Description |
|---|
LeaseSet()Creates a new leaseset with default values. |
| Modifier and Type | Method and Description |
|---|---|
void | addLease(Lease lease)Adds a lease to this leaseset. |
void | encrypt(SessionKey key)Encrypt the gateway and tunnel ID of each lease, leaving the expire dates unchanged. |
boolean | equals(Object object) |
protected byte[] | getBytes()without sig! |
long | getDate()Same as getEarliestLeaseDate() |
Destination | getDestination()Warning - will be null for LS2 EncryptedLeaseSets if not decrypted |
long | getEarliestLeaseDate()Retrieve the end date of the earliest lease included in this leaseSet. |
PublicKey | getEncryptionKey()Encryption public key. |
PublicKey | getEncryptionKey(Set<EncType> supported)If more than one key, return the first supported one. |
KeysAndCert | getKeysAndCert()Keys and certificate for this lease set. |
long | getLatestLeaseDate()Retrieve the end date of the latest lease included in this leaseSet. |
Lease | getLease(int index)Get the lease at the given index. |
int | getLeaseCount()Gets the number of leases in this leaseset. |
SigningPublicKey | getSigningKey()The revocation key. |
int | getType()Lease set type for the network database. |
int | hashCode()the destination has enough randomness in it to use it by itself for speed |
boolean | isCurrent(long fudge)Determine whether ANY lease is currently valid, at least within a given
fudge factor |
void | readBytes(InputStream in)This does NOT validate the signature |
void | setDestination(Destination dest)Sets the destination for this leaseset. |
void | setEncryptionKey(PublicKey encryptionKey)Sets the encryption key for this leaseset. |
void | setReceivedBy(Hash localClient)As of 0.9.65, no longer sets receivedAsReply to true |
void | setSigningKey(SigningPublicKey key)The revocation key. |
int | size()Number of bytes, NOT including signature |
String | toString() |
boolean | verifySignature()Verify that the signature matches the leaseset's destination's signing public key. |
void | writeBytes(OutputStream out)This does NOT validate the signature |
getHash, getReceivedAsPublished, getReceivedAsReply, getReceivedBy, getRoutingKey, getSignature, getSigningPublicKey, isLeaseSet, isLeaseSet, isRouterInfo, setReceivedAsPublished, setReceivedAsReply, setSignature, sign, validateRoutingKeycalculateHash, fromBase64, fromByteArray, read, toBase64, toByteArrayprotected volatile byte[] _byteified
protected boolean _checked
protected Destination _destination
protected PublicKey _encryptionKey
protected long _lastExpiration
protected final List<Lease> _leases
protected SigningPublicKey _signingKey
public static final int MAX_LEASES
public void addLease(Lease lease)
IllegalStateException - if already signedpublic void encrypt(SessionKey key)
protected byte[] getBytes()
getBytes in class DatabaseEntrypublic long getDate()
getDate in class DatabaseEntrypublic Destination getDestination()
public long getEarliestLeaseDate()
public PublicKey getEncryptionKey()
public PublicKey getEncryptionKey(Set<EncType> supported)
supported - what return types are allowedpublic KeysAndCert getKeysAndCert()
getKeysAndCert in class DatabaseEntrypublic long getLatestLeaseDate()
public Lease getLease(int index)
index - the lease indexpublic int getLeaseCount()
public SigningPublicKey getSigningKey()
public int getType()
getType in class DatabaseEntrypublic int hashCode()
public boolean isCurrent(long fudge)
fudge - milliseconds fudge factor to allow between the current timepublic void readBytes(InputStream in) throws DataFormatException, IOException
in - stream to read fromIllegalStateException - if called more than once or Destination already setDataFormatException - if the data is improperly formattedIOException - if there was a problem reading the streampublic void setDestination(Destination dest)
IllegalStateException - if already signedpublic void setEncryptionKey(PublicKey encryptionKey)
IllegalStateException - if already signedpublic void setReceivedBy(Hash localClient)
setReceivedBy in class DatabaseEntrylocalClient - may be nullpublic void setSigningKey(SigningPublicKey key)
IllegalArgumentException - if different typepublic int size()
public boolean verifySignature()
verifySignature in class DatabaseEntrypublic void writeBytes(OutputStream out) throws DataFormatException, IOException
out - stream to write toDataFormatException - if the data was incomplete or not yet ready to be writtenIOException - if there was a problem writing to the stream