Class FormAuthHttpClient

java.lang.Object
org.glassfish.main.itest.tools.FormAuthHttpClient

public class FormAuthHttpClient extends Object
HTTP client using the HTTP protocol and form based authentication.
  • Constructor Details

    • FormAuthHttpClient

      public FormAuthHttpClient(URL baseUrl, String user, String password)
      Parameters:
      baseUrl - target endpoint.
      user -
      password -
  • Method Details

    • readResponseBody

      public static String readResponseBody(HttpURLConnection connection) throws IOException
      Read remaining bytes in the response as a response body. The input stream will be closed then.
      Parameters:
      connection -
      Returns:
      String.
      Throws:
      IOException
    • get

      public HttpURLConnection get(String relativePath) throws IOException
      Does following steps:
      1. HTTP GET to the protected relative path - expects HTTP 200 and login page - and also id of the new session.
      2. HTTP POST to the /j_security_check with the j_username and j_password in the request body and JSESSIONID sent as a cookie. Expects the body for the original protected relative path.
      Parameters:
      relativePath -
      Returns:
      connection with headers and body which can be parsed.
      Throws:
      IOException
      ProtocolException