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 StringACTION_ADDDESTstatic StringACTION_ADDNAMEstatic StringACTION_ADDSUBDOMAINstatic StringACTION_CHANGEDESTstatic StringACTION_CHANGENAMEstatic StringACTION_REMOVEstatic StringACTION_REMOVEALLstatic StringACTION_UPDATEstatic charKV_SEPARATORstatic StringPROP_ACTIONstatic StringPROP_DATEstatic StringPROP_DESTstatic StringPROP_EXPIRESstatic StringPROP_NAMEstatic StringPROP_OLDDESTstatic StringPROP_OLDNAMEstatic StringPROP_OLDSIGstatic charPROP_SEPARATORstatic StringPROP_SIGstatic StringPROPS_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 booleanequals(Object o)Compares Destination only, not propertiesStringgetDest()StringgetName()OrderedPropertiesgetProps()inthashCode()booleanhasValidInnerSig()Verify with the "olddest" property's public key using the "oldsig" propertybooleanhasValidRemoveSig()Verify with the "dest" property's public key using the "sig" propertybooleanhasValidSig()Verify with the dest public key using the "sig" propertyvoidsign(SigningPrivateKey spk)Sign and set the "sig" property Must have been constructed with non-null properties.voidsignInner(SigningPrivateKey spk)Sign and set the "oldsig" property Must have been constructed with non-null properties.voidsignRemove(SigningPrivateKey spk)Sign as a "remove" line #!dest=dest#name=name#k1=v1#sig=sig...] Must have been constructed with non-null properties.voidwrite(BufferedWriter out)Write as a standard line name=dest[#!k1=v1#k2=v2...] Includes newline.voidwrite(Writer out)Write as a standard line name=dest[#!k1=v1#k2=v2...] Does not include newline.voidwriteProps(Writer out)Write the props part (if any) only, without newlinevoidwriteRemove(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.voidwriteRemoveLine(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.
-