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
All Methods Instance Methods Concrete Methods 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 Detail
-
KV_SEPARATOR
public static final char KV_SEPARATOR
- See Also:
- Constant Field Values
-
PROPS_SEPARATOR
public static final String PROPS_SEPARATOR
- See Also:
- Constant Field Values
-
PROP_SEPARATOR
public static final char PROP_SEPARATOR
- See Also:
- Constant Field Values
-
PROP_ACTION
public static final String PROP_ACTION
- See Also:
- Constant Field Values
-
PROP_DATE
public static final String PROP_DATE
- See Also:
- Constant Field Values
-
PROP_DEST
public static final String PROP_DEST
- See Also:
- Constant Field Values
-
PROP_EXPIRES
public static final String PROP_EXPIRES
- See Also:
- Constant Field Values
-
PROP_NAME
public static final String PROP_NAME
- See Also:
- Constant Field Values
-
PROP_OLDDEST
public static final String PROP_OLDDEST
- See Also:
- Constant Field Values
-
PROP_OLDNAME
public static final String PROP_OLDNAME
- See Also:
- Constant Field Values
-
PROP_OLDSIG
public static final String PROP_OLDSIG
- See Also:
- Constant Field Values
-
PROP_SIG
public static final String PROP_SIG
- See Also:
- Constant Field Values
-
ACTION_ADDDEST
public static final String ACTION_ADDDEST
- See Also:
- Constant Field Values
-
ACTION_ADDNAME
public static final String ACTION_ADDNAME
- See Also:
- Constant Field Values
-
ACTION_ADDSUBDOMAIN
public static final String ACTION_ADDSUBDOMAIN
- See Also:
- Constant Field Values
-
ACTION_CHANGEDEST
public static final String ACTION_CHANGEDEST
- See Also:
- Constant Field Values
-
ACTION_CHANGENAME
public static final String ACTION_CHANGENAME
- See Also:
- Constant Field Values
-
ACTION_REMOVE
public static final String ACTION_REMOVE
- See Also:
- Constant Field Values
-
ACTION_REMOVEALL
public static final String ACTION_REMOVEALL
- See Also:
- Constant Field Values
-
ACTION_UPDATE
public static final String ACTION_UPDATE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HostTxtEntry
public HostTxtEntry(String name, String dest, String sprops) throws IllegalArgumentException
- Parameters:
sprops
- line part after the #!, non-null- Throws:
IllegalArgumentException
- on dup key in sprops and other errors
-
HostTxtEntry
public HostTxtEntry(String sprops) throws IllegalArgumentException
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
public HostTxtEntry(String name, String dest, OrderedProperties props)
- Parameters:
props
- may be null
-
-
Method Detail
-
getName
public String getName()
-
getDest
public String getDest()
-
getProps
public OrderedProperties getProps()
-
write
public void write(BufferedWriter out) throws IOException
Write as a standard line name=dest[#!k1=v1#k2=v2...] Includes newline.- Throws:
IOException
-
write
public void write(Writer out) throws IOException
Write as a standard line name=dest[#!k1=v1#k2=v2...] Does not include newline.- Throws:
IOException
-
writeRemoveLine
public void writeRemoveLine(BufferedWriter out) throws IOException
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
public void writeRemove(Writer out) throws IOException
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
public void writeProps(Writer out) throws IOException
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
-
equals
public boolean equals(Object o)
Compares Destination only, not properties
-
sign
public void sign(SigningPrivateKey spk)
Sign and set the "sig" property Must have been constructed with non-null properties.
-
signInner
public void signInner(SigningPrivateKey spk)
Sign and set the "oldsig" property Must have been constructed with non-null properties.
-
signRemove
public 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.
-
-