Class AS4IncomingMessageMetadata

java.lang.Object
com.helger.phase4.incoming.AS4IncomingMessageMetadata
All Implemented Interfaces:
IAS4IncomingMessageMetadata

public class AS4IncomingMessageMetadata extends Object implements IAS4IncomingMessageMetadata
This class holds optional metadata for a single incoming request. This is the default implementation of IAS4IncomingMessageMetadata.
Since:
0.9.8
Author:
Philip Helger
  • Constructor Details

    • AS4IncomingMessageMetadata

      protected AS4IncomingMessageMetadata(@NonNull EAS4MessageMode eMode)
      Default constructor using a UUID as the incoming unique ID and the current date time.
      Parameters:
      eMode - The messaging mode. May not be null.
      See Also:
    • AS4IncomingMessageMetadata

      protected AS4IncomingMessageMetadata(@Nonempty @NonNull @Nonempty String sIncomingUniqueID, @NonNull OffsetDateTime aIncomingDT, @NonNull EAS4MessageMode eMode)
      Constructor in case this every needs to be deserialized or other weird things are necessary.
      Parameters:
      sIncomingUniqueID - Incoming unique ID. May neither be null nor empty.
      aIncomingDT - The incoming date time. May not be null.
      eMode - The messaging mode. May not be null.
  • Method Details

    • createNewIncomingUniqueID

      @Nonempty public static @NonNull @Nonempty String createNewIncomingUniqueID()
      Returns:
      A new unique incoming ID. Neither null nor empty.
      Since:
      4.2.5
    • getIncomingUniqueID

      @Nonempty public final @NonNull @Nonempty String getIncomingUniqueID()
      Specified by:
      getIncomingUniqueID in interface IAS4IncomingMessageMetadata
      Returns:
      A unique ID created just for this message metadata. It can be used to reference to this message internally. Usually this is a UUID. This is different from the AS4 message ID, because in case of a corrupted message, the AS4 message ID may be missing or misplaced. Never null nor empty.
    • setIncomingUniqueID

      public @NonNull AS4IncomingMessageMetadata setIncomingUniqueID(@Nonempty @NonNull @Nonempty String sIncomingUniqueID)
      Set the incoming unique ID to be used.
      Parameters:
      sIncomingUniqueID - The incoming unique ID to use. May neither be null nor empty.
      Returns:
      this for chaining
      Since:
      4.2.5
    • getIncomingDT

      public final @NonNull OffsetDateTime getIncomingDT()
      Specified by:
      getIncomingDT in interface IAS4IncomingMessageMetadata
      Returns:
      The date and time when the request was received. Never null.
    • getMode

      public final @NonNull EAS4MessageMode getMode()
      Specified by:
      getMode in interface IAS4IncomingMessageMetadata
      Returns:
      The message mode. May be null.
    • getRemoteAddr

      public @Nullable String getRemoteAddr()
      Description copied from interface: IAS4IncomingMessageMetadata
      Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
      Specified by:
      getRemoteAddr in interface IAS4IncomingMessageMetadata
      Returns:
      a String containing the IP address of the client that sent the request
    • setRemoteAddr

      public @NonNull AS4IncomingMessageMetadata setRemoteAddr(@Nullable String sRemoteAddr)
      Set the remote address to be used.
      Parameters:
      sRemoteAddr - The remote address. May be null.
      Returns:
      this for chaining
    • getRemoteHost

      public @Nullable String getRemoteHost()
      Description copied from interface: IAS4IncomingMessageMetadata
      Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address.
      Specified by:
      getRemoteHost in interface IAS4IncomingMessageMetadata
      Returns:
      a String containing the fully qualified name of the client
    • setRemoteHost

      public @NonNull AS4IncomingMessageMetadata setRemoteHost(@Nullable String sRemoteHost)
      Set the remote host to be used.
      Parameters:
      sRemoteHost - The remote host. May be null.
      Returns:
      this for chaining
    • getRemotePort

      @CheckForSigned public int getRemotePort()
      Description copied from interface: IAS4IncomingMessageMetadata
      Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
      Specified by:
      getRemotePort in interface IAS4IncomingMessageMetadata
      Returns:
      an integer specifying the port number or a negative value if not set
    • setRemotePort

      public @NonNull AS4IncomingMessageMetadata setRemotePort(int nRemotePort)
      Set the remote port to be used.
      Parameters:
      nRemotePort - The remote port.
      Returns:
      this for chaining
    • getRemoteUser

      public @Nullable String getRemoteUser()
      Description copied from interface: IAS4IncomingMessageMetadata
      Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication.
      Specified by:
      getRemoteUser in interface IAS4IncomingMessageMetadata
      Returns:
      a String specifying the login of the user making this request, or null if the user login is not known
    • setRemoteUser

      public @NonNull AS4IncomingMessageMetadata setRemoteUser(@Nullable String sRemoteUser)
      Set the remote user to be used.
      Parameters:
      sRemoteUser - The remote user. May be null.
      Returns:
      this for chaining
    • remoteTlsClientCerts

      @ReturnsMutableObject public @Nullable com.helger.collection.commons.ICommonsList<X509Certificate> remoteTlsClientCerts()
      Description copied from interface: IAS4IncomingMessageMetadata
      Returns the TLS certificates presented by the remote client to authenticate itself.
      Specified by:
      remoteTlsClientCerts in interface IAS4IncomingMessageMetadata
      Returns:
      A list containing a chain of X509Certificate objects. Maybe null.
    • setRemoteTlsCerts

      @Deprecated(forRemoval=true, since="4.5.1") public @NonNull AS4IncomingMessageMetadata setRemoteTlsCerts(@Nullable X509Certificate[] aRemoteTlsCerts)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the remote TLS certificates to be used.
      Parameters:
      aRemoteTlsCerts - The TLS certificates the remote client presented during the handshake. May be null.
      Returns:
      this for chaining
      Since:
      2.5.0
    • setRemoteTlsClientCerts

      public @NonNull AS4IncomingMessageMetadata setRemoteTlsClientCerts(@Nullable X509Certificate[] aRemoteTlsCerts)
      Set the remote TLS certificates to be used.
      Parameters:
      aRemoteTlsCerts - The TLS certificates the remote client presented during the handshake. May be null.
      Returns:
      this for chaining
      Since:
      2.5.0
    • remoteTlsPeerCerts

      @ReturnsMutableObject public @Nullable com.helger.collection.commons.ICommonsList<X509Certificate> remoteTlsPeerCerts()
      Description copied from interface: IAS4IncomingMessageMetadata
      Returns the TLS certificates presented by the remote peer to authenticate itself.
      Specified by:
      remoteTlsPeerCerts in interface IAS4IncomingMessageMetadata
      Returns:
      A list containing a chain of X509Certificate objects. Maybe null.
    • setRemoteTlsPeerCerts

      public @NonNull AS4IncomingMessageMetadata setRemoteTlsPeerCerts(@Nullable com.helger.collection.commons.ICommonsList<X509Certificate> aRemoteTlsPeerCerts)
      Set the remote TLS certificates to be used.
      Parameters:
      aRemoteTlsPeerCerts - The TLS certificates the remote peer presented during the handshake. May be null.
      Returns:
      this for chaining
      Since:
      4.5.1
    • cookies

      @ReturnsMutableObject public @NonNull com.helger.collection.commons.ICommonsList<jakarta.servlet.http.Cookie> cookies()
      Specified by:
      cookies in interface IAS4IncomingMessageMetadata
      Returns:
      A list of all Cookies contained in the request. Never null but maybe empty. The returned list is mutable so handle with care.
    • setCookies

      public @NonNull AS4IncomingMessageMetadata setCookies(@Nullable jakarta.servlet.http.Cookie[] aCookies)
      Set the cookies to be used.
      Parameters:
      aCookies - The cookie array. May be null.
      Returns:
      this for chaining
    • getAllHttpHeaders

      @ReturnsMutableCopy public @NonNull com.helger.http.header.HttpHeaderMap getAllHttpHeaders()
      Specified by:
      getAllHttpHeaders in interface IAS4IncomingMessageMetadata
      Returns:
      A copy of all the HTTP headers from the incoming request. Never null but maybe empty.
    • setHttpHeaders

      public @NonNull AS4IncomingMessageMetadata setHttpHeaders(@Nullable com.helger.http.header.HttpHeaderMap aHttpHeaderMap)
    • getRequestMessageID

      public @Nullable String getRequestMessageID()
      Specified by:
      getRequestMessageID in interface IAS4IncomingMessageMetadata
      Returns:
      The AS4 message ID of the request message. This field is always null for a request. This field is always non-null for a response.
      See Also:
    • setRequestMessageID

      public @NonNull AS4IncomingMessageMetadata setRequestMessageID(@Nullable String sRequestMessageID)
      Set the request AS4 message ID to be used. This field should only be set by responses. Usually you don't have to call this setter, as this is done by the factory method createForResponse(String).
      Parameters:
      sRequestMessageID - The request message ID to be used. May be null.
      Returns:
      this for chaining
      Since:
      1.4.2
    • getResponseHttpStatusCode

      @CheckForSigned public int getResponseHttpStatusCode()
      Specified by:
      getResponseHttpStatusCode in interface IAS4IncomingMessageMetadata
      Returns:
      The HTTP status code to be returned. All values ≤ 0 means: undefined.
    • hasResponseHttpStatusCode

      public boolean hasResponseHttpStatusCode()
      Specified by:
      hasResponseHttpStatusCode in interface IAS4IncomingMessageMetadata
      Returns:
      true if a defined HTTP status code is present, false otherwise.
    • setResponseHttpStatusCode

      public @NonNull AS4IncomingMessageMetadata setResponseHttpStatusCode(int nHttpStatusCode)
      Set the response HTTP Status code to be used. This is only called for RESPONSE mode messages.
      Parameters:
      nHttpStatusCode - The HTTP status code to be used. Any value ≤ 0 means to use the default.
      Returns:
      this for chaining
      Since:
      4.2.0
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createForRequest

      public static @NonNull AS4IncomingMessageMetadata createForRequest()
    • createForResponse

      public static @NonNull AS4IncomingMessageMetadata createForResponse(@Nonempty @NonNull @Nonempty String sRequestMessageID)