Package net.i2p.data

Class LeaseSet2

    • Field Detail

      • _flags

        protected int _flags
      • _published

        protected long _published
      • _expires

        protected long _expires
      • _transientExpires

        protected long _transientExpires
      • _transientSigningPublicKey

        protected SigningPublicKey _transientSigningPublicKey
      • _offlineSignature

        protected Signature _offlineSignature
    • Constructor Detail

      • LeaseSet2

        public LeaseSet2()
    • Method Detail

      • getPublished

        public long getPublished()
        Published timestamp, as received. Different than getDate() or getEarliestLeaseDate(), which are the earliest lease expiration.
        Returns:
        in ms, with 1 second resolution
        Since:
        0.9.39
      • getExpires

        public long getExpires()
        Published expiration, as received. May be different than getLatestLeaseDate(), which is the latest lease expiration.
        Returns:
        in ms, with 1 second resolution
        Since:
        0.9.39
      • isUnpublished

        public boolean isUnpublished()
      • isBlindedWhenPublished

        public boolean isBlindedWhenPublished()
        Set if the unencrypted LS, when published, will be blinded/encrypted
        Since:
        0.9.42
      • setBlindedWhenPublished

        public void setBlindedWhenPublished()
        Set if the unencrypted LS, when published, will be blinded/encrypted
        Throws:
        IllegalStateException - if already signed
        Since:
        0.9.42
      • getReceivedAsPublished

        public boolean getReceivedAsPublished()
        If true, we received this LeaseSet by a remote peer publishing it to us, AND the unpublished flag is not set. Default false.
        Overrides:
        getReceivedAsPublished in class LeaseSet
        Since:
        0.9.39 overridden
      • getEncryptionKey

        public PublicKey getEncryptionKey()
        If more than one key, return the first supported one. If none supported, return the first one.
        Overrides:
        getEncryptionKey in class LeaseSet
        Since:
        0.9.39 overridden
      • getEncryptionKey

        public PublicKey getEncryptionKey​(Set<EncType> supported)
        If more than one key, return the first supported one. If none supported, return null.
        Overrides:
        getEncryptionKey in class LeaseSet
        Parameters:
        supported - what return types are allowed
        Returns:
        first supported key or null
        Since:
        0.9.44
      • addEncryptionKey

        public void addEncryptionKey​(PublicKey key)
        Add an encryption key. Encryption keys should be added in order of server preference, most-preferred first.
      • getEncryptionKeys

        public List<PublicKey> getEncryptionKeys()
        This returns all the keys. getEncryptionKey() returns the first one. Encryption keys should be in order of server preference, most-preferred first. Client behavior should be to select the first key with a supported encryption type. Clients may use other selection algorithms based on encryption support, relative performance, and other factors.
        Returns:
        not a copy, do not modify, null if none
      • setOptions

        public void setOptions​(Properties options)
        Configure a set of options or statistics that the router can expose. Makes a copy. Warning, clears all capabilities, must be called BEFORE addCapability().
        Parameters:
        options - if null, clears current options
        Throws:
        IllegalStateException - if LeaseSet2 is already signed
      • isOffline

        public boolean isOffline()
      • getTransientSigningKey

        public SigningPublicKey getTransientSigningKey()
        Returns:
        transient public key or null if not offline signed
      • getTransientExpiration

        public long getTransientExpiration()
        Absolute time, not time from now.
        Returns:
        transient expiration time or 0 if not offline signed
        Since:
        0.9.48
      • setOfflineSignature

        public boolean setOfflineSignature​(long expires,
                                           SigningPublicKey transientSPK,
                                           Signature offlineSig)
        Destination must be previously set.
        Parameters:
        expires - absolute ms
        transientSPK - the key that will sign the leaseset
        offlineSig - the signature by the spk in the destination
        Returns:
        success, false if verify failed or expired
        Throws:
        IllegalStateException - if already signed
      • offlineSign

        public static Signature offlineSign​(long expires,
                                            SigningPublicKey transientSPK,
                                            SigningPrivateKey priv)
        Generate a Signature to pass to setOfflineSignature()
        Parameters:
        expires - absolute ms
        transientSPK - the key that will sign the leaseset
        priv - the private signing key for the destination
        Returns:
        null on error
      • verifyOfflineSignature

        public boolean verifyOfflineSignature()
      • verifyOfflineSignature

        protected boolean verifyOfflineSignature​(SigningPublicKey spk)
      • setBlindedHash

        public void setBlindedHash​(Hash bh)
        Set this on creation if known
      • getBlindedHash

        public Hash getBlindedHash()
        The orignal blinded hash, where this came from.
        Returns:
        null if unknown or not previously blinded
      • getType

        public int getType()
        Description copied from class: DatabaseEntry
        Get the type of the data structure. This should be faster than instanceof.
        Overrides:
        getType in class LeaseSet
        Returns:
        KEY_TYPE_ROUTERINFO or KEY_TYPE_LEASESET or LS2 types
      • setSigningKey

        public void setSigningKey​(SigningPublicKey key)
        The revocation key. Overridden to do nothing, as we're using the _signingKey field for the blinded key in Enc LS2.
        Overrides:
        setSigningKey in class LeaseSet
        Since:
        0.9.39
      • isCurrent

        public boolean isCurrent​(long fudge)
        Determine whether the leaseset is currently valid, at least within a given fudge factor. Overridden to use the expiration time instead of the last expiration.
        Overrides:
        isCurrent in class LeaseSet
        Parameters:
        fudge - milliseconds fudge factor to allow between the current time
        Returns:
        true if there are current leases, false otherwise
        Since:
        0.9.39
      • getBytes

        protected byte[] getBytes()
        without sig!
        Overrides:
        getBytes in class LeaseSet
        Returns:
        null on error ???????????????????????
      • size

        public int size()
        Number of bytes, NOT including signature
        Overrides:
        size in class LeaseSet
      • verifySignature

        public boolean verifySignature()
        Verify with the SPK in the dest for online sigs. Verify with the SPK in the offline sig section for offline sigs.
        Overrides:
        verifySignature in class LeaseSet
        Returns:
        valid
      • hashCode

        public int hashCode()
        the destination has enough randomness in it to use it by itself for speed
        Overrides:
        hashCode in class LeaseSet
      • encrypt

        public void encrypt​(SessionKey key)
        Description copied from class: LeaseSet
        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().
        Overrides:
        encrypt in class LeaseSet