public class LeaseSet2 extends LeaseSet
LeaseSet2 provides several enhancements over the original LeaseSet format:
Key differences from LeaseSet:
getPublished() for version comparison instead of lease datesgetEncryptionKeys()setOfflineSignature(long, SigningPublicKey, Signature)| 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, _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)
Adds a lease to this leaseset.
|
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) |
Properties |
getOptions()
Gets the leaseset options.
|
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()
Gets the transient public key for offline signing.
|
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()
Checks if this leaseset uses offline keys.
|
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 |
setPublished(long now)
Set published timestamp.
|
void |
setSigningKey(SigningPublicKey key)
The revocation key.
|
void |
setUnpublished()
Marks this leaseset as unpublished.
|
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, getSigningKey, setDestination, setEncryptionKey, setReceivedBygetHash, getReceivedAsReply, getReceivedBy, getRoutingKey, getSignature, getSigningPublicKey, isLeaseSet, isLeaseSet, isRouterInfo, setReceivedAsPublished, setReceivedAsReply, setSignature, validateRoutingKeycalculateHash, fromBase64, fromByteArray, read, toBase64, toByteArrayprotected long _expires
protected int _flags
protected Signature _offlineSignature
protected Properties _options
protected long _published
protected long _transientExpires
protected SigningPublicKey _transientSigningPublicKey
public void addEncryptionKey(PublicKey key)
public void addLease(Lease lease)
LeaseSetaddLease in class LeaseSetlease - must be a Lease2IllegalArgumentException - if not a Lease2public void encrypt(SessionKey key)
LeaseSetpublic Hash getBlindedHash()
protected byte[] getBytes()
public PublicKey getEncryptionKey()
getEncryptionKey in class LeaseSetpublic PublicKey getEncryptionKey(Set<EncType> supported)
getEncryptionKey in class LeaseSetsupported - what return types are allowedpublic List<PublicKey> getEncryptionKeys()
public long getExpires()
public Properties getOptions()
public long getPublished()
public boolean getReceivedAsPublished()
getReceivedAsPublished in class DatabaseEntrypublic long getTransientExpiration()
public SigningPublicKey getTransientSigningKey()
public int getType()
DatabaseEntrypublic int hashCode()
public boolean isBlindedWhenPublished()
public boolean isCurrent(long fudge)
public boolean isOffline()
public boolean isUnpublished()
public 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 void readBytes(InputStream in) throws DataFormatException, IOException
readBytes in interface DataStructurereadBytes in class LeaseSetin - 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 streamprotected void readHeader(InputStream in) throws DataFormatException, IOException
DataFormatExceptionIOExceptionprotected void readOfflineBytes(InputStream in) throws DataFormatException, IOException
DataFormatExceptionIOExceptionpublic void setBlindedHash(Hash bh)
public void setBlindedWhenPublished()
IllegalStateException - if already signedpublic 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 void setOptions(Properties options)
options - if null, clears current optionsIllegalStateException - if LeaseSet2 is already signedpublic void setPublished(long now)
public void setSigningKey(SigningPublicKey key)
setSigningKey in class LeaseSetpublic void setUnpublished()
IllegalStateException - if already signedpublic void sign(SigningPrivateKey key) throws DataFormatException
sign in class DatabaseEntryIllegalStateException - if already signedDataFormatExceptionpublic boolean verifyOfflineSignature()
protected boolean verifyOfflineSignature(SigningPublicKey spk)
public boolean verifySignature()
verifySignature in class LeaseSetprotected void writeBody(OutputStream out) throws DataFormatException, IOException
DataFormatExceptionIOExceptionpublic void writeBytes(OutputStream out) throws DataFormatException, IOException
writeBytes in interface DataStructurewriteBytes in class LeaseSetout - 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
DataFormatExceptionIOExceptionprotected void writeHeader(OutputStream out) throws DataFormatException, IOException
DataFormatExceptionIOExceptionprotected void writeOfflineBytes(OutputStream out) throws DataFormatException, IOException
DataFormatExceptionIOException