Class AS2Client


  • public class AS2Client
    extends Object
    A simple client that allows for sending AS2 Messages and retrieving of synchronous MDNs.
    Author:
    Philip Helger
    • Constructor Detail

      • AS2Client

        public AS2Client()
    • Method Detail

      • setAS2SenderModuleFactory

        @Nonnull
        public AS2Client setAS2SenderModuleFactory​(@Nonnull
                                                   Supplier<AS2SenderModule> aAS2SenderModuleFactory)
        Set the factory to create AS2SenderModule objects internally. By default a new instance of AS2SenderModule is created so you don't need to call this method.
        Parameters:
        aAS2SenderModuleFactory - The factory to be used. May not be null.
        Returns:
        this for chaining
      • getHttpProxy

        @Nullable
        public Proxy getHttpProxy()
        Returns:
        The current HTTP proxy used. Defaults to null.
      • setHttpProxy

        @Nonnull
        public AS2Client setHttpProxy​(@Nullable
                                      Proxy aHttpProxy)
        Set the proxy server for transmission.
        Parameters:
        aHttpProxy - The proxy to use. May be null to indicate no proxy.
        Returns:
        this for chaining
      • createAS2MessageObj

        @Nonnull
        @OverrideOnDemand
        protected AS2Message createAS2MessageObj()
      • createCertificateFactory

        @Nonnull
        @OverrideOnDemand
        protected CertificateFactory createCertificateFactory()
        Returns:
        The certificate factory instance to be used. May not be null.
      • initCertificateFactory

        @OverrideOnDemand
        protected void initCertificateFactory​(@Nonnull
                                              AS2ClientSettings aSettings,
                                              @Nonnull
                                              AS2Session aSession)
                                       throws AS2Exception
        This method initializes the certificate factory. If you override this method, please make sure that you call aSession.setCertificateFactory (aCertFactory);.
        Parameters:
        aSettings - The AS2 client settings. Never null.
        aSession - The AS2 session to be initialized. Never null.
        Throws:
        AS2Exception - In case of error
      • initPartnershipFactory

        @OverrideOnDemand
        protected void initPartnershipFactory​(@Nonnull
                                              AS2Session aSession)
                                       throws AS2Exception
        Init the partnership factory. If you override this method, please make sure that you call aSession.setPartnershipFactory (aPartnershipFactory);.
        Parameters:
        aSession - The AS2 session to be filled. Never null.
        Throws:
        AS2Exception - In case of error
      • initMessageProcessor

        @OverrideOnDemand
        protected void initMessageProcessor​(@Nonnull
                                            AS2Session aSession)
                                     throws AS2Exception
        Init the message processor. If you override this method, please make sure that you call aSession.setMessageProcessor (aMessageProcessor);.
        Parameters:
        aSession - The AS2 session to be filled. Never null.
        Throws:
        AS2Exception - In case of error
      • createResponse

        @Nonnull
        @OverrideOnDemand
        protected AS2ClientResponse createResponse()
        Create an empty response object that is to be filled.
        Returns:
        The empty response object and never null.
      • createSession

        @Nonnull
        @OverrideOnDemand
        protected AS2Session createSession()
        Create the AS2 session to be used. This method must ensure an eventually needed proxy is set.
        Returns:
        The new AS2 session and never null.
      • beforeSend

        @OverrideOnDemand
        protected void beforeSend​(@Nonnull
                                  AS2ClientSettings aSettings,
                                  @Nonnull
                                  AS2Session aSession,
                                  @Nonnull
                                  IMessage aMsg)
        Callback method that is invoked before the main sending. This may be used to customize the message.
        Parameters:
        aSettings - Client settings. Never null.
        aSession - Current session. Never null.
        aMsg - Current message. Never null.