Class SocketCommProps

  • All Implemented Interfaces:
    EventListener, IGProp<GProp<?>[]>, IPropCnr, java.lang.Cloneable
    Direct Known Subclasses:
    TelnetCommProps, WebSocketCommProps

    public class SocketCommProps
    extends PropCnr
    This property container contains all properties required for a Socket (NIO) connection using Proxy, WebSocket, SSL, etc, required by the SocketProp property.
    Author:
    Christopher Mindus
    • Constructor Detail

      • SocketCommProps

        public SocketCommProps()
        Creates the socket property container without a name. The name must be set in all cases using the setPropertyAtom call.
      • SocketCommProps

        public SocketCommProps​(Atom propertyAtom)
        Creates the socket property container with the specified name. All system-reserved names for components begins with "$".
        Parameters:
        propertyAtom - the name of the component, unique within it's parent.
    • Method Detail

      • clone

        public SocketCommProps clone()
        Clone method overridden in order not to clone the proxy password.
        Overrides:
        clone in class PropCnr
      • setVerbose

        public void setVerbose​(boolean on)
        Sets verbose mode.
        Parameters:
        on - true for verbose mode, false for silent.
      • isVerbose

        public boolean isVerbose()
        Checks for verbose output.
        Returns:
        true for verbose output, false for silent.
      • getHost

        public java.lang.String getHost()
        Gets the destination host name or IP address for the socket destination.
        Returns:
        null if none is set.
      • getPort

        public int getPort()
        Gets the host port for the socket.
        Returns:
        0 if none if set.
      • getBindAddress

        public java.lang.String getBindAddress()
        Gets the bind address for the port, i.e. the local host name or IP address.
        Returns:
        null if none is set or not required.
      • isSecure

        public boolean isSecure()
        Gets the secure socket flag.
        Returns:
        true if SSL-secured, false if not.
      • setSecure

        public void setSecure​(boolean on)
        Sets the secure socket flag.
      • getProxyHost

        public java.lang.String getProxyHost()
        Gets the proxy host name if any.
        Returns:
        null for no proxy, otherwise a host name or IP address.
      • getProxyPort

        public int getProxyPort()
        Gets the proxy port if any.
        Returns:
        0 for no proxy.
      • getProxyType

        public int getProxyType()
        Gets the proxy type: 0=none/DIRECT, 1=HTTP, 2=SOCKS 4/5.
      • useWebSocket

        public boolean useWebSocket()
        Checks if WebSocket protocol is used.
        Returns:
        true if WebSocket is used, false otherwise.
      • getProxyUser

        public java.lang.String getProxyUser()
        Gets the authentication user name for HTTP proxy if required.
        Returns:
        null for none, otherwise a user name.
      • getProxyPW

        public java.lang.String getProxyPW()
        Gets the authentication password for HTTP proxy if required.
        Returns:
        null for none, otherwise a password for the user name in question.
      • setHost

        public void setHost​(java.lang.String host)
        Sets the destination host name/IP address for the socket.
        Parameters:
        host - the host name or IP address (IPv4 or IPv6).
        Throws:
        java.lang.NullPointerException - if the parameter is null.
      • setPort

        public void setPort​(int port)
        Gets the host port for the socket.
        Parameters:
        port - the port number 1-65535.
        Throws:
        java.lang.IllegalArgumentException - if the port is not 1-65535.
      • setBindAddress

        public void setBindAddress​(java.lang.String bindAddress)
        Sets the bind address for the socket, i.e. the local host name or IP address.
        Parameters:
        bindAddress - The bind address as host name or IP address (IPv4 or IPv6).
      • setSecureProps

        public void setSecureProps​(SSLCommProps secureProps)
                            throws PropException
        Sets or removed the secure properties.
        Parameters:
        secureProps - The secure properties, or null to remove them.
        Throws:
        PropException - If the properties couldn't be added, set or removed.
      • getSecureProps

        public SSLCommProps getSecureProps()
                                    throws PropException
        Gets the secure properties.To check for secure communication, use isSecure().
        Returns:
        The instance of the secure properties, null if not secure.
        Throws:
        PropException - If the secure properties couldn't be added.
      • createSecureProps

        public SSLCommProps createSecureProps()
                                       throws PropException
        Creates or gets the secure properties. If the no secure properties are present, a new instance is created.
        Returns:
        The instance of the secure properties.
        Throws:
        PropException - If the secure properties couldn't be added.
      • setProxyHost

        public void setProxyHost​(java.lang.String proxyHost)
        Sets the proxy host name if any.
        Parameters:
        proxyHost - The proxy host name or IP address.
      • setProxyPort

        public void setProxyPort​(int proxyPort)
        Sets the proxy port if any.
        Parameters:
        proxyPort - 0 for no proxy, otherwise 1-65535.
        Throws:
        java.lang.IllegalArgumentException - if the proxyPort is not 0-65535.
      • setProxyType

        public void setProxyType​(int proxyType)
        Sets the proxy type: 0=none/DIRECT, 1=HTTP, 2=SOCKS 4/5.
        Parameters:
        proxyType - 0=none/DIRECT, 1=HTTP, 2=SOCKS 4/5.
        Throws:
        java.lang.IllegalArgumentException - if the proxyType is not 0-2.
      • setWebSocket

        public void setWebSocket​(boolean webSocket)
        Sets if WebSocket protocol is used.
        Parameters:
        webSocket - true if WebSocket is used, false otherwise.
      • setProxyUser

        public void setProxyUser​(java.lang.String proxyUser)
        Gets the authentication user name for HTTP proxy if required.
        Parameters:
        proxyUser - The user name.
      • getProxyPW

        public void getProxyPW​(java.lang.String password)
        Sets the authentication password for HTTP proxy if required. This password is not stored for persistence nor transmitted if the class instance is cloned or transmitted in transactions.
        Parameters:
        password - null for none, otherwise a password for the user name in question.
      • setResolveHostNames

        public void setResolveHostNames​(boolean doResolveHostNames)
        Sets if host name resolve is enabled or if the host address should be returned (for performance reasons) for a call to e.g. getRemoteHost().
        Parameters:
        doResolveHostNames - true if host names should be resolved, default is false.
      • doResolveHostNames

        public boolean doResolveHostNames()
        Checks if host name resolve is enabled or if the host address should be returned (for performance reasons) for a call to e.g. getRemoteHost().
        Returns:
        true if host names should be resolved, default is false.