Package com.verisign.epp.interfaces

## Class EPPHttpSession

- java.lang.Object
- - com.verisign.epp.interfaces.EPPSession
  - - com.verisign.epp.interfaces.EPPHttpSession

- Direct Known Subclasses:
    `EPPPooledGenericHttpSession`

      public class EPPHttpSession
      extends EPPSession

  EPPHttpSession provides behavior for communicating with an EPP Server using the HTTP protocol as the transport.

- - ### Field Summary

    - ### Fields inherited from class com.verisign.epp.interfaces.EPPSession

      `clientId, codec, connection, extensionServices, inputStream, language, loginAdapter, message, mode, MODE_ASYNC, MODE_SYNC, msgID, newPassword, OP_ACK, OP_REQ, outputStream, password, pollOp, response, services, transId, version`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `EPPHttpSession()` | Contact an `EPPHttpSession` instance using the URL defined in the "EPP.ServerURL" configuration property.
    `EPPHttpSession​(java.lang.String aUrl)` | Construct an `EPPHttpSession` instance that points to the given URL.
    `EPPHttpSession​(java.lang.String aUrl, EPPSSLContext aSSLContext)` | Construct an `EPPHttpSession` instance that points to the given URL and an `EPPSSLContext`.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `endConnection()` | End the `EPPHttpSession`.
    `void` | `endSession()` | Ends a session by logging out from the server and closing the connection with the server.
    `EPPGreeting` | `getGreeting()` | Gets the EPP Greeting received when making the connection.
    `java.net.http.HttpClient` | `getHttpClient()` | Gets the `HttpClient` instance.
    `static java.net.http.HttpClient.Version` | `getHttpVersion()` | Returns the HTTP version to use, with the default being HTTP/2 with `HttpClient.Version.HTTP_2`.
    `java.lang.String` | `getUrl()` | Gets the server URL to connect to.
    `EPPGreeting` | `hello()` | Sends a Hello Command to the EPP Server.
    `void` | `init()` | Helper method called by constructor to perform any initialization required for the `EPPHttpSession` class.
    `boolean` | `isModeSupported​(int aMode)` | Does the session support the specified mode `EPPSession.MODE_SYNC` or `EPPSession.MODE_ASYNC`? `EPPHttpSession` only supports `EPPSession.MODE_SYNC`.
    `protected void` | `login()` | Sends the EPP login command over the HTTP connection to establish an EPP session.
    `protected void` | `logout()` | Sends the EPP logout command over the HTTP connection to gracefully end EPP session.
    `EPPMessage` | `postMessage​(EPPMessage aMessage)` | Send the message in an HTTP POST method.
    `EPPResponse` | `processDocument​(EPPCommand aCommand, java.lang.Class aExpectedResponse)` | Process an `EPPCommand` instance posting the command and processing the response.
    `org.w3c.dom.Document` | `recDocument()` | A no-op for the EPPHttpSession implementation.
    `void` | `sendDocument​(org.w3c.dom.Document aDocument, EPPMessage aMessage)` | A no-op for the EPPHttpSession implementation.
    `EPPResponse` | `sendPoll()` | This method creates an instance of `EPPPollCmd` and sets the given attributes and invokes the send method associated with the command.
    `void` | `setHttpClient​(java.net.http.HttpClient aHttpClient)` | Sets the `HttpClient` instance.
    `void` | `setUrl​(java.lang.String aUrl)` | Sets the server URL to connect to.

    - ### Methods inherited from class com.verisign.epp.interfaces.EPPSession

      `getClientCon, getClientID, getConnection, getInputStream, getLoginAdapter, getMode, getMsgID, getNewPassword, getOutputStream, getPassword, getPollOp, getResponse, getTransId, getVersion, init, init, initLoginAdapter, initSession, initSession, initStreams, login, processDocument, processGreeting, readResponse, sendMessage, sendPacket, setClientID, setExtensions, setInputStream, setLang, setLang, setLoginAdapter, setMode, setMsgID, setNewPassword, setOutputStream, setPassword, setPollOp, setServices, setTransId, setVersion, validateClientTransId`

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

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

- - ### Constructor Detail

    - #### EPPHttpSession

          public EPPHttpSession​(java.lang.String aUrl)
                         throws EPPCommandException

      Construct an `EPPHttpSession` instance that points to the given URL. An example is `https://test.vgrs.com:8080/`.
      Parameters:
        `aUrl` - URL to connect to
      Throws:
        `EPPCommandException` - Error initializing the session

    - #### EPPHttpSession

          public EPPHttpSession​(java.lang.String aUrl,
                                EPPSSLContext aSSLContext)
                         throws EPPCommandException

      Construct an `EPPHttpSession` instance that points to the given URL and an `EPPSSLContext`. An example is `https://test.vgrs.com:8080/`.
      Parameters:
        `aUrl` - URL to connect to
        `aSSLContext` - Optional specific SSL context to use. Set to `null` if undefined.
      Throws:
        `EPPCommandException` - Error initializing the session

    - #### EPPHttpSession

          public EPPHttpSession()
                         throws EPPCommandException

      Contact an `EPPHttpSession` instance using the URL defined in the "EPP.ServerURL" configuration property.
      Throws:
        `EPPCommandException` - Error initializing the `EPPHttpSession`

  - ### Method Detail

    - #### init

          public void init()
                    throws EPPCommandException

      Helper method called by constructor to perform any initialization required for the `EPPHttpSession` class.
      Overrides:
        `init` in class `EPPSession`
      Throws:
        `EPPCommandException` - if something goes wrong

    - #### getHttpClient

          public java.net.http.HttpClient getHttpClient()

      Gets the `HttpClient` instance.
      Returns:
        the `HttpClient` instance if set; `null` otherwise.

    - #### setHttpClient

          public void setHttpClient​(java.net.http.HttpClient aHttpClient)

      Sets the `HttpClient` instance.
      Parameters:
        `aHttpClient` - The `HttpClient` instance. Setting to `null` will not apply.

    - #### postMessage

          public EPPMessage postMessage​(EPPMessage aMessage)
                                 throws EPPCommandException

      Send the message in an HTTP POST method.
      Parameters:
        `aMessage` - Message to send
      Returns:
        The EPP message returned, which could be an `EPPGreeting` or an `EPPResponse`.
      Throws:
        `EPPCommandException` - Error posting the `aXml`

    - #### hello

          public EPPGreeting hello()
                            throws EPPCommandException

      Sends a Hello Command to the EPP Server. The EPP Greeting from the EPP Server will be returned.
      Overrides:
        `hello` in class `EPPSession`
      Returns:
        EPP Greeting
      Throws:
        `EPPCommandException` - Thrown if any exception occurs.

    - #### sendPoll

          public EPPResponse sendPoll()
                               throws EPPCommandException

      This method creates an instance of `EPPPollCmd` and sets the given attributes and invokes the send method associated with the command.
      Overrides:
        `sendPoll` in class `EPPSession`
      Returns:
        the response from the poll command
      Throws:
        `EPPCommandException` - Error sending the poll command

    - #### endSession

          public void endSession()
                          throws EPPCommandException

      Ends a session by logging out from the server and closing the connection with the server.
      Overrides:
        `endSession` in class `EPPSession`
      Throws:
        `EPPCommandException` - Error ending session

    - #### endConnection

          public void endConnection()
                             throws EPPCommandException

      End the `EPPHttpSession`.
      Overrides:
        `endConnection` in class `EPPSession`
      Throws:
        `EPPCommandException` - Error ending the `EPPHttpSession`. todo Explicitly close the underlying HttpClient once using Java 21 and above.

    - #### login

          protected void login()
                        throws EPPCommandException

      Sends the EPP login command over the HTTP connection to establish an EPP session.
      Overrides:
        `login` in class `EPPSession`
      Throws:
        `EPPCommandException` - Error sending the EPP login command

    - #### logout

          protected void logout()
                         throws EPPCommandException

      Sends the EPP logout command over the HTTP connection to gracefully end EPP session.
      Overrides:
        `logout` in class `EPPSession`
      Throws:
        `EPPCommandException` - Error sending the EPP login command

    - #### processDocument

          public EPPResponse processDocument​(EPPCommand aCommand,
                                             java.lang.Class aExpectedResponse)
                                      throws EPPCommandException

      Process an `EPPCommand` instance posting the command and processing the response. The only mode supported is `EPPSession.MODE_SYNC`.
      Overrides:
        `processDocument` in class `EPPSession`
      Parameters:
        `aCommand` - Command to post to the server
        `aExpectedResponse` - Expected type of `EPPResponse`. If `aExpectedResponse` is non-`null` and the response is not of the specified type, than an `EPPCommandException` will be thrown.
      Returns:
        Response associated with passed in command
      Throws:
        `EPPCommandException` - error processing the command. This can include an error specified from the server or encountered while attempting to process the command. If the exception contains an `EPPResponse` than it was a server specified error.

    - #### sendDocument

          public void sendDocument​(org.w3c.dom.Document aDocument,
                                   EPPMessage aMessage)
                            throws EPPCommandException

      A no-op for the EPPHttpSession implementation.
      Overrides:
        `sendDocument` in class `EPPSession`
      Parameters:
        `aDocument` - Document to send
        `aMessage` - Message associated with `newDoc` that is used for packet logging logic. Set to `null` if unavailable.
      Throws:
        `EPPCommandException` - Error processing the command

    - #### recDocument

          public org.w3c.dom.Document recDocument()
                                           throws EPPCommandException

      A no-op for the EPPHttpSession implementation.
      Overrides:
        `recDocument` in class `EPPSession`
      Returns:
        Document received
      Throws:
        `EPPCommandException` - Error receiving the document

    - #### getHttpVersion

          public static java.net.http.HttpClient.Version getHttpVersion()
                                                                 throws EPPEnvException

      Returns the HTTP version to use, with the default being HTTP/2 with `HttpClient.Version.HTTP_2`.
      Returns:
        `HTTPClient.Version` value
      Throws:
        `EPPEnvException` - The "EPP.ServerName" property does not exist.

    - #### getUrl

          public java.lang.String getUrl()

      Gets the server URL to connect to.
      Returns:
        Gets the server URL to connection to if set; `null` otherwise.

    - #### setUrl

          public void setUrl​(java.lang.String aUrl)

      Sets the server URL to connect to.
      Parameters:
        `aUrl` - Server URL to

    - #### isModeSupported

          public boolean isModeSupported​(int aMode)

      Does the session support the specified mode `EPPSession.MODE_SYNC` or `EPPSession.MODE_ASYNC`? `EPPHttpSession` only supports `EPPSession.MODE_SYNC`.
      Overrides:
        `isModeSupported` in class `EPPSession`
      Parameters:
        `aMode` - `EPPSession.MODE_SYNC` or `EPPSession.MODE_ASYNC`
      Returns:
        `true` if supported; `false` otherwise.

    - #### getGreeting

          public EPPGreeting getGreeting()

      Gets the EPP Greeting received when making the connection.
      Returns:
        The EPP Greeting if set; `null` otherwise.