public class LeaseSet2 extends LeaseSet
Modifier and Type | Field and Description |
---|---|
protected long |
_expires |
protected int |
_flags |
protected Signature |
_offlineSignature |
protected Properties |
_options |
protected long |
_published |
protected long |
_transientExpires |
protected SigningPublicKey |
_transientSigningPublicKey |
_byteified, _checked, _destination, _encryptionKey, _lastExpiration, _leases, _receivedAsPublished, _signingKey, MAX_LEASES
_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 |
---|
LeaseSet2() |
Modifier and Type | Method and Description |
---|---|
void |
addEncryptionKey(PublicKey key)
Add an encryption key.
|
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) |
Hash |
getBlindedHash()
The orignal blinded hash, where this came from.
|
protected byte[] |
getBytes()
without sig!
|
PublicKey |
getEncryptionKey()
If more than one key, return the first supported one.
|
PublicKey |
getEncryptionKey(Set<EncType> supported)
If more than one key, return the first supported one.
|
List<PublicKey> |
getEncryptionKeys()
This returns all the keys.
|
long |
getExpires()
Published expiration, as received.
|
String |
getOption(String opt) |
long |
getPublished()
Published timestamp, as received.
|
boolean |
getReceivedAsPublished()
If true, we received this LeaseSet by a remote peer publishing it to
us, AND the unpublished flag is not set.
|
long |
getTransientExpiration()
Absolute time, not time from now.
|
SigningPublicKey |
getTransientSigningKey() |
int |
getType()
Get the type of the data structure.
|
int |
hashCode()
the destination has enough randomness in it to use it by itself for speed
|
boolean |
isBlindedWhenPublished()
Set if the unencrypted LS, when published, will be blinded/encrypted
|
boolean |
isCurrent(long fudge)
Determine whether the leaseset is currently valid, at least within a given
fudge factor.
|
boolean |
isOffline() |
boolean |
isUnpublished() |
static Signature |
offlineSign(long expires,
SigningPublicKey transientSPK,
SigningPrivateKey priv)
Generate a Signature to pass to setOfflineSignature()
|
void |
readBytes(InputStream in)
This does NOT validate the signature
|
protected void |
readHeader(InputStream in) |
protected void |
readOfflineBytes(InputStream in) |
void |
setBlindedHash(Hash bh)
Set this on creation if known
|
void |
setBlindedWhenPublished()
Set if the unencrypted LS, when published, will be blinded/encrypted
|
boolean |
setOfflineSignature(long expires,
SigningPublicKey transientSPK,
Signature offlineSig)
Destination must be previously set.
|
void |
setOptions(Properties options)
Configure a set of options or statistics that the router can expose.
|
void |
setSigningKey(SigningPublicKey key)
The revocation key.
|
void |
setUnpublished() |
void |
sign(SigningPrivateKey key)
Sign the structure using the supplied signing key.
|
int |
size()
Number of bytes, NOT including signature
|
String |
toString() |
boolean |
verifyOfflineSignature() |
protected boolean |
verifyOfflineSignature(SigningPublicKey spk) |
boolean |
verifySignature()
Verify with the SPK in the dest for online sigs.
|
protected void |
writeBody(OutputStream out)
Without sig.
|
void |
writeBytes(OutputStream out)
Including sig.
|
protected void |
writeBytesWithoutSig(OutputStream out)
Without sig.
|
protected void |
writeHeader(OutputStream out) |
protected void |
writeOfflineBytes(OutputStream out) |
getDate, getDestination, getEarliestLeaseDate, getKeysAndCert, getLatestLeaseDate, getLease, getLeaseCount, getReceivedAsReply, getReceivedBy, getSigningKey, setDestination, setEncryptionKey, setReceivedAsPublished, setReceivedAsReply, setReceivedBy, verifySignature
getHash, getRoutingKey, getSignature, getSigningPublicKey, isLeaseSet, isLeaseSet, setSignature, validateRoutingKey
calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray
protected int _flags
protected long _published
protected long _expires
protected long _transientExpires
protected SigningPublicKey _transientSigningPublicKey
protected Signature _offlineSignature
protected Properties _options
public long getPublished()
public long getExpires()
public boolean isUnpublished()
public void setUnpublished()
IllegalStateException
- if already signedpublic boolean isBlindedWhenPublished()
public void setBlindedWhenPublished()
IllegalStateException
- if already signedpublic boolean getReceivedAsPublished()
getReceivedAsPublished
in class LeaseSet
public PublicKey getEncryptionKey()
getEncryptionKey
in class LeaseSet
public PublicKey getEncryptionKey(Set<EncType> supported)
getEncryptionKey
in class LeaseSet
supported
- what return types are allowedpublic void addEncryptionKey(PublicKey key)
public List<PublicKey> getEncryptionKeys()
public void setOptions(Properties options)
options
- if null, clears current optionsIllegalStateException
- if LeaseSet2 is already signedpublic boolean isOffline()
public SigningPublicKey getTransientSigningKey()
public long getTransientExpiration()
public boolean setOfflineSignature(long expires, SigningPublicKey transientSPK, Signature offlineSig)
expires
- absolute mstransientSPK
- the key that will sign the leasesetofflineSig
- the signature by the spk in the destinationIllegalStateException
- if already signedpublic static Signature offlineSign(long expires, SigningPublicKey transientSPK, SigningPrivateKey priv)
expires
- absolute mstransientSPK
- the key that will sign the leasesetpriv
- the private signing key for the destinationpublic boolean verifyOfflineSignature()
protected boolean verifyOfflineSignature(SigningPublicKey spk)
public void setBlindedHash(Hash bh)
public Hash getBlindedHash()
public int getType()
DatabaseEntry
public void setSigningKey(SigningPublicKey key)
setSigningKey
in class LeaseSet
public boolean isCurrent(long fudge)
protected byte[] getBytes()
public void readBytes(InputStream in) throws DataFormatException, IOException
readBytes
in interface DataStructure
readBytes
in class LeaseSet
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 writeBytes(OutputStream out) throws DataFormatException, IOException
writeBytes
in interface DataStructure
writeBytes
in class LeaseSet
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 streamprotected void writeBytesWithoutSig(OutputStream out) throws DataFormatException, IOException
DataFormatException
IOException
protected void writeBody(OutputStream out) throws DataFormatException, IOException
DataFormatException
IOException
protected void readHeader(InputStream in) throws DataFormatException, IOException
DataFormatException
IOException
protected void writeHeader(OutputStream out) throws DataFormatException, IOException
DataFormatException
IOException
protected void readOfflineBytes(InputStream in) throws DataFormatException, IOException
DataFormatException
IOException
protected void writeOfflineBytes(OutputStream out) throws DataFormatException, IOException
DataFormatException
IOException
public void addLease(Lease lease)
addLease
in class LeaseSet
lease
- must be a Lease2IllegalArgumentException
- if not a Lease2public void sign(SigningPrivateKey key) throws DataFormatException
sign
in class DatabaseEntry
IllegalStateException
- if already signedDataFormatException
public boolean verifySignature()
verifySignature
in class LeaseSet
public int hashCode()
public void encrypt(SessionKey key)
LeaseSet