public class HostTxtEntry extends Object
| Modifier and Type | Field and Description |
|---|---|
static String | ACTION_ADDDESTAction value: add a new destination |
static String | ACTION_ADDNAMEAction value: add a new hostname |
static String | ACTION_ADDSUBDOMAINAction value: add a subdomain entry |
static String | ACTION_CHANGEDESTAction value: change an existing destination |
static String | ACTION_CHANGENAMEAction value: change an existing hostname |
static String | ACTION_REMOVEAction value: remove an entry |
static String | ACTION_REMOVEALLAction value: remove all entries |
static String | ACTION_UPDATEAction value: update an existing entry |
static char | KV_SEPARATORSeparator between name and destination in the hosts.txt line |
static String | PROP_ACTIONProperty key for the action type (e.g. |
static String | PROP_DATEProperty key for the date timestamp (seconds since epoch) |
static String | PROP_DESTProperty key for the destination Base64 string |
static String | PROP_EXPIRESProperty key for the expiry time |
static String | PROP_NAMEProperty key for the hostname |
static String | PROP_OLDDESTProperty key for the old destination (used in change operations) |
static String | PROP_OLDNAMEProperty key for the old hostname (used in rename operations) |
static String | PROP_OLDSIGProperty key for the old signature for inner verification |
static char | PROP_SEPARATORSeparator between individual properties |
static String | PROP_SIGProperty key for the signature |
static String | PROPS_SEPARATORSeparator between the destination part and the properties part |
| Constructor and Description |
|---|
HostTxtEntry(String sprops)A 'remove' entry. |
HostTxtEntry(String name,
String dest)Create a new host text entry with name and destination, no properties. |
HostTxtEntry(String name,
String dest,
OrderedProperties props)Create a new host text entry with optional properties. |
HostTxtEntry(String name,
String dest,
String sprops)Create a new host text entry with name, destination, and serialized properties. |
| Modifier and Type | Method and Description |
|---|---|
boolean | equals(Object o)Compares Destination only, not properties |
String | getDest()Return the Base64 destination. |
String | getName()Return the hostname. |
OrderedProperties | getProps()Return the properties, or null. |
int | hashCode() |
boolean | hasValidInnerSig()Verify with the "olddest" property's public key using the "oldsig" property |
boolean | hasValidRemoveSig()Verify with the "dest" property's public key using the "sig" property |
boolean | hasValidSig()Verify with the dest public key using the "sig" property |
void | 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 newline. |
void | 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. |
public static final String ACTION_ADDDEST
public static final String ACTION_ADDNAME
public static final String ACTION_ADDSUBDOMAIN
public static final String ACTION_CHANGEDEST
public static final String ACTION_CHANGENAME
public static final String ACTION_REMOVE
public static final String ACTION_REMOVEALL
public static final String ACTION_UPDATE
public static final char KV_SEPARATOR
public static final String PROP_ACTION
public static final String PROP_DATE
public static final String PROP_DEST
public static final String PROP_EXPIRES
public static final String PROP_NAME
public static final String PROP_OLDDEST
public static final String PROP_OLDNAME
public static final String PROP_OLDSIG
public static final char PROP_SEPARATOR
public static final String PROP_SIG
public static final String PROPS_SEPARATOR
public HostTxtEntry(String sprops) throws IllegalArgumentException
sprops - line part after the #!, non-nullIllegalArgumentException - on dup key in sprops and other errorspublic HostTxtEntry(String name, String dest)
name - the hostnamedest - the Base64 destinationpublic HostTxtEntry(String name, String dest, OrderedProperties props)
name - the hostnamedest - the Base64 destinationprops - may be nullpublic HostTxtEntry(String name, String dest, String sprops) throws IllegalArgumentException
name - the hostnamedest - the Base64 destinationsprops - line part after the #!, non-nullIllegalArgumentException - on dup key in sprops and other errorspublic boolean equals(Object o)
public String getDest()
public String getName()
public OrderedProperties getProps()
public boolean hasValidInnerSig()
public boolean hasValidRemoveSig()
public boolean hasValidSig()
public void sign(SigningPrivateKey spk)
public void signInner(SigningPrivateKey spk)
public void signRemove(SigningPrivateKey spk)
public void write(BufferedWriter out) throws IOException
out - the writer to write toIOException - if writing failspublic void write(Writer out) throws IOException
out - the writer to write toIOException - if writing failspublic void writeProps(Writer out) throws IOException
out - the writer to write toIOException - if writing failspublic void writeRemove(Writer out) throws IOException
out - the writer to write toIOException - if writing failspublic void writeRemoveLine(BufferedWriter out) throws IOException
out - the writer to write toIOException - if writing fails