Class Get

java.lang.Object
org.jose4j.http.Get
All Implemented Interfaces:
SimpleGet

public class Get extends Object implements SimpleGet
An implantation of SimpleGet (used by HttpsJwks) that uses URL and HttpsURLConnection to make basic HTTP GET requests.
  • Constructor Details

    • Get

      public Get()
  • Method Details

    • get

      public SimpleResponse get(String location) throws IOException
      Description copied from interface: SimpleGet
      Make an HTTP GET request
      Specified by:
      get in interface SimpleGet
      Parameters:
      location - the HTTP(S) URL
      Returns:
      a SimpleResponse object representing the result of the HTTP GET request
      Throws:
      IOException - if a problem occurs with the request
    • setConnectTimeout

      public void setConnectTimeout(int connectTimeout)
      Sets a specified timeout value, in milliseconds, to be used by the underlying URLConnection when opening a communications link to the resource referenced by the URLConnection. Default is 20000.
      Parameters:
      connectTimeout - the timeout value to be used in milliseconds
    • setReadTimeout

      public void setReadTimeout(int readTimeout)
      Sets the read timeout to the specified value, in milliseconds, for the underlying URLConnection. Default is 20000.
      Parameters:
      readTimeout - the timeout value to be used in milliseconds
    • setHostnameVerifier

      public void setHostnameVerifier(HostnameVerifier hostnameVerifier)
      Sets the HostnameVerifier used by the underlying HttpsURLConnection.
      Parameters:
      hostnameVerifier - the host name verifier
    • setTrustedCertificates

      public void setTrustedCertificates(X509Certificate... certificates)
      Parameters:
      certificates - certificates to trust
    • setRetries

      public void setRetries(int retries)
      Sets the number times to retry in the case of a request that failed for a reason that potently could be recovered from. Default is 3.
      Parameters:
      retries - the number of times to retry
    • setProgressiveRetryWait

      public void setProgressiveRetryWait(boolean progressiveRetryWait)
      Sets whether a progressively longer wait time should be used between retry attempts (up to a max of 8000). Defaut is true.
      Parameters:
      progressiveRetryWait - true for a progressively longer retry wait time, false for a static retry wait time
    • setInitialRetryWaitTime

      public void setInitialRetryWaitTime(long initialRetryWaitTime)
      Sets the initial wait time for retry requests. Default is 180.
      Parameters:
      initialRetryWaitTime - wait time in milliseconds
    • setResponseBodySizeLimit

      public void setResponseBodySizeLimit(int responseBodySizeLimit)
      Sets a limit on the size of the response body that will be consumed. Default is 1,024,512.
      Parameters:
      responseBodySizeLimit - size limit of the response body in number of characters, -1 indicates no limit
    • setTrustedCertificates

      public void setTrustedCertificates(Collection<X509Certificate> certificates)
      Sets the certificates that will be used by the underlying HttpsURLConnection as trust anchors when validating the HTTPS certificate presented by the server. When this method is used, the provided certificates become the only trusted certificates for the instance (the ones from the java runtime won't be used in that context anymore).

      Note that only one of setSslSocketFactory(SSLSocketFactory) or setTrustedCertificates(Collection) or setTrustedCertificates(X509Certificate...) should be used per instance of this class as each results in the setting of the underlying SSLSocketFactory used by the HttpsURLConnection and the last method to be called will effectively override the others.

      Parameters:
      certificates - certificates to trust
    • setSslSocketFactory

      public void setSslSocketFactory(SSLSocketFactory sslSocketFactory)

      Sets the SSLSocketFactory to used when creating sockets for HTTPS connections, which allows for control over the details of creating and initially configuring the secure sockets such as setting authentication keys, peer certificate validation, enabled cipher suites, and so on.

      Note that only one of setSslSocketFactory(SSLSocketFactory) or setTrustedCertificates(Collection) or setTrustedCertificates(X509Certificate...) should be used per instance of this class as each results in the setting of the underlying SSLSocketFactory used by the HttpsURLConnection and the last method to be called will effectively override the others.

      Parameters:
      sslSocketFactory - the SSLSocketFactory
    • setHttpProxy

      public void setHttpProxy(Proxy proxy)
      Sets the Proxy through which the connection will be made with URL.openConnection(Proxy). By default no Proxy is used when making the connection - e.g. just URL.openConnection().
      Parameters:
      proxy - the Proxy through which the connection will be made