java.lang.Object
i2p.susi.dns.AddressBean

public class AddressBeanextends Object
Bean representing an I2P address entry with hostname and destination. Provides methods for handling I2P addresses and their properties.
  • Field Details

    • name

      private final String name
      The name being resolved.
    • dest

      private final byte[] dest
      The destination bytes, if the name has one.
    • props

      private Properties props
      Properties stored with the destination, if any.
    • haveIDN

      static final boolean haveIDN
      Available as of Java 6.
    • DOT

      private static final char DOT
      ASCII dot separating name labels.
      See Also:
    • DOT2

      private static final char DOT2
      Ideographic dot treated as a label separator too.
      See Also:
    • DOT3

      private static final char DOT3
      Fullwidth dot treated as a label separator too.
      See Also:
    • DOT4

      private static final char DOT4
      Halfwidth ideographic dot treated as a label separator too.
      See Also:
  • Constructor Details

    • AddressBean

      public AddressBean(String name, String destination)
      Constructs an AddressBean with hostname and base64 encoded destination.
      Parameters:
      name - the ASCII (Punycode) hostname
      destination - the base64 encoded destination
    • AddressBean

      public AddressBean(String name, Destination destination)
      Constructs an AddressBean with hostname and destination object.
      Parameters:
      name - the ASCII (Punycode) hostname
      destination - the Destination being published
    • AddressBean

      public AddressBean(String name, byte[] destination)
      Constructs an AddressBean with hostname and destination as byte array.
      Parameters:
      name - the ASCII (Punycode) hostname
      destination - the 387-byte destination being published
  • Method Details

    • getDestination

      public String getDestination()
      Gets the destination as base64 encoded string.
      Returns:
      the base64 encoded destination
    • getName

      public String getName()
      The ASCII (Punycode) name.
      Returns:
      the name exactly as supplied, not Punycode-decoded
    • getDisplayName

      public String getDisplayName()
      The Unicode name, translated from Punycode.
      Returns:
      the original string on error
    • toUnicode

      public static String toUnicode(String host)
      The Unicode name, translated from Punycode.
      Parameters:
      host - the hostname to convert
      Returns:
      the original string on error
    • isIDN

      public boolean isIDN()
      Is the ASCII name Punycode-encoded?
      Returns:
      true if the name is Punycode-encoded
    • toASCII

      static String toASCII(String host) throws IllegalArgumentException
      Ref: java.net.IDN and RFC 3490.
      Parameters:
      host - will be converted to lower case
      Returns:
      name converted to lower case and punycoded if necessary
      Throws:
      IllegalArgumentException - on various errors or if IDN is needed but not available
    • getB32

      public String getB32()
      Gets the base32 hash address for this destination.
      Returns:
      the base32 hash address
    • getB64

      public String getB64()
      Gets the base64 hash of the destination.
      Returns:
      the base64 hash
    • setProperties

      public void setProperties(Properties p)
      Sets the properties for this address entry.
      Parameters:
      p - the properties to set
    • getSource

      public String getSource()
      Gets the source URL or name for this address entry.
      Returns:
      the source URL or name
    • getSourceHostname

      public String getSourceHostname()
      Gets the source URL with hostname as display text for this address entry.
      Returns:
      the source URL with hostname as display text
    • getAdded

      public String getAdded()
      Gets the date when this address was added.
      Returns:
      the date when added
    • getModded

      public String getModded()
      Gets the date when this address was last modified.
      Returns:
      the date when modified
    • isValidated

      public boolean isValidated()
      Checks if this address has been validated.
      Returns:
      true if validated
    • getNotes

      public String getNotes()
      Gets the notes for this address entry, HTML escaped.
      Returns:
      the notes, HTML escaped
    • getCert

      public String getCert()
      Do this the easy way.
      Returns:
      the certificate type as a string
    • getSigType

      public String getSigType()
      Do this the easy way.
      Returns:
      the signature type as a string
    • getEncType

      public String getEncType()
      Do this the easy way.
      Returns:
      the encryption type as a string
    • getProp

      String getProp(String p)
      Gets a property value for this address entry.
      Parameters:
      p - the property key
      Returns:
      non-null, "" if not found
    • getDate

      private String getDate(String key)
      Parse a date property from the bean map.
      Parameters:
      key - the property key
      Returns:
      the formatted date
    • _t

      private static String _t(String s)
      Translate a string.
      Parameters:
      s - the string to translate
      Returns:
      the translated string
    • _t

      private static String _t(String s, Object o)
      Translate a string with one parameter.
      Parameters:
      s - the string to translate
      o - the value substituted for the {0} placeholder in s
      Returns:
      the translated string
    • _t

      private static String _t(String s, Object o, Object o2)
      Translate a string with two parameters.
      Parameters:
      s - the string to translate
      o - the first parameter
      o2 - the second parameter
      Returns:
      the translated string