net.i2p.data.i2cp

## Class CreateLeaseSet2Message

- java.lang.Object
- - net.i2p.data.i2cp.I2CPMessageImpl
  - - net.i2p.data.i2cp.CreateLeaseSetMessage
    - - net.i2p.data.i2cp.CreateLeaseSet2Message

- All Implemented Interfaces:
    I2CPMessage

      public class CreateLeaseSet2Message
      extends CreateLeaseSetMessage

  Like CreateLeaseSetMessage, but supports both old and new LeaseSet types, including LS2, Meta, and Encrypted. Revocation keys are not present. Multiple public/private encryption keys are possible. For LS2: Same as CreateLeaseSetMessage, but has a netdb type before the LeaseSet. PrivateKeys are serialized after the LeaseSet, not before, so we can infer the types from the LeaseSet. For Meta LS: PrivateKeys are not present.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `MESSAGE_TYPE` NOTE: Preliminary format was type 40 in 0.9.38.

    - ### Fields inherited from class net.i2p.data.i2cp.CreateLeaseSetMessage

      `_leaseSet, _privateKey, _sessionId`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CreateLeaseSet2Message()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPrivateKey(PrivateKey key)` Add a private key.
    `protected void` | `doReadMessage(InputStream in, int size)` Read in the payload part of the message (after the initial 4 byte size and 1 byte type)
    `protected byte[]` | `doWriteMessage()` Write out the payload part of the message (not including the 4 byte size and 1 byte type)
    `List<PrivateKey>` | `getPrivateKeys()` This returns all the keys.
    `int` | `getType()` Return the unique identifier for this type of message, as specified in the network specification document under #ClientAccessLayerMessages
    `String` | `toString()`

    - ### Methods inherited from class net.i2p.data.i2cp.CreateLeaseSetMessage

      `getLeaseSet, getPrivateKey, getSessionId, getSigningPrivateKey, sessionId, setLeaseSet, setPrivateKey, setSessionId, setSigningPrivateKey`

    - ### Methods inherited from class net.i2p.data.i2cp.I2CPMessageImpl

      `readBytes, readMessage, readMessage, writeBytes, writeMessage`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### MESSAGE_TYPE

          public static final int MESSAGE_TYPE

      NOTE: Preliminary format was type 40 in 0.9.38. Format changed as of 0.9.39, changed type to 41.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CreateLeaseSet2Message

          public CreateLeaseSet2Message()

  - ### Method Detail

    - #### addPrivateKey

          public void addPrivateKey(PrivateKey key)

      Add a private key.

    - #### doReadMessage

          protected void doReadMessage(InputStream in,
                                       int size)
                                throws I2CPMessageException,
                                       IOException

      Description copied from class: `I2CPMessageImpl`
      Read in the payload part of the message (after the initial 4 byte size and 1 byte type)
      Overrides:
        `doReadMessage` in class `CreateLeaseSetMessage`
      Parameters:
        `in` - InputStream
        `size` - payload size
      Throws:
        `I2CPMessageException` - if the message format is invalid
        `IOException` - if there's an error reading from the stream

    - #### doWriteMessage

          protected byte[] doWriteMessage()
                                   throws I2CPMessageException,
                                          IOException

      Description copied from class: `I2CPMessageImpl`
      Write out the payload part of the message (not including the 4 byte size and 1 byte type)
      Overrides:
        `doWriteMessage` in class `CreateLeaseSetMessage`
      Returns:
        byte array
      Throws:
        `I2CPMessageException` - if the message cannot be written
        `IOException` - if there's an error writing to the stream

    - #### getPrivateKeys

          public List<PrivateKey> getPrivateKeys()

      This returns all the keys. getPrivateKey() returns the first one.
      Returns:
        not a copy, do not modify, null if none

    - #### getType

          public int getType()

      Description copied from interface: `I2CPMessage`
      Return the unique identifier for this type of message, as specified in the network specification document under #ClientAccessLayerMessages
      Specified by:
        `getType` in interface `I2CPMessage`
      Overrides:
        `getType` in class `CreateLeaseSetMessage`
      Returns:
        unique identifier for this type of message

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `CreateLeaseSetMessage`