Class Partnership

java.lang.Object
com.helger.as2lib.partner.Partnership
All Implemented Interfaces:
Serializable

public class Partnership extends Object implements Serializable
This class represents a single partnership. It has a unique name, a set of sender and receiver specific attributes (like AS2 ID, Email and key alias) and a set of generic attributes that are interpreted depending on the context.
Author:
Philip Helger
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getName

      @Nonnull public final String getName()
      Returns:
      The partnership name. Never null.
    • setName

      public final void setName(@Nonnull String sName)
    • setSenderID

      public void setSenderID(@Nonnull String sKey, @Nullable String sValue)
      Set an arbitrary sender ID.
      Parameters:
      sKey - The name of the ID. May not be null.
      sValue - The value to be set. It may be null in which case the attribute is removed.
    • setSenderAS2ID

      public void setSenderAS2ID(@Nullable String sValue)
      Set the senders AS2 ID.
      Parameters:
      sValue - The value to be set. May be null.
      See Also:
    • setSenderX509Alias

      public void setSenderX509Alias(@Nullable String sValue)
      Set the senders X509 alias.
      Parameters:
      sValue - The value to be set. May be null.
      See Also:
    • setSenderEmail

      public void setSenderEmail(@Nullable String sValue)
      Set the senders email address.
      Parameters:
      sValue - The value to be set. May be null.
      See Also:
    • addSenderIDs

      public void addSenderIDs(@Nullable Map<String,String> aMap)
      Add all sender IDs provided in the passed map. Existing sender IDs are not altered.
      Parameters:
      aMap - The map to use. May be null.
    • getSenderID

      @Nullable public String getSenderID(@Nullable String sKey)
      Get the value of an arbitrary sender ID
      Parameters:
      sKey - The name of the ID to query. May be null.
      Returns:
      The contained value if the name is not null and contained in the sender IDs.
    • getSenderAS2ID

      @Nullable public String getSenderAS2ID()
      Returns:
      the sender's AS2 ID or null if it is not set
      See Also:
    • getSenderX509Alias

      @Nullable public String getSenderX509Alias()
      Returns:
      the sender's X509 alias or null if it is not set
      See Also:
    • getSenderEmail

      @Nullable public String getSenderEmail()
      Returns:
      the sender's email address or null if it is not set.
      See Also:
    • containsSenderID

      public boolean containsSenderID(@Nullable String sKey)
      Check if an arbitrary sender ID is present.
      Parameters:
      sKey - The name of the ID to query. May be null.
      Returns:
      true if the name is not null and contained in the sender IDs.
    • containsSenderAS2ID

      public boolean containsSenderAS2ID()
      Returns:
      true if the sender's AS2 ID is present, false otherwise.
      See Also:
    • containsSenderX509Alias

      public boolean containsSenderX509Alias()
      Returns:
      true if the sender's X509 alias is present, false otherwise.
      See Also:
    • containsSenderEmail

      public boolean containsSenderEmail()
      Returns:
      true if the sender's email address is present, false otherwise.
      See Also:
    • getAllSenderIDs

      @Nonnull @ReturnsMutableCopy public com.helger.commons.collection.attr.IStringMap getAllSenderIDs()
      Returns:
      All sender IDs. Never null.
    • setReceiverID

      public void setReceiverID(@Nonnull String sKey, @Nullable String sValue)
      Set an arbitrary receiver ID.
      Parameters:
      sKey - The name of the ID. May not be null.
      sValue - The value to be set. It may be null in which case the attribute is removed.
    • setReceiverAS2ID

      public void setReceiverAS2ID(@Nullable String sValue)
      Set the receivers AS2 ID.
      Parameters:
      sValue - The value to be set. May be null.
      See Also:
    • setReceiverX509Alias

      public void setReceiverX509Alias(@Nullable String sValue)
      Set the receivers X509 alias.
      Parameters:
      sValue - The value to be set. May be null.
      See Also:
    • setReceiverEmail

      public void setReceiverEmail(@Nullable String sValue)
      Set the receivers email address.
      Parameters:
      sValue - The value to be set. May be null.
      See Also:
    • addReceiverIDs

      public void addReceiverIDs(@Nullable Map<String,String> aMap)
      Add all receiver IDs provided in the passed map. Existing receiver IDs are not altered.
      Parameters:
      aMap - The map to use. May be null.
    • getReceiverID

      @Nullable public String getReceiverID(@Nullable String sKey)
      Get the value of an arbitrary receiver ID
      Parameters:
      sKey - The name of the ID to query. May be null.
      Returns:
      The contained value if the name is not null and contained in the receiver IDs.
    • getReceiverAS2ID

      @Nullable public String getReceiverAS2ID()
      Returns:
      the receiver's AS2 ID or null if it is not set
      See Also:
    • getReceiverX509Alias

      @Nullable public String getReceiverX509Alias()
      Returns:
      the receiver's X509 alias or null if it is not set
      See Also:
    • getReceiverEmail

      @Nullable public String getReceiverEmail()
      Returns:
      the receiver's email address or null if it is not set.
      See Also:
    • containsReceiverID

      public boolean containsReceiverID(@Nullable String sKey)
      Check if an arbitrary receiver ID is present.
      Parameters:
      sKey - The name of the ID to query. May be null.
      Returns:
      true if the name is not null and contained in the receiver IDs.
    • containsReceiverAS2ID

      public boolean containsReceiverAS2ID()
      Returns:
      true if the receiver's AS2 ID is present, false otherwise.
      See Also:
    • containsReceiverX509Alias

      public boolean containsReceiverX509Alias()
      Returns:
      true if the receiver's X509 alias is present, false otherwise.
      See Also:
    • containsReceiverEmail

      public boolean containsReceiverEmail()
      Returns:
      true if the receiver's email address is present, false otherwise.
      See Also:
    • getAllReceiverIDs

      @Nonnull @ReturnsMutableCopy public com.helger.commons.collection.attr.IStringMap getAllReceiverIDs()
      Returns:
      All receiver IDs. Never null.
    • setAttribute

      @Nonnull public com.helger.commons.state.EChange setAttribute(@Nonnull String sKey, @Nullable String sValue)
      Set an arbitrary partnership attribute.
      Parameters:
      sKey - The key to be used. May not be null.
      sValue - The value to be used. If null an existing attribute with the provided name will be removed.
      Returns:
      EChange.CHANGED if something changed. Never null.
    • getAttribute

      @Nullable public String getAttribute(@Nullable String sKey)
      Get the value associated with the given attribute name.
      Parameters:
      sKey - Attribute name to search. May be null.
      Returns:
      null if the attribute name was null or if no such attribute is contained.
      See Also:
    • getAttribute

      @Nullable public String getAttribute(@Nullable String sKey, @Nullable String sDefault)
      Get the value associated with the given attribute name or the default values.
      Parameters:
      sKey - Attribute name to search. May be null.
      sDefault - Default value to be returned if no such attribute is present.
      Returns:
      The provided default value if the attribute name was null or if no such attribute is contained.
      See Also:
    • getAS2URL

      @Nullable public String getAS2URL()
    • setAS2URL

      @Nonnull public com.helger.commons.state.EChange setAS2URL(@Nullable String sValue)
    • getAS2MDNTo

      @Nullable public String getAS2MDNTo()
      Returns:
      The URL to send the MDN to. May be null.
      See Also:
    • setAS2MDNTo

      @Nonnull public com.helger.commons.state.EChange setAS2MDNTo(@Nullable String sValue)
      Set the URL to send the MDN to. For async MDN also call setAS2ReceiptDeliveryOption(String).
      Parameters:
      sValue - The async MDN URL. May be null.
      Returns:
      EChange.
      See Also:
    • getAS2MDNOptions

      @Nullable public String getAS2MDNOptions()
      Returns:
      The MDN options corresponding to the Disposition-Notification-Options header. May be null.
    • setAS2MDNOptions

      @Nonnull public com.helger.commons.state.EChange setAS2MDNOptions(@Nullable String sValue)
      Set the MDN options corresponding to the Disposition-Notification-Options header.
      Parameters:
      sValue - The value to be set. May be null.
      Returns:
      EChange
    • getAS2ReceiptDeliveryOption

      @Nullable public String getAS2ReceiptDeliveryOption()
      Returns:
      The return URL for async MDN when sending messages. May be null.
      Since:
      3.0.4
      See Also:
    • setAS2ReceiptDeliveryOption

      @Nonnull public com.helger.commons.state.EChange setAS2ReceiptDeliveryOption(@Nullable String sValue)
      Set the return URL for async MDNs when sending messages. When setting it, also set setAS2MDNTo(String).
      Parameters:
      sValue - The async MDN url. May be null.
      Returns:
      EChange
      Since:
      3.0.4
      See Also:
    • getMessageIDFormat

      @Nullable public String getMessageIDFormat(@Nullable String sDefault)
    • setMessageIDFormat

      @Nonnull public com.helger.commons.state.EChange setMessageIDFormat(@Nullable String sValue)
    • getMDNSubject

      @Nullable public String getMDNSubject()
    • setMDNSubject

      @Nonnull public com.helger.commons.state.EChange setMDNSubject(@Nullable String sValue)
    • isBlockErrorMDN

      public boolean isBlockErrorMDN()
    • setBlockErrorMDN

      @Nonnull public com.helger.commons.state.EChange setBlockErrorMDN(boolean bBlock)
    • getDateFormat

      @Nullable public String getDateFormat(@Nullable String sDefault)
    • setDateFormat

      @Nonnull public com.helger.commons.state.EChange setDateFormat(@Nullable String sValue)
    • getEncryptAlgorithm

      @Nullable public String getEncryptAlgorithm()
    • setEncryptAlgorithm

      @Nonnull public com.helger.commons.state.EChange setEncryptAlgorithm(@Nullable String sValue)
    • setEncryptAlgorithm

      @Nonnull public com.helger.commons.state.EChange setEncryptAlgorithm(@Nullable ECryptoAlgorithmCrypt eValue)
    • getSigningAlgorithm

      @Nullable public String getSigningAlgorithm()
    • setSigningAlgorithm

      @Nonnull public com.helger.commons.state.EChange setSigningAlgorithm(@Nullable String sValue)
    • setSigningAlgorithm

      @Nonnull public com.helger.commons.state.EChange setSigningAlgorithm(@Nullable ECryptoAlgorithmSign eValue)
    • getProtocol

      @Nullable public String getProtocol()
    • setProtocol

      @Nonnull public com.helger.commons.state.EChange setProtocol(@Nullable String sValue)
    • getSubject

      @Nullable public String getSubject()
    • setSubject

      @Nonnull public com.helger.commons.state.EChange setSubject(@Nullable String sValue)
    • getContentTransferEncodingSend

      @Nullable public String getContentTransferEncodingSend(@Nullable String sDefault)
      Get the Content-Transfer-Encoding for sending messages.
      Parameters:
      sDefault - Default to be returned if none is present. May be null.
      Returns:
      The partnership Content-Transfer-Encoding or the provided default value.
    • setContentTransferEncodingSend

      @Nonnull public com.helger.commons.state.EChange setContentTransferEncodingSend(@Nullable String sValue)
      Set the Content-Transfer-Encoding for sending messages.
      Parameters:
      sValue - The value for this partnership. May be null.
      Returns:
      EChange
    • setContentTransferEncodingSend

      @Nonnull public com.helger.commons.state.EChange setContentTransferEncodingSend(@Nullable com.helger.mail.cte.EContentTransferEncoding eCTE)
      Set the Content-Transfer-Encoding for sending messages.
      Parameters:
      eCTE - The value for this partnership. May be null.
      Returns:
      EChange
    • getContentTransferEncodingReceive

      @Nullable public String getContentTransferEncodingReceive(@Nullable String sDefault)
      Get the Content-Transfer-Encoding for receiving messages.
      Parameters:
      sDefault - Default to be returned if none is present. May be null.
      Returns:
      The partnership Content-Transfer-Encoding or the provided default value.
    • setContentTransferEncodingReceive

      @Nonnull public com.helger.commons.state.EChange setContentTransferEncodingReceive(@Nullable String sValue)
      Set the Content-Transfer-Encoding for receiving messages.
      Parameters:
      sValue - The value for this partnership. May be null.
      Returns:
      EChange
    • setContentTransferEncodingReceive

      @Nonnull public com.helger.commons.state.EChange setContentTransferEncodingReceive(@Nullable com.helger.mail.cte.EContentTransferEncoding eCTE)
      Set the Content-Transfer-Encoding for receiving messages.
      Parameters:
      eCTE - The value for this partnership. May be null.
      Returns:
      EChange
    • getCompressionType

      @Nullable public String getCompressionType()
    • setCompressionType

      @Nonnull public com.helger.commons.state.EChange setCompressionType(@Nullable String sValue)
    • setCompressionType

      @Nonnull public com.helger.commons.state.EChange setCompressionType(@Nullable ECompressionType eValue)
    • getCompressionMode

      @Nullable public String getCompressionMode()
    • setCompressionMode

      @Nonnull public com.helger.commons.state.EChange setCompressionMode(@Nullable String sValue)
    • isCompressBeforeSign

      public boolean isCompressBeforeSign()
    • setCompressionModeCompressAfterSigning

      @Nonnull public com.helger.commons.state.EChange setCompressionModeCompressAfterSigning()
    • setCompressionModeCompressBeforeSigning

      @Nonnull public com.helger.commons.state.EChange setCompressionModeCompressBeforeSigning()
    • isForceDecrypt

      public boolean isForceDecrypt()
    • setForceDecrypt

      @Nonnull public com.helger.commons.state.EChange setForceDecrypt(boolean bValue)
    • isDisableDecrypt

      public boolean isDisableDecrypt()
    • setDisableDecrypt

      @Nonnull public com.helger.commons.state.EChange setDisableDecrypt(boolean bValue)
    • isForceVerify

      public boolean isForceVerify()
    • setForceVerify

      @Nonnull public com.helger.commons.state.EChange setForceVerify(boolean bValue)
    • isDisableVerify

      public boolean isDisableVerify()
    • setDisableVerify

      @Nonnull public com.helger.commons.state.EChange setDisableVerify(boolean bValue)
    • getIncludeCertificateInSignedContent

      @Nonnull public com.helger.commons.state.ETriState getIncludeCertificateInSignedContent()
    • setIncludeCertificateInSignedContent

      @Nonnull public com.helger.commons.state.EChange setIncludeCertificateInSignedContent(@Nonnull com.helger.commons.state.ETriState eValue)
    • getVerifyUseCertificateInBodyPart

      @Nonnull public com.helger.commons.state.ETriState getVerifyUseCertificateInBodyPart()
    • setVerifyUseCertificateInBodyPart

      @Nonnull public com.helger.commons.state.EChange setVerifyUseCertificateInBodyPart(@Nonnull com.helger.commons.state.ETriState eValue)
    • isDisableDecompress

      public boolean isDisableDecompress()
    • setDisableDecompress

      @Nonnull public com.helger.commons.state.EChange setDisableDecompress(boolean bValue)
    • isRFC3851MICAlgs

      public boolean isRFC3851MICAlgs()
      Returns:
      true if the "old" RFC 3851 MIC algorithm names (e.g. sha1) should be used, false if the new RFC 5751 MIC algorithm names (e.g. sha-1) should be used. Default is false.
      Since:
      2.2.7
    • setRFC3851MICAlgs

      @Nonnull public com.helger.commons.state.EChange setRFC3851MICAlgs(boolean bValue)
      Enable or disable the usage of the old RFC 3851 MIC algorithm names. By default this is false.
      Parameters:
      bValue - true if the "old" RFC 3851 MIC algorithm names (e.g. sha1) should be used, false if the new RFC 5751 MIC algorithm names (e.g. sha-1) should be used. Default is false.
      Returns:
      EChange.
      Since:
      2.2.7
    • isRemoveCmsAlgorithmProtect

      public boolean isRemoveCmsAlgorithmProtect()
      Returns:
      if true, the CMS attribute "AlgorithmProtect" will be removed. This is needed in compatibility with e.g. IBM Sterling. Default value is false. See Issue #137.
      Since:
      4.10.1
    • setRemoveCmsAlgorithmProtect

      @Nonnull public com.helger.commons.state.EChange setRemoveCmsAlgorithmProtect(boolean bValue)
      Enable or disable the removal of the CMS attribute "AlgorithmProtect". By default this is false. This is needed in compatibility with e.g. IBM Sterling. Default value is false. See Issue #137.
      Parameters:
      bValue - true to remove the attribute, false to keep it.
      Returns:
      EChange.
      Since:
      4.10.1
    • getAllAttributes

      @Nonnull @ReturnsMutableCopy public com.helger.commons.collection.attr.IStringMap getAllAttributes()
      Returns:
      A copy of all contained attributes. Never null.
    • addAllAttributes

      public void addAllAttributes(@Nullable Map<String,String> aAttributes)
      Add all provided attributes. existing attributes are not altered.
      Parameters:
      aAttributes - The attributes to be added. May be null. If a null value is contained in the map, the respective attribute will be removed.
    • matches

      public boolean matches(@Nonnull Partnership aPartnership)
      Check if sender and receiver IDs of this partnership match the ones of the provided partnership.
      Parameters:
      aPartnership - The partnership to compare to. May not be null.
      Returns:
      true if sender and receiver IDs of this partnership are present in the sender and receiver IDs of the provided partnership.
    • compareIDs

      protected boolean compareIDs(@Nonnull com.helger.commons.collection.attr.IStringMap aIDs, @Nonnull com.helger.commons.collection.attr.IStringMap aCompareTo)
      Check if all values from the left side are also present on the right side.
      Parameters:
      aIDs - The source map which must be fully contained in the aCompareTo map
      aCompareTo - The map to compare to. May not be null. It may contain more attributes than aIDs but must at least contain the same ones.
      Returns:
      true if aIDs is not empty and all values from aIDs are also present in aCompareTo, false otherwise.
    • copyFrom

      public void copyFrom(@Nonnull Partnership aPartnership)
      Set all fields of this partnership with the data from the provided partnership. Name, sender IDs, receiver IDs and attributes are fully overwritten!
      Parameters:
      aPartnership - The partnership to copy the data from. May not be null.
    • toString

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

      @Nonnull public static Partnership createPlaceholderPartnership()