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
All Methods Instance Methods Concrete Methods 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 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.
-
-