net.i2p.sam

## Class SAMUtils

- java.lang.Object
- - net.i2p.sam.SAMUtils

-     public class SAMUtils
      extends Object

  Miscellaneous utility methods used by SAM protocol handlers.
  Author:
    human

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SAMUtils.InvalidDestination`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SAMUtils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `checkDestination(String dest)` Check whether a base64-encoded dest is valid
    `static void` | `checkPrivateDestination(String dest)`
    `static void` | `genRandomKey(OutputStream priv, OutputStream pub)` Generate a random destination key
    `static Destination` | `getDest(String s)` Resolve the destination from a key or a hostname
    `static Destination` | `lookupHost(String name, OutputStream pubKey)` Resolved the specified hostname.
    `static void` | `main(String[] args)`
    `static Properties` | `parseParams(StringTokenizer tok)` Parse SAM parameters, and put them into a Propetries object

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SAMUtils

          public SAMUtils()

  - ### Method Detail

    - #### genRandomKey

          public static void genRandomKey(OutputStream priv,
                          OutputStream pub)

      Generate a random destination key
      Parameters:
        `priv` - Stream used to write the private key
        `pub` - Stream used to write the public key (may be null)

    - #### checkDestination

          public static boolean checkDestination(String dest)

      Check whether a base64-encoded dest is valid
      Parameters:
        `dest` - The base64-encoded destination to be checked
      Returns:
        True if the destination is valid, false otherwise

    - #### checkPrivateDestination

          public static void checkPrivateDestination(String dest)
                                              throws SAMUtils.InvalidDestination

      Throws:
        `SAMUtils.InvalidDestination`

    - #### lookupHost

          public static Destination lookupHost(String name,
                               OutputStream pubKey)

      Resolved the specified hostname.
      Parameters:
        `name` - Hostname to be resolved
        `pubKey` - A stream to write the Destination public key (may be null)
      Returns:
        the Destination for the specified hostname, or null if not found

    - #### getDest

          public static Destination getDest(String s)
                                     throws DataFormatException

      Resolve the destination from a key or a hostname
      Parameters:
        `s` - Hostname or key to be resolved
      Returns:
        the Destination for the specified hostname, or null if not found
      Throws:
        `DataFormatException`

    - #### parseParams

          public static Properties parseParams(StringTokenizer tok)
                                        throws SAMException

      Parse SAM parameters, and put them into a Propetries object
      Parameters:
        `tok` - A StringTokenizer pointing to the SAM parameters
      Returns:
        Properties with the parsed SAM params
      Throws:
        `SAMException` - if the data was formatted incorrectly

    - #### main

          public static void main(String[] args)