Class HTTPServerConnector

    • Field Detail

      • PARAMETER_TCP_PORT

        public static final java.lang.String PARAMETER_TCP_PORT
        Parameter Name: "tcpPort"
        See Also:
        Constant Field Values
      • PARAM_TCP_BACKLOG

        public static final java.lang.String PARAM_TCP_BACKLOG
        Parameter Name: "backlog"
        See Also:
        Constant Field Values
      • PARAM_SYSTEM_TCP_BACKLOG

        public static final java.lang.String PARAM_SYSTEM_TCP_BACKLOG
        Parameter Name: "com.ibm.di.tcp.backlog"
        See Also:
        Constant Field Values
      • PARAMETER_HEADERS_AS_PROPS

        public static final java.lang.String PARAMETER_HEADERS_AS_PROPS
        Parameter Name: "headersAsProperties"
        See Also:
        Constant Field Values
      • PARAMETER_TCP_DATA_AS_PROPS

        public static final java.lang.String PARAMETER_TCP_DATA_AS_PROPS
        Parameter Name: "tcpDataAsProperties"
        See Also:
        Constant Field Values
      • PARAMETER_AUTH_CONN

        public static final java.lang.String PARAMETER_AUTH_CONN
        Parameter Name: "authConnector"
        See Also:
        Constant Field Values
      • PARAMETER_HTTP_BASIC_AUTH

        public static final java.lang.String PARAMETER_HTTP_BASIC_AUTH
        Parameter Name: "httpAuth"
        See Also:
        Constant Field Values
      • PARAMETER_AUTH_REALM

        public static final java.lang.String PARAMETER_AUTH_REALM
        Parameter Name: "authRealm"
        See Also:
        Constant Field Values
      • PARAMETER_USE_SSL

        public static final java.lang.String PARAMETER_USE_SSL
        Parameter Name: "useSSL"
        See Also:
        Constant Field Values
      • PARAMETER_REQUIRE_CLIENT_AUTH

        public static final java.lang.String PARAMETER_REQUIRE_CLIENT_AUTH
        Parameter Name: "needClientAuth"
        See Also:
        Constant Field Values
      • PARAMETER_CONTENT_TYPE

        public static final java.lang.String PARAMETER_CONTENT_TYPE
        Parameter Name: "contentType"
        See Also:
        Constant Field Values
      • PARAMETER_USE_CHUNKS

        public static final java.lang.String PARAMETER_USE_CHUNKS
        Parameter Name: "msgChunked"
        See Also:
        Constant Field Values
      • PARAMETER_IDLE_CONNECTION_TIMEOUT

        public static final java.lang.String PARAMETER_IDLE_CONNECTION_TIMEOUT
        Parameter Name: . Connection timeout in seconds.
        See Also:
        Constant Field Values
      • ATTR_NAME_HTTP_REMOTE_USER

        public static final java.lang.String ATTR_NAME_HTTP_REMOTE_USER
        An Entry attribute name: "http.remote_user"
        See Also:
        Constant Field Values
      • ATTR_NAME_HTTP_REMOTE_PASSWORD

        public static final java.lang.String ATTR_NAME_HTTP_REMOTE_PASSWORD
        An Entry attribute name: "http.remote_pass"
        See Also:
        Constant Field Values
      • ATTR_NAME_HTTP_BODY

        public static final java.lang.String ATTR_NAME_HTTP_BODY
        An Entry attribute name: "http.body"
        See Also:
        Constant Field Values
      • ATTR_NAME_HTTP_CONTENT_TYPE

        public static final java.lang.String ATTR_NAME_HTTP_CONTENT_TYPE
        An Entry attribute name: "http.Content-Type"
        See Also:
        Constant Field Values
      • ATTR_NAME_HTTP_CHARACTER_SET

        public static final java.lang.String ATTR_NAME_HTTP_CHARACTER_SET
        An Entry attribute name: "characterSet"
        See Also:
        Constant Field Values
      • ATTR_NAME_HTTP_CONNECTION

        public static final java.lang.String ATTR_NAME_HTTP_CONNECTION
        An Entry attribute name: "http.connection"
        See Also:
        Constant Field Values
      • ATTR_NAME_HTTP_AUTH_ENTRY

        public static final java.lang.String ATTR_NAME_HTTP_AUTH_ENTRY
        An Entry attribute name: "auth.entry"
        See Also:
        Constant Field Values
      • HTTP_BAD_REQUEST

        public static final java.lang.String HTTP_BAD_REQUEST
        Error String: "400 Bad Request"
        See Also:
        Constant Field Values
      • VERSION_INFO

        public static final java.lang.String VERSION_INFO
        The Connector version.
        See Also:
        Constant Field Values
      • CONNECTOR_MODES

        public static final java.lang.String[] CONNECTOR_MODES
        Possible Connector modes.
    • Constructor Detail

      • HTTPServerConnector

        public HTTPServerConnector()
        Constructs this object, sets the supported modes and initializes the internally used HTTPParser.
    • Method Detail

      • initialize

        public void initialize​(java.lang.Object aObject)
                        throws java.lang.Exception
        Parsers all the configuration parameters of this connector and prepares for starting the HTTP Server. If a Socket is provided as a parameter then that socket will be used for communication with the client on the other end of the socket.
        Specified by:
        initialize in interface ConnectorInterface
        Overrides:
        initialize in class Connector
        Parameters:
        aObject - recognizes only an object of type Socket
        Throws:
        java.lang.Exception - if an error occurs.
      • getNextClient

        public ConnectorInterface getNextClient()
                                         throws java.lang.Exception
        This method blocks until a client is connected. After a connection is established a new instance of this object is created, initialized and returned.
        Specified by:
        getNextClient in interface ConnectorInterface
        Overrides:
        getNextClient in class Connector
        Returns:
        a new instance of HTTPServerConnector responsible for handling the communication with the new client.
        Throws:
        java.lang.Exception - if this connector was not initialized properly or other type of error occurs.
      • getServerConnector

        public HTTPServerConnector getServerConnector()
        Retrieves server connector.
        Returns:
        the server connector if this connector is handling an HTTP client session, or null if a connection has not been established yet.
      • setServerConnector

        public void setServerConnector​(HTTPServerConnector aServerConnector)
        Sets the server connector for this connector.
        Parameters:
        aServerConnector - the server connector that created this instance.
      • isAccepting

        public boolean isAccepting()
        Checks whether the connector is waiting for a client connection.
        Returns:
        true if this connector is currently waiting for a client connection.
      • isTerminating

        public boolean isTerminating()
        Checks whether a termination request is sent.
        Returns:
        true if this connector has the termination flag set.
      • terminateServer

        public void terminateServer()
                             throws java.lang.Exception
        This method tries to terminate the server by setting the termination flag for the connector returned by getServerConnector and immediately connecting to its port (which should fail).
        Specified by:
        terminateServer in interface ConnectorInterface
        Overrides:
        terminateServer in class Connector
        Throws:
        java.lang.Exception - if an error occurs.
      • terminate

        public void terminate()
                       throws java.lang.Exception
        Terminate the connector. This function closes all connection and releases all resources used by the connector. This function also calls the parser's closeParser() method if a parser is active.
        Specified by:
        terminate in interface ConnectorInterface
        Overrides:
        terminate in class Connector
        Throws:
        java.lang.Exception - if an error occurs.
      • getNextEntry

        public Entry getNextEntry()
                           throws java.lang.Exception
        This method is called when this connector is used in Iterator mode. This method will block until a client connects on the opened port. If the authentication fails the method returns null. If authentication is successful the HTTP request is parsed to an Entry object and returned.
        Specified by:
        getNextEntry in interface ConnectorInterface
        Overrides:
        getNextEntry in class Connector
        Returns:
        the parsed HTTP request as an Entry object.
        Throws:
        java.lang.Exception - if an error occurs.
        See Also:
        ConnectorInterface.selectEntries()
      • putEntry

        public void putEntry​(Entry aEntry)
                      throws java.lang.Exception
        This method provides chunking capabilities to the HTTP server. This method is used from a scripts and is not directly called by the TDI Server. If the chunking is turned off the usage of this method will turn it on.
        Specified by:
        putEntry in interface ConnectorInterface
        Overrides:
        putEntry in class Connector
        Parameters:
        aEntry - the entry to send as a chunk.
        Throws:
        java.lang.Exception - if a communication error is raised.
      • replyEntry

        public void replyEntry​(Entry aEntry)
                        throws java.lang.Exception
        This method sends the provided entry to the client as an HTTP response. If chunking is enabled then the provided entry will be sent as the last chunk.
        Specified by:
        replyEntry in interface ConnectorInterface
        Overrides:
        replyEntry in class Connector
        Parameters:
        aEntry - the entry to send to the client.
        Throws:
        java.lang.Exception - if an error occurs.
      • getUserName

        public java.lang.String getUserName()
        Retrieves username.
        Returns:
        the username used for the authentication.
      • getPassword

        public java.lang.String getPassword()
        Retrieves password.
        Returns:
        the password the user has authenticated with.
      • rejectClientAuthentication

        public void rejectClientAuthentication()
                                        throws java.lang.Exception
        Prints the Forbidden page and closes the connection. This method does not have effect if the basic authentication is not enabled for this connector.
        Throws:
        java.lang.Exception - if an error occurs.
      • setProperty

        public void setProperty​(Entry aEntry,
                                java.lang.String aProperty,
                                java.lang.Object aValue,
                                boolean aTcpDataAsProps)
        This method adds a property to the provided entry if the aTcpDataAsProps is set to true, if it is set to false then the provided property is added as an attribute.
        Parameters:
        aEntry - the entry which the property will be set on.
        aProperty - the property name.
        aValue - the property value.
        aTcpDataAsProps - tells whether the property will be set as an Entry property or as Entry Attribute.
      • getVersion

        public java.lang.String getVersion()
        Version information.
        Specified by:
        getVersion in interface VersionInfoInterface
        Returns:
        version information
      • setAutoChunking

        public void setAutoChunking​(boolean enabled)
        This method lets the user dynamically configure chunked output mode. It has no effect if chunking already is enabled through the configuration. Setting this to "true" will cause the putEntry method to automatically initialize the chunked writer for output.
        Parameters:
        enabled - The new value for automatic chunking.
      • isAutoChunking

        public boolean isAutoChunking()
        Returns whether automatic chunking is enabled or not.
        Returns:
        True if automatic chunking is enabled.
      • isChunked

        public boolean isChunked()
        Returns true if response is chunked.
        Returns:
        True if response should be chunked.
      • isConnectionClosed

        public boolean isConnectionClosed()
        Returns true if the client socket is closed
        Returns: