com.jscape.inet.ipclientssl

## Class IpClientSsl

- java.lang.Object
- - com.jscape.inet.ipclient.IpClient
  - - com.jscape.inet.ipclientssl.IpClientSsl

- All Implemented Interfaces:
    java.lang.AutoCloseable

      public class IpClientSsl
      extends IpClient

  Implements basic functionality of a secure TLS/SSL TCP/IP client connection.

  Example usage:

       try {
         // create new IpClientSsl instance with hostname, port and timeout arguments
         IpClientSsl client = new IpClientSsl("10.0.0.1",993,5000);

         // establish connection with server
         client.connect();

         // obtain OutputStream for sending data to server
         OutputStream out = client.getOutputStream();

         // obtain InputStream for reading data from server
         InputStream in = client.getInputStream();

         // disconnect from server
         client.disconnect();

       } catch(IpClientException ipe) {
         ipe.printStackTrace();
       }

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `IpClientSsl(java.lang.String hostname, int port)` Creates a new IpClientSsl instance.
    `IpClientSsl(java.lang.String hostname, int port, int timeout)` Creates a new IpClientSsl instance.
    `IpClientSsl(java.lang.String hostname, int port, int timeout, javax.net.ssl.SSLContext context)` Creates a new IpClientSsl instance.
    `IpClientSsl(java.lang.String hostname, int port, javax.net.ssl.SSLContext context)` Creates a new IpClientSsl instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearProxySettings()` Clears proxy server values.
    `IpClientSsl` | `connect()` Establishes connection with server.
    `void` | `disconnect()` Closes connection with server.
    `void` | `setClientCertificates(java.lang.String filename, java.lang.String password)` Sets optional client certificate to be used during authentication.
    `void` | `setClientCertificates(java.lang.String filename, java.lang.String password, java.lang.String storetype)` Sets optional client certificate to be used during authentication.
    `void` | `setProxyAuthentication(java.lang.String proxyUsername, java.lang.String proxyPassword)` Sets the username and password to use when for authentication with proxy server.
    `void` | `setProxyHost(java.lang.String proxyHostname, int proxyPort)` Sets the proxy hostname and port for this connection.
    `void` | `setProxyType(java.lang.String proxyType)` Sets the proxy type will be used for this connection.
    `void` | `setServerCertificates(java.lang.String filename, java.lang.String password)` Sets optional server certificate to be used during authentication.
    `void` | `setServerCertificates(java.lang.String filename, java.lang.String password, java.lang.String storetype)` Sets optional server certificate to be used during authentication.

    - ### Methods inherited from class com.jscape.inet.ipclient.IpClient

      `addIpClientListener, close, getConnectTimeout, getInputStream, getOutputStream, getReadTimeout, getSocket, removeIpClientListener, setConnectTimeout, setInputStream, setOutputStream, setReadTimeout, setSocket`

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

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

- - ### Constructor Detail

    - #### IpClientSsl

          public IpClientSsl(java.lang.String hostname,
                             int port)

      Creates a new IpClientSsl instance.
      Parameters:
        `hostname` - the server hostname or IP address
        `port` - the server port

    - #### IpClientSsl

          public IpClientSsl(java.lang.String hostname,
                             int port,
                             javax.net.ssl.SSLContext context)

      Creates a new IpClientSsl instance.
      Parameters:
        `hostname` - the server hostname or IP address
        `port` - the server port
        `context` - an SSLContext

    - #### IpClientSsl

          public IpClientSsl(java.lang.String hostname,
                             int port,
                             int timeout)

      Creates a new IpClientSsl instance.
      Parameters:
        `hostname` - the server hostname or IP address
        `port` - the server port
        `timeout` - the timeout for establishing a connection specified in ms (milliseconds)

    - #### IpClientSsl

          public IpClientSsl(java.lang.String hostname,
                             int port,
                             int timeout,
                             javax.net.ssl.SSLContext context)

      Creates a new IpClientSsl instance.
      Parameters:
        `hostname` - the server hostname or IP address
        `port` - the server port
        `timeout` - the timeout for establishing a connection specified in ms (milliseconds)
        `context` - an SSLContext
      See Also:
        `SSLContext`

  - ### Method Detail

    - #### setClientCertificates

          public void setClientCertificates(java.lang.String filename,
                                            java.lang.String password)

      Sets optional client certificate to be used during authentication. Default expected keystore format is JKS format. Existing certificate may be imported into keystore using the `keytool` utility provided in the Sun JDK.

      Example:

           keytool.exe -import -file x509.cer -keystore your_store_name

      The example above imports the certificate x509.cer into a keystore named your_store_name

      Parameters:
        `filename` - the keystore file containing the client certificate
        `password` - the keystore password

    - #### setClientCertificates

          public void setClientCertificates(java.lang.String filename,
                                            java.lang.String password,
                                            java.lang.String storetype)

      Sets optional client certificate to be used during authentication. Default expected keystore format is JKS format. Existing certificate may be imported into keystore using the `keytool` utility provided in the Sun JDK.

      Example:

           keytool.exe -import -file x509.cer -keystore your_store_name

      The example above imports the certificate x509.cer into a keystore named your_store_name

      Parameters:
        `filename` - the keystore file containing the client certificate
        `password` - the keystore password
        `storetype` - the keystore type valid values include jks and pkcs12

    - #### setServerCertificates

          public void setServerCertificates(java.lang.String filename,
                                            java.lang.String password)

      Sets optional server certificate to be used during authentication. Default expected keystore format is JKS format. Existing certificate may be imported into keystore using the `keytool` utility provided in the Sun JDK.

      Example:

           keytool.exe -import -file x509.cer -keystore your_store_name

      The example above imports the certificate x509.cer into a keystore named your_store_name

      Parameters:
        `filename` - the keystore file containing the server certificate
        `password` - the keystore password

    - #### setServerCertificates

          public void setServerCertificates(java.lang.String filename,
                                            java.lang.String password,
                                            java.lang.String storetype)

      Sets optional server certificate to be used during authentication. Default expected keystore format is JKS format. Existing certificate may be imported into keystore using the `keytool` utility provided in the Sun JDK.

      Example:

           keytool.exe -import -file x509.cer -keystore your_store_name

      The example above imports the certificate x509.cer into a keystore named your_store_name

      Parameters:
        `filename` - the keystore file containing the server certificate
        `password` - the keystore password
        `storetype` - the keystore type valid values include jks and pkcs12

    - #### setProxyAuthentication

          public void setProxyAuthentication(java.lang.String proxyUsername,
                                             java.lang.String proxyPassword)

      Sets the username and password to use when for authentication with proxy server. To clear these settings invoke the `#clearProxySettings` method.
      Overrides:
        `setProxyAuthentication` in class `IpClient`
      Parameters:
        `proxyUsername` - the proxy username
        `proxyPassword` - the proxy password
      See Also:
        `clearProxySettings()`

    - #### setProxyHost

          public void setProxyHost(java.lang.String proxyHostname,
                                   int proxyPort)

      Sets the proxy hostname and port for this connection. To clear these settings invoke the `#clearProxySettings` method.
      Overrides:
        `setProxyHost` in class `IpClient`
      Parameters:
        `proxyHostname` - the hostname or ip address of the proxy server
        `proxyPort` - the port of the proxy server
      See Also:
        `clearProxySettings()`

    - #### setProxyType

          public void setProxyType(java.lang.String proxyType)

      Sets the proxy type will be used for this connection.
      Overrides:
        `setProxyType` in class `IpClient`
      Parameters:
        `proxyType` - The proxy type. Valid values: HTTP, SOCKS5

    - #### clearProxySettings

          public void clearProxySettings()

      Clears proxy server values.
      Overrides:
        `clearProxySettings` in class `IpClient`

    - #### connect

          public IpClientSsl connect()
                              throws IpClientException

      Establishes connection with server.
      Overrides:
        `connect` in class `IpClient`
      Throws:
        `IpClientException` - if an I/O or network related error occurs

    - #### disconnect

          public void disconnect()
                          throws IpClientException

      Closes connection with server.
      Overrides:
        `disconnect` in class `IpClient`
      Throws:
        `IpClientException` - if an I/O or network related error occurs

Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved