Class AS4CryptoFactoryInMemoryKeyStore

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

@Immutable public class AS4CryptoFactoryInMemoryKeyStore extends Object implements IAS4CryptoFactory
This class contains an implementation of IAS4CryptoFactory in which case the KeyStore is available in memory and the settings are NOT read from a file. Created for https://github.com/phax/phase4/issues/28
Since:
0.9.7
Author:
Philip Helger
  • Constructor Details

    • AS4CryptoFactoryInMemoryKeyStore

      public AS4CryptoFactoryInMemoryKeyStore(@Nonnull KeyStore aKeyStore, @Nonnull @Nonempty String sKeyAlias, @Nonnull String sKeyPassword, @Nullable KeyStore aTrustStore)
      Default constructor.
      Parameters:
      aKeyStore - The key store to be used. May not be null.
      sKeyAlias - The key alias to be used. May neither be null nor empty.
      sKeyPassword - The key password to be used. May not be null but maybe empty.
      aTrustStore - The optional trust store to be used. If none is provided the default Java runtime truststore (cacerts) is used.
  • Method Details

    • getCrypto

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

      @Nonnull 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

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

      @Nonnull 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.
    • 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.