Package net.i2p.client.naming
Class HostTxtEntry
java.lang.Object
net.i2p.client.naming.HostTxtEntry
public class HostTxtEntry extends Object
A hostname, b64 destination, and optional properties.
Includes methods to sign and verify the entry.
Used by addressbook to parse subscription data,
and by i2ptunnel to generate signed metadata.
- Since:
- 0.9.26
-
Field Summary
Fields Modifier and Type Field Description static String
ACTION_ADDDEST
static String
ACTION_ADDNAME
static String
ACTION_ADDSUBDOMAIN
static String
ACTION_CHANGEDEST
static String
ACTION_CHANGENAME
static String
ACTION_REMOVE
static String
ACTION_REMOVEALL
static String
ACTION_UPDATE
static char
KV_SEPARATOR
static String
PROP_ACTION
static String
PROP_DATE
static String
PROP_DEST
static String
PROP_EXPIRES
static String
PROP_NAME
static String
PROP_OLDDEST
static String
PROP_OLDNAME
static String
PROP_OLDSIG
static char
PROP_SEPARATOR
static String
PROP_SIG
static String
PROPS_SEPARATOR
-
Constructor Summary
Constructors Constructor Description HostTxtEntry(String sprops)
A 'remove' entry.HostTxtEntry(String name, String dest)
Properties will be nullHostTxtEntry(String name, String dest, String sprops)
HostTxtEntry(String name, String dest, OrderedProperties props)
-
Method Summary
Modifier and Type Method Description boolean
equals(Object o)
Compares Destination only, not propertiesString
getDest()
String
getName()
OrderedProperties
getProps()
int
hashCode()
boolean
hasValidInnerSig()
Verify with the "olddest" property's public key using the "oldsig" propertyboolean
hasValidRemoveSig()
Verify with the "dest" property's public key using the "sig" propertyboolean
hasValidSig()
Verify with the dest public key using the "sig" propertyvoid
sign(SigningPrivateKey spk)
Sign and set the "sig" property Must have been constructed with non-null properties.void
signInner(SigningPrivateKey spk)
Sign and set the "oldsig" property Must have been constructed with non-null properties.void
signRemove(SigningPrivateKey spk)
Sign as a "remove" line #!dest=dest#name=name#k1=v1#sig=sig...] Must have been constructed with non-null properties.void
write(BufferedWriter out)
Write as a standard line name=dest[#!k1=v1#k2=v2...] Includes newline.void
write(Writer out)
Write as a standard line name=dest[#!k1=v1#k2=v2...] Does not include newline.void
writeProps(Writer out)
Write the props part (if any) only, without newlinevoid
writeRemove(Writer out)
Write as a "remove" line #!dest=dest#name=name#k1=v1#sig=sig...] This works whether constructed with name and dest, or just properties.void
writeRemoveLine(BufferedWriter out)
Write as a "remove" line #!dest=dest#name=name#k1=v1#sig=sig...] This works whether constructed with name and dest, or just properties.
-
Field Details
-
KV_SEPARATOR
public static final char KV_SEPARATOR- See Also:
- Constant Field Values
-
PROPS_SEPARATOR
- See Also:
- Constant Field Values
-
PROP_SEPARATOR
public static final char PROP_SEPARATOR- See Also:
- Constant Field Values
-
PROP_ACTION
- See Also:
- Constant Field Values
-
PROP_DATE
- See Also:
- Constant Field Values
-
PROP_DEST
- See Also:
- Constant Field Values
-
PROP_EXPIRES
- See Also:
- Constant Field Values
-
PROP_NAME
- See Also:
- Constant Field Values
-
PROP_OLDDEST
- See Also:
- Constant Field Values
-
PROP_OLDNAME
- See Also:
- Constant Field Values
-
PROP_OLDSIG
- See Also:
- Constant Field Values
-
PROP_SIG
- See Also:
- Constant Field Values
-
ACTION_ADDDEST
- See Also:
- Constant Field Values
-
ACTION_ADDNAME
- See Also:
- Constant Field Values
-
ACTION_ADDSUBDOMAIN
- See Also:
- Constant Field Values
-
ACTION_CHANGEDEST
- See Also:
- Constant Field Values
-
ACTION_CHANGENAME
- See Also:
- Constant Field Values
-
ACTION_REMOVE
- See Also:
- Constant Field Values
-
ACTION_REMOVEALL
- See Also:
- Constant Field Values
-
ACTION_UPDATE
- See Also:
- Constant Field Values
-
-
Constructor Details
-
HostTxtEntry
Properties will be null -
HostTxtEntry
- Parameters:
sprops
- line part after the #!, non-null- Throws:
IllegalArgumentException
- on dup key in sprops and other errors
-
HostTxtEntry
A 'remove' entry. Name and Dest will be null.- Parameters:
sprops
- line part after the #!, non-null- Throws:
IllegalArgumentException
- on dup key in sprops and other errors
-
HostTxtEntry
- Parameters:
props
- may be null
-
-
Method Details
-
getName
-
getDest
-
getProps
-
write
Write as a standard line name=dest[#!k1=v1#k2=v2...] Includes newline.- Throws:
IOException
-
write
Write as a standard line name=dest[#!k1=v1#k2=v2...] Does not include newline.- Throws:
IOException
-
writeRemoveLine
Write as a "remove" line #!dest=dest#name=name#k1=v1#sig=sig...] This works whether constructed with name and dest, or just properties. Includes newline. Must have been constructed with non-null properties.- Throws:
IOException
-
writeRemove
Write as a "remove" line #!dest=dest#name=name#k1=v1#sig=sig...] This works whether constructed with name and dest, or just properties. Does not include newline. Must have been constructed with non-null properties.- Throws:
IOException
-
writeProps
Write the props part (if any) only, without newline- Throws:
IOException
-
hasValidSig
public boolean hasValidSig()Verify with the dest public key using the "sig" property -
hasValidInnerSig
public boolean hasValidInnerSig()Verify with the "olddest" property's public key using the "oldsig" property -
hasValidRemoveSig
public boolean hasValidRemoveSig()Verify with the "dest" property's public key using the "sig" property -
hashCode
public int hashCode() -
equals
Compares Destination only, not properties -
sign
Sign and set the "sig" property Must have been constructed with non-null properties. -
signInner
Sign and set the "oldsig" property Must have been constructed with non-null properties. -
signRemove
Sign as a "remove" line #!dest=dest#name=name#k1=v1#sig=sig...] Must have been constructed with non-null properties.
-