Class AS4CryptParams

java.lang.Object
com.helger.phase4.crypto.AS4CryptParams
All Implemented Interfaces:
com.helger.commons.lang.ICloneable<AS4CryptParams>

@NotThreadSafe public class AS4CryptParams extends Object implements com.helger.commons.lang.ICloneable<AS4CryptParams>
AS4 encrypt/decrypt parameters
Since:
0.9.0
Author:
Philip Helger, Gregor Scholtysik
  • Field Details

  • Constructor Details

  • Method Details

    • isCryptEnabled

      public boolean isCryptEnabled(@Nullable Consumer<String> aWarningConsumer)
    • getKeyIdentifierType

      @Nonnull public final ECryptoKeyIdentifierType getKeyIdentifierType()
      Returns:
      The key identifier type. May not be null.
      Since:
      0.11.0
    • setKeyIdentifierType

      @Nonnull public final AS4CryptParams setKeyIdentifierType(@Nonnull ECryptoKeyIdentifierType eKeyIdentifierType)
      Set the key identifier type to use. That defines how the information about the signing certificate is transmitted.
      Parameters:
      eKeyIdentifierType - The key identifier type to use. May not be null.
      Returns:
      this for chaining
      Since:
      0.11.0
    • getAlgorithmCrypt

      @Nullable public final ECryptoAlgorithmCrypt getAlgorithmCrypt()
      Returns:
      The encryption algorithm to use. May be null.
    • setAlgorithmCrypt

      @Nonnull public final AS4CryptParams setAlgorithmCrypt(@Nullable ECryptoAlgorithmCrypt eAlgorithmCrypt)
      A encryption algorithm can be set.
      MANDATORY if you want to use encryption.
      Parameters:
      eAlgorithmCrypt - the encryption algorithm that should be set
      Returns:
      this for chaining
    • getKeyEncAlgorithm

      @Nonnull public final ECryptoKeyEncryptionAlgorithm getKeyEncAlgorithm()
    • setKeyEncAlgorithm

      @Nonnull public final AS4CryptParams setKeyEncAlgorithm(@Nonnull ECryptoKeyEncryptionAlgorithm eKeyEncAlgorithm)
    • getMGFAlgorithm

      @Nonnull @Nonempty public final String getMGFAlgorithm()
      Returns:
      The mask generation function (MGF) algorithm to use with the RSA-OAEP key transport algorithm. The default is DEFAULT_MGF_ALGORITHM
    • setMGFAlgorithm

      @Nonnull public final AS4CryptParams setMGFAlgorithm(@Nonnull @Nonempty String sMGFAlgorithm)
      Set the mask generation function (MGF) algorithm to use with the RSA-OAEP key transport algorithm.
      Parameters:
      sMGFAlgorithm - The MFG algorithm to use. May neither be null nor empty.
      Returns:
      this for chaining
    • getDigestAlgorithm

      @Nonnull @Nonempty public final String getDigestAlgorithm()
      Returns:
      The digest algorithm to use with the RSA-OAEP key transport algorithm. The default is DEFAULT_DIGEST_ALGORITHM
    • setDigestAlgorithm

      @Nonnull public final AS4CryptParams setDigestAlgorithm(@Nonnull @Nonempty String sDigestAlgorithm)
      Set the digest algorithm to use with the RSA-OAEP key transport algorithm.
      Parameters:
      sDigestAlgorithm - The digest algorithm to use. May neither be null nor empty.
      Returns:
      this for chaining
    • getCertificate

      @Nullable public final X509Certificate getCertificate()
      Returns:
      The currently set X509 certificate. May be null.
    • hasCertificate

      public final boolean hasCertificate()
      Returns:
      true if an X509 certificate is present, false if not.
    • setCertificate

      @Nonnull public final AS4CryptParams setCertificate(@Nullable X509Certificate aCert)
      Set the X509 certificate be used. The provided certificate is not checked for validity. If it is expired only a warning is logged but the certificate will still be used.
      Parameters:
      aCert - The certificate to be used. May be null.
      Returns:
      this for chaining
    • getAlias

      @Nullable public final String getAlias()
    • hasAlias

      public final boolean hasAlias()
    • setAlias

      @Nonnull public final AS4CryptParams setAlias(@Nullable String sAlias)
    • getSessionKeyProvider

      @Nonnull public final ICryptoSessionKeyProvider getSessionKeyProvider()
      Returns:
      The session key provider to be used. Never null.
      Since:
      2.1.2
    • setSessionKeyProvider

      @Nonnull public final AS4CryptParams setSessionKeyProvider(@Nonnull ICryptoSessionKeyProvider aSessionKeyProvider)
      Set the session key provider to be used for encryption. The provided provider must never return a null key.
      Parameters:
      aSessionKeyProvider - The session key provider to be used. May not be null.
      Returns:
      this for chaining
      Since:
      2.1.2
    • getSecurityProviderEncrypt

      @Nullable public final Provider getSecurityProviderEncrypt()
      Note: this is currently not used by WSS4J
      Returns:
      The security provider to be used for encryption (not for decryption). May be null.
      Since:
      2.4.0
    • setSecurityProviderEncrypt

      @Nonnull public final AS4CryptParams setSecurityProviderEncrypt(@Nullable Provider aSecurityProviderEncrypt)
      Set the security provider to be used for encryption (not for decryption).
      Note: this is currently not used by WSS4J
      Parameters:
      aSecurityProviderEncrypt - The security provider to be used. May be null.
      Returns:
      this for chaining
      Since:
      2.4.0
    • getSecurityProviderDecrypt

      @Nullable public final Provider getSecurityProviderDecrypt()
      Note: this is currently not used by WSS4J
      Returns:
      The security provider to be used for decryption (not for encryption). May be null.
      Since:
      2.4.0
    • setSecurityProviderDecrypt

      @Nonnull public final AS4CryptParams setSecurityProviderDecrypt(@Nullable Provider aSecurityProviderDecrypt)
      Set the security provider to be used for decryption (not for encryption).
      Note: this is currently not used by WSS4J
      Parameters:
      aSecurityProviderDecrypt - The security provider to be used. May be null.
      Returns:
      this for chaining
      Since:
      2.4.0
    • setSecurityProvider

      @Nonnull public final AS4CryptParams setSecurityProvider(@Nullable Provider aSecurityProvider)
      Set the security provider to be used for encryption and decryption.
      Parameters:
      aSecurityProvider - The security provider to be used. May be null.
      Returns:
      this for chaining
      Since:
      2.1.4
    • isEncryptSymmetricSessionKey

      public final boolean isEncryptSymmetricSessionKey()
      Returns:
      true if the symmetric session key should be part of the transmission or false if not. Default is DEFAULT_ENCRYPT_SYMMETRIC_SESSION_KEY
      Since:
      2.1.4
    • setEncryptSymmetricSessionKey

      @Nonnull public final AS4CryptParams setEncryptSymmetricSessionKey(boolean b)
      Enable or disable the inclusion of the symmetric session key into the transmission or not.
      Parameters:
      b - true to enabled, false to disable it.
      Returns:
      this for chaining
      Since:
      2.1.4
    • getWSSecEncryptCustomizer

      @Nullable public final IWSSecEncryptCustomizer getWSSecEncryptCustomizer()
    • hasWSSecEncryptCustomizer

      public final boolean hasWSSecEncryptCustomizer()
    • setWSSecEncryptCustomizer

      @Nonnull public final AS4CryptParams setWSSecEncryptCustomizer(@Nullable IWSSecEncryptCustomizer a)
    • setFromPMode

      @Nonnull public final AS4CryptParams setFromPMode(@Nullable PModeLegSecurity aSecurity)
      This method calls setAlgorithmCrypt(ECryptoAlgorithmCrypt) based on the PMode parameters. If the PMode parameter is null the value will be set to null.
      Parameters:
      aSecurity - The PMode security stuff to use. May be null.
      Returns:
      this for chaining
      See Also:
    • cloneTo

    • getClone

      @Nonnull @ReturnsMutableCopy public AS4CryptParams getClone()
      Specified by:
      getClone in interface com.helger.commons.lang.ICloneable<AS4CryptParams>
    • toString

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

      @Nonnull @ReturnsMutableObject public static AS4CryptParams createDefault()
      Returns:
      A non-null default instance.
      See Also: