Changeset 4a656767


Ignore:
Timestamp:
Jun 5, 2013 4:39:50 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
b7dc8f42
Parents:
000ca7c
Message:

throw ISE if LS changed after being signed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/LeaseSet.java

    r000ca7c r4a656767  
    110110    }
    111111
     112    /**
     113     * @throws IllegalStateException if already signed
     114     */
    112115    public void setDestination(Destination dest) {
     116        if (_signature != null)
     117            throw new IllegalStateException();
    113118        _destination = dest;
    114119    }
     
    118123    }
    119124
     125    /**
     126     * @throws IllegalStateException if already signed
     127     */
    120128    public void setEncryptionKey(PublicKey encryptionKey) {
     129        if (_signature != null)
     130            throw new IllegalStateException();
    121131        _encryptionKey = encryptionKey;
    122132    }
     
    137147     */
    138148    public boolean getReceivedAsPublished() { return _receivedAsPublished; }
     149
    139150    /** Default false */
    140151    public void setReceivedAsPublished(boolean received) { _receivedAsPublished = received; }
     
    146157     */
    147158    public boolean getReceivedAsReply() { return _receivedAsReply; }
     159
    148160    /** set to true @since 0.7.14 */
    149161    public void setReceivedAsReply() { _receivedAsReply = true; }
    150162
     163    /**
     164     * @throws IllegalStateException if already signed
     165     */
    151166    public void addLease(Lease lease) {
    152167        if (lease == null) throw new IllegalArgumentException("erm, null lease");
    153168        if (lease.getGateway() == null) throw new IllegalArgumentException("erm, lease has no gateway");
    154169        if (lease.getTunnelId() == null) throw new IllegalArgumentException("erm, lease has no tunnel");
    155         if (_leases.size() > MAX_LEASES)
     170        if (_signature != null)
     171            throw new IllegalStateException();
     172        if (_leases.size() >= MAX_LEASES)
    156173            throw new IllegalArgumentException("Too many leases - max is " + MAX_LEASES);
    157174        _leases.add(lease);
     
    164181
    165182    /**
    166      *  @return 0-6
     183     *  @return 0-16
    167184     *  A LeaseSet with no leases is revoked.
    168185     */
Note: See TracChangeset for help on using the changeset viewer.