Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.i2p.data
Class LeaseSet

    java.lang.Object
      net.i2p.data.DataStructureImpl
          net.i2p.data.LeaseSet

All Implemented Interfaces:
  DataStructure

    public class LeaseSet

extends DataStructureImpl

Defines the set of leases a destination currently has. Support encryption and decryption with a supplied key. Only the gateways and tunnel IDs in the individual leases are encrypted. Encrypted leases are not indicated as such. The only way to tell a lease is encrypted is to determine that the listed gateways do not exist. Routers wishing to decrypt a leaseset must have the desthash and key in their keyring. This is required for the local router as well, since the encryption is done on the client side of I2CP, the router must decrypt it back again for local usage (but not for transmission to the floodfills) Decrypted leases are only available through the getLease() method, so that storage and network transmission via writeBytes() will output the original encrypted leases and the original leaseset signature. Revocation (zero leases) isn't used anywhere. In addition: - A revoked leaseset has an EarliestLeaseDate of -1, so it will never be stored successfully. - Revocation of an encrypted leaseset will explode. - So having an included signature at all is pointless?

Author:
  jrandom

Field Summary
`static int` | `MAX_LEASES` This seems like plenty

Constructor Summary
`LeaseSet()`

Method Summary
`void` | `addLease(Lease lease)`
`void` | `encrypt(SessionKey key)` Encrypt the gateway and tunnel ID of each lease, leaving the expire dates unchanged.
`boolean` | `equals(Object object)`
`Destination` | `getDestination()`
`long` | `getEarliestLeaseDate()` Retrieve the end date of the earliest lease include in this leaseSet.
`PublicKey` | `getEncryptionKey()`
`Lease` | `getLease(int index)`
`int` | `getLeaseCount()`
`boolean` | `getReceivedAsPublished()` If true, we received this LeaseSet by a remote peer publishing it to us, rather than by searching for it ourselves or locally creating it.
`boolean` | `getReceivedAsReply()` If true, we received this LeaseSet by searching for it Default false.
`Hash` | `getRoutingKey()` Get the routing key for the structure using the current modifier in the RoutingKeyGenerator.
`Signature` | `getSignature()`
`SigningPublicKey` | `getSigningKey()` Deprecated. unused
`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)` Load up the current object with data from the given stream.
`void` | `setDestination(Destination dest)`
`void` | `setEncryptionKey(PublicKey encryptionKey)`
`void` | `setReceivedAsPublished(boolean received)` Default false
`void` | `setReceivedAsReply()` set to true @since 0.7.14
`void` | `setRoutingKey(Hash key)`
`void` | `setSignature(Signature sig)`
`void` | `setSigningKey(SigningPublicKey key)`
`void` | `sign(SigningPrivateKey key)` Sign the structure using the supplied signing key
`int` | `size()`
`String` | `toString()`
`boolean` | `validateRoutingKey()`
`boolean` | `verifySignature()` Verify that the signature matches the lease set's destination's signing public key.
`boolean` | `verifySignature(SigningPublicKey signingKey)` Verify that the signature matches the lease set's destination's signing public key.
`void` | `writeBytes(OutputStream out)` Write out the data structure to the stream, using the format defined in the I2P data structure specification.

Methods inherited from class net.i2p.data.DataStructureImpl
`calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### MAX_LEASES

    public static final int MAX_LEASES

  This seems like plenty

  See Also:
    Constant Field Values

Constructor Detail

### LeaseSet

    public LeaseSet()

Method Detail

### getDestination

    public Destination getDestination()

### setDestination

    public void setDestination(Destination dest)

### getEncryptionKey

    public PublicKey getEncryptionKey()

### setEncryptionKey

    public void setEncryptionKey(PublicKey encryptionKey)

### getSigningKey

    public SigningPublicKey getSigningKey()

  Deprecated. unused

### setSigningKey

    public void setSigningKey(SigningPublicKey key)

### getReceivedAsPublished

    public boolean getReceivedAsPublished()

  If true, we received this LeaseSet by a remote peer publishing it to us, rather than by searching for it ourselves or locally creating it. Default false.

### setReceivedAsPublished

    public void setReceivedAsPublished(boolean received)

  Default false

### getReceivedAsReply

    public boolean getReceivedAsReply()

  If true, we received this LeaseSet by searching for it Default false.

  Since:
    0.7.14

### setReceivedAsReply

    public void setReceivedAsReply()

  set to true @since 0.7.14

### addLease

    public void addLease(Lease lease)

### getLeaseCount

    public int getLeaseCount()

  Returns:
    0-6 A LeaseSet with no leases is revoked.

### getLease

    public Lease getLease(int index)

### getSignature

    public Signature getSignature()

### setSignature

    public void setSignature(Signature sig)

### getRoutingKey

    public Hash getRoutingKey()

  Get the routing key for the structure using the current modifier in the RoutingKeyGenerator. This only calculates a new one when necessary though (if the generator's key modifier changes)

### setRoutingKey

    public void setRoutingKey(Hash key)

### validateRoutingKey

    public boolean validateRoutingKey()

### getEarliestLeaseDate

    public long getEarliestLeaseDate()

  Retrieve the end date of the earliest lease include in this leaseSet. This is the date that should be used in comparisons for leaseSet age - to determine which LeaseSet was published more recently (later earliestLeaseSetDate means it was published later)

  Returns:
    earliest end date of any lease in the set, or -1 if there are no leases

### sign

    public void sign(SigningPrivateKey key)
              throws DataFormatException

  Sign the structure using the supplied signing key

  Throws:
    `DataFormatException`

### verifySignature

    public boolean verifySignature()

  Verify that the signature matches the lease set's destination's signing public key. OR the included revocation key.

  Returns:
    true only if the signature matches

### verifySignature

    public boolean verifySignature(SigningPublicKey signingKey)

  Verify that the signature matches the lease set's destination's signing public key. OR the specified revocation key.

  Returns:
    true only if the signature matches

### isCurrent

    public boolean isCurrent(long fudge)

  Determine whether ANY lease is currently valid, at least within a given fudge factor

  Parameters:
    `fudge` - milliseconds fudge factor to allow between the current time
  Returns:
    true if there are current leases, false otherwise

### readBytes

    public void readBytes(InputStream in)
                   throws DataFormatException,
                          IOException

  Description copied from interface: `DataStructure`
  Load up the current object with data from the given stream. Data loaded this way must match the I2P data structure specification.

  Parameters:
    `in` - stream to read from
  Throws:
    `DataFormatException` - if the data is improperly formatted
    `IOException` - if there was a problem reading the stream

### writeBytes

    public void writeBytes(OutputStream out)
                    throws DataFormatException,
                           IOException

  Description copied from interface: `DataStructure`
  Write out the data structure to the stream, using the format defined in the I2P data structure specification.

  Parameters:
    `out` - stream to write to
  Throws:
    `DataFormatException` - if the data was incomplete or not yet ready to be written
    `IOException` - if there was a problem writing to the stream

### size

    public int size()

### equals

    public boolean equals(Object object)

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  the destination has enough randomness in it to use it by itself for speed

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### encrypt

    public void encrypt(SessionKey key)

  Encrypt the gateway and tunnel ID of each lease, leaving the expire dates unchanged. This adds an extra dummy lease, because AES data must be padded to 16 bytes. The fact that it is encrypted is not stored anywhere. Must be called after all the leases are in place, but before sign().

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD