Class AdvancedMemoryDataLoader

java.lang.Object
eu.europa.esig.dss.spi.client.http.AdvancedMemoryDataLoader
All Implemented Interfaces:
AdvancedDataLoader, DataLoader, Serializable

public class AdvancedMemoryDataLoader extends Object implements AdvancedDataLoader
Defines a map between URL and document to load the response data from offline source
See Also:
  • Constructor Details

    • AdvancedMemoryDataLoader

      public AdvancedMemoryDataLoader(Map<String, ResponseEnvelope> dataMap)
      Default constructor
      Parameters:
      dataMap - a map between URLs and the corresponding response data content
  • Method Details

    • get

      public byte[] get(String url)
      Description copied from interface: DataLoader
      Execute a HTTP GET operation.
      Specified by:
      get in interface DataLoader
      Parameters:
      url - the url to access
      Returns:
      byte array of obtained data or null
    • get

      public DataLoader.DataAndUrl get(List<String> urlStrings) throws DSSException
      Description copied from interface: DataLoader
      Execute a HTTP GET operation. This method is used when many URls are available to access the same resource. The operation stops after the first successful download.
      Specified by:
      get in interface DataLoader
      Parameters:
      urlStrings - List of Strings representing the URLs to be used in sequential way to obtain the data.
      Returns:
      DataAndUrl representing the array of obtained data and used url, or null
      Throws:
      DSSException
    • post

      public byte[] post(String url, byte[] content)
      Description copied from interface: DataLoader
      Executes a HTTP POST operation
      Specified by:
      post in interface DataLoader
      Parameters:
      url - to access
      content - the content to post
      Returns:
      byte array of obtained data
    • setContentType

      public void setContentType(String contentType)
      Description copied from interface: DataLoader
      This allows to set the content type. Example: Content-Type "application/ocsp-request"
      Specified by:
      setContentType in interface DataLoader
      Parameters:
      contentType - to set the Content-Type
    • requestGet

      public ResponseEnvelope requestGet(String url)
      Description copied from interface: AdvancedDataLoader
      Executes a GET request and returns an ResponseEnvelope object. This method included the response message body, context and metadata within the response object.
      Specified by:
      requestGet in interface AdvancedDataLoader
      Parameters:
      url - String URL to perform request to
      Returns:
      ResponseEnvelope
    • requestGet

      public ResponseEnvelope requestGet(String url, boolean includeResponseDetails)
      Description copied from interface: AdvancedDataLoader
      Executes a GET request and returns an ResponseEnvelope object. This method allows configuration whether the response context (HTTP headers, TLS/SSL certificates, etc.), is to be included within the response object. The response body will be included within the response, when calling this method.
      Specified by:
      requestGet in interface AdvancedDataLoader
      Parameters:
      url - String URL to perform request to
      includeResponseDetails - defines whether the response context (HTTP headers, metadata) is to be included within the response
      Returns:
      ResponseEnvelope
    • requestGet

      public ResponseEnvelope requestGet(String url, boolean includeResponseDetails, boolean includeResponseBody)
      Description copied from interface: AdvancedDataLoader
      Executes a GET request and returns an ResponseEnvelope object. This method allows configuration whether the response context (HTTP headers, TLS/SSL certificates, etc.), as well as the response message body are to be included within the response object. The data which is not included, won't be read by the execution process, thus helping to achieve time-memory efficiency.
      Specified by:
      requestGet in interface AdvancedDataLoader
      Parameters:
      url - String URL to perform request to
      includeResponseDetails - defines whether the response context (HTTP headers, metadata) is to be included within the response
      includeResponseBody - defines whether the response body is to be included within the response
      Returns:
      ResponseEnvelope
    • requestPost

      public ResponseEnvelope requestPost(String url, byte[] content)
      Description copied from interface: AdvancedDataLoader
      Executes a POST request and returns an ResponseEnvelope object. This method included the response message body, context and metadata within the response object.
      Specified by:
      requestPost in interface AdvancedDataLoader
      Parameters:
      url - String URL to perform request to
      content - byte array containing request content for the POST call
      Returns:
      ResponseEnvelope
    • requestPost

      public ResponseEnvelope requestPost(String url, byte[] content, boolean includeResponseDetails)
      Description copied from interface: AdvancedDataLoader
      Executes a POST request and returns an ResponseEnvelope object. This method allows configuration whether the response context (HTTP headers, TLS/SSL certificates, etc.), is to be included within the response object. The response body will be included within the response, when calling this method.
      Specified by:
      requestPost in interface AdvancedDataLoader
      Parameters:
      url - String URL to perform request to
      content - byte array containing request content for the POST call
      includeResponseDetails - defines whether the response context (HTTP headers, metadata) is to be included within the response
      Returns:
      ResponseEnvelope
    • requestPost

      public ResponseEnvelope requestPost(String url, byte[] content, boolean includeResponseDetails, boolean includeResponseBody)
      Description copied from interface: AdvancedDataLoader
      Executes a POST request and returns an ResponseEnvelope object. This method allows configuration whether the response context (HTTP headers, TLS/SSL certificates, etc.), as well as the response message body are to be included within the response object. The data which is not included, won't be read by the execution process, thus helping to achieve time-memory efficiency.
      Specified by:
      requestPost in interface AdvancedDataLoader
      Parameters:
      url - String URL to perform request to
      content - byte array containing request content for the POST call
      includeResponseDetails - defines whether the response context (HTTP headers, metadata) is to be included within the response
      includeResponseBody - defines whether the response body is to be included within the response
      Returns:
      ResponseEnvelope