Class AbstractHTTPWithJWTTokenAuthEventSender

java.lang.Object
org.gcube.event.publisher.AbstractHTTPWithJWTTokenAuthEventSender
All Implemented Interfaces:
EventSender
Direct Known Subclasses:
HTTPWithOIDCAuthEventSender

public abstract class AbstractHTTPWithJWTTokenAuthEventSender extends Object implements EventSender
  • Field Details

  • Constructor Details

    • AbstractHTTPWithJWTTokenAuthEventSender

      public AbstractHTTPWithJWTTokenAuthEventSender(URL baseEndpointURL, String clientId, String clientSecret, URL tokenURL)
    • AbstractHTTPWithJWTTokenAuthEventSender

      public AbstractHTTPWithJWTTokenAuthEventSender(URL baseEndpointURL, String clientId, String clientSecret, URL tokenURL, int connectionTimeout, int readTimeout)
  • Method Details

    • getReadTimeout

      public int getReadTimeout()
    • setReadTimeout

      public void setReadTimeout(int readTimeout)
    • getConnectionTimeout

      public int getConnectionTimeout()
    • setConnectionTimeout

      public void setConnectionTimeout(int connectionTimeout)
    • send

      public void send(Event event)
      Description copied from interface: EventSender
      Sends an event.
      Specified by:
      send in interface EventSender
      Parameters:
      event - the event to send
    • getLastSendHTTPResponseCode

      public int getLastSendHTTPResponseCode()
      Description copied from interface: EventSender
      Return the last send HTTP response code.
      Specified by:
      getLastSendHTTPResponseCode in interface EventSender
      Returns:
      the HTTP response code or -1 if an error occurred before the call (e.g. during the authorization or connection)
    • sendAndGetResult

      public String sendAndGetResult(Event event)
      Description copied from interface: EventSender
      Send an event and get results.
      Specified by:
      sendAndGetResult in interface EventSender
      Parameters:
      event - the event to send
      Returns:
      the result of the call
    • retrive

      public org.json.simple.JSONObject retrive(String id)
      Description copied from interface: EventSender
      Retrieves the instance of the provided workflow instance.
      Specified by:
      retrive in interface EventSender
      Parameters:
      id - the workflow instance id
      Returns:
    • getLastRetrieveHTTPResponseCode

      public int getLastRetrieveHTTPResponseCode()
      Description copied from interface: EventSender
      Return the last retrieve HTTP response code.
      Specified by:
      getLastRetrieveHTTPResponseCode in interface EventSender
      Returns:
      the HTTP response code or -1 if an error occurred before the call (e.g. during the authorization or connection)
    • getTokenURL

      protected URL getTokenURL()
    • getAuthorizationToken

      protected abstract String getAuthorizationToken() throws EventSenderAuthException
      Gives the access token (the raw JWT string, without the Bearer prefix) to authorize the next request. It is called at every attempt, so implementations should cache it until it expires.
      Returns:
      the access token, or null to send the request without authorization
      Throws:
      EventSenderAuthException - if the token cannot be obtained