Class GatewayService


  • public class GatewayService
    extends Object
    Service for Gateway's Integration
    • Constructor Detail

      • GatewayService

        public GatewayService()
    • Method Detail

      • initializeAccessServiceAgreement

        @Deprecated
        public static GatewayService.ServiceAgreementResult initializeAccessServiceAgreement​(String url,
                                                                                             InitializeAccessSLA payload)
        Deprecated.
        This method is Deprecated and will be removed in further versions Calls a Gateway's endpoint to request the initialization of a new Service Agreement
        Parameters:
        url - the url
        payload - the payload
        Returns:
        an object that indicates if the Gateway initialized the Service Agreement correctly
      • consumeUrl

        public static io.keyko.common.helpers.HttpHelper.DownloadResult consumeUrl​(String serviceEndpoint,
                                                                                   String consumerAddress,
                                                                                   String serviceAgreementId,
                                                                                   String url,
                                                                                   String destinationPath)
                                                                            throws IOException,
                                                                                   URISyntaxException
        Calls a Gateway´s endpoint to download an asset
        Parameters:
        serviceEndpoint - the service endpoint
        consumerAddress - the address of the consumer
        serviceAgreementId - the serviceAgreement Id
        url - the url
        destinationPath - the path to download the resource
        Returns:
        DownloadResult Instance of DownloadResult that indicates if the download was correct
        Throws:
        IOException - IOException
        URISyntaxException - URISyntaxException
      • downloadUrl

        public static void downloadUrl​(String serviceEndpoint,
                                       String consumerAddress,
                                       String serviceAgreementId,
                                       String url,
                                       String destinationPath)
                                throws IOException
        Calls a Gateway endpoint to download an asset
        Parameters:
        serviceEndpoint - the service endpoint
        consumerAddress - the address of the consumer
        serviceAgreementId - the serviceAgreement Id
        url - the url
        destinationPath - the path to download the resource
        Throws:
        IOException - Exception during the download process
      • downloadUrl

        public static InputStream downloadUrl​(String serviceEndpoint,
                                              String consumerAddress,
                                              String serviceAgreementId,
                                              String did,
                                              int index,
                                              String signature,
                                              Boolean isRangeRequest,
                                              Integer startRange,
                                              Integer endRange)
                                       throws IOException
        Calls a Gateway endpoint to download an asset
        Parameters:
        serviceEndpoint - the service endpoint
        consumerAddress - the address of the consumer
        serviceAgreementId - the serviceAgreement Id
        did - asset decentralized identifier
        index - index position of the file in the DDO
        signature - User signature of the service agreement
        startRange - the start of the bytes range
        endRange - the end of the bytes range
        isRangeRequest - indicates if is a range request
        Returns:
        an InputStream that represents the binary content
        Throws:
        IOException - Exception during the download process
      • downloadToPath

        public static void downloadToPath​(String serviceEndpoint,
                                          String consumerAddress,
                                          String serviceAgreementId,
                                          String did,
                                          int index,
                                          String signature,
                                          String destinationPath,
                                          Boolean isRangeRequest,
                                          Integer startRange,
                                          Integer endRange)
                                   throws IOException
        Calls a Gateway endpoint to download an asset
        Parameters:
        serviceEndpoint - the service endpoint
        consumerAddress - the address of the consumer
        serviceAgreementId - the serviceAgreement Id
        did - asset decentralized identifier
        index - index position of the file in the DDO
        signature - User signature of the service agreement
        destinationPath - path where the downloaded asset will be stored
        startRange - the start of the bytes range
        endRange - the end of the bytes range
        isRangeRequest - indicates if is a range request
        Throws:
        IOException - Exception during the download process
      • getStatus

        public static Status getStatus​(String serviceEndpoint)
                                throws IOException
        Calls a Gateway endpoint to download an asset
        Parameters:
        serviceEndpoint - the service endpoint
        Returns:
        an InputStream that represents the binary content
        Throws:
        IOException - Exception during the download process
      • encrypt

        public static EncryptionResponse encrypt​(String gatewayUrl,
                                                 String message,
                                                 AuthorizationService.AuthTypes authType)
                                          throws ServiceException
        Calls a Gateway endpoint to request the execution of a Compute Service
        Parameters:
        gatewayUrl - encryption endpoint
        message - the message to encrypt
        authType - AuthType to use for encryption
        Returns:
        EncryptionResponse an object that indicates if Gateway initialized the Execution of the Service correctly
        Throws:
        ServiceException - Service Exception
      • encrypt

        public static EncryptionResponse encrypt​(String gatewayUrl,
                                                 String message,
                                                 AuthorizationService.AuthTypes authType,
                                                 String did)
                                          throws ServiceException
        Calls a Gateway endpoint to request the execution of a Compute Service
        Parameters:
        gatewayUrl - encryption endpoint
        message - the message to encrypt
        authType - AuthType to use for encryption
        did - DID used to encrypt when using SecretStore
        Returns:
        EncryptionResponse an object with the gateway encryption response
        Throws:
        ServiceException - Service Exception
      • initializeServiceExecution

        public static GatewayService.ServiceExecutionResult initializeServiceExecution​(String serviceEndpoint,
                                                                                       ExecuteService payload)
        Calls a Gateway endpoint to request the execution of a Compute Service
        Parameters:
        serviceEndpoint - the serviceEndpoint
        payload - the payload
        Returns:
        an object that indicates if Gateway initialized the Execution of the Service correctly