Class AS4CryptoFactoryProperties

java.lang.Object
com.helger.phase4.crypto.AS4CryptoFactoryProperties
All Implemented Interfaces:
IAS4CryptoFactory

@Immutable public class AS4CryptoFactoryProperties extends Object implements IAS4CryptoFactory
phase4 crypto factory settings based on AS4CryptoProperties
Since:
0.11.0
Author:
Philip Helger+
  • Constructor Details

    • AS4CryptoFactoryProperties

      public AS4CryptoFactoryProperties(@Nonnull AS4CryptoProperties aCryptoProps)
      This constructor takes the crypto properties directly. See the AbstractAS4Client for a usage example.
      Parameters:
      aCryptoProps - The properties to be used. May not be null. Note: the object is cloned internally to avoid outside modification.
  • Method Details

    • getDefaultInstance

      @Nonnull public static AS4CryptoFactoryProperties getDefaultInstance()
      Returns:
      The default instance, created by reading the properties from the configuration sources.
      Since:
      0.11.0
    • cryptoProperties

      @Nonnull @ReturnsMutableObject public final AS4CryptoProperties cryptoProperties()
      Returns:
      The crypto properties as created in the constructor. Never null.
    • createCrypto

      @Nonnull public static org.apache.wss4j.common.crypto.Crypto createCrypto(@Nonnull AS4CryptoProperties aCryptoProps)
      Helper method to create a WSS4J Crypto instance based on the provided crypto properties.
      Parameters:
      aCryptoProps - The crypto properties to use. May not be null.
      Returns:
      A new Crypto object.
      Throws:
      IllegalStateException - if creation failed
    • getCrypto

      @Nonnull public final org.apache.wss4j.common.crypto.Crypto getCrypto()
      Lazily create a Crypto instance using the properties from cryptoProperties().
      Specified by:
      getCrypto in interface IAS4CryptoFactory
      Returns:
      A Crypto instance and never null.
    • getKeyStore

      @Nullable public final KeyStore getKeyStore()
      Specified by:
      getKeyStore in interface IAS4CryptoFactory
      Returns:
      The underlying key store, or null if none is available (the reasons depend on the used implementation).
    • getPrivateKeyEntry

      @Nullable public final KeyStore.PrivateKeyEntry getPrivateKeyEntry()
      Specified by:
      getPrivateKeyEntry in interface IAS4CryptoFactory
      Returns:
      The underlying private key entry from the keystore or null if none is available (the reasons depend on the used implementation).
    • getKeyAlias

      @Nullable public final String getKeyAlias()
      Specified by:
      getKeyAlias in interface IAS4CryptoFactory
      Returns:
      The keystore alias to resolve the private key entry. May be null.
    • getKeyPassword

      @Nullable public final String getKeyPassword()
      Specified by:
      getKeyPassword in interface IAS4CryptoFactory
      Returns:
      The password to access the private key entry denoted by the key alias. May be null.
    • getCertificate

      @Nullable public final X509Certificate getCertificate()
      Returns:
      The public certificate of the private key entry or null if the private key entry could not be loaded.
      See Also:
    • getTrustStore

      @Nullable public final KeyStore getTrustStore()
      Specified by:
      getTrustStore in interface IAS4CryptoFactory
      Returns:
      The trust store to be used or null if none is configured.
    • isAllowRSA15KeyTransportAlgorithm

      public boolean isAllowRSA15KeyTransportAlgorithm()
      Specified by:
      isAllowRSA15KeyTransportAlgorithm in interface IAS4CryptoFactory
      Returns:
      Whether to allow the RSA v1.5 Key Transport Algorithm or not. Default is false.
    • readCryptoPropertiesFromFile

      @Nonnull public static AS4CryptoProperties readCryptoPropertiesFromFile(@Nullable String sCryptoPropertiesPath)
      Read crypto properties from the specified file path.
      Parameters:
      sCryptoPropertiesPath - The class path to read the properties file from. It is null or empty, than the default file "crypto.properties" is read.
      Returns:
      Never null.