Class ComponentManager

java.lang.Object
com.sshtools.common.ssh.components.ComponentManager
Direct Known Subclasses:
JCEComponentManager

public abstract class ComponentManager extends Object

An abstract class that manages the components used by the SSH API. All algorithm implementations are obtained through a single provider. One concrete implementation is provided, the JCEComponentManager that uses the Java runtime JCE provider(s) algorithm implementations.

Author:
Lee David Painter
  • Field Details

  • Constructor Details

    • ComponentManager

      protected ComponentManager()
  • Method Details

    • disableAlgorithm

      public void disableAlgorithm(String algorithm)
    • isDisabled

      public boolean isDisabled(String algorithm)
    • enableAlgorithm

      public void enableAlgorithm(String algorithm)
    • isEnableNoneCipher

      public static boolean isEnableNoneCipher()
    • setEnableNoneCipher

      public static void setEnableNoneCipher(boolean enableNoneCipher)
    • isEnableNoneMac

      public static boolean isEnableNoneMac()
    • setEnableNoneMac

      public static void setEnableNoneMac(boolean enableNoneCipher)
    • isDefaultEnabled

      public static <C extends Component> Optional<Boolean> isDefaultEnabled(Class<C> factoryType, String key)
    • setDefaultEnabled

      public static <C extends Component> void setDefaultEnabled(Class<C> componentType, String key, boolean enabled)
    • getInstance

      public static ComponentManager getInstance()
      Get the installed component manager. Don't want to initialize this at class load time, so use a singleton instead. Initialized on the first call to getInstance.
      Returns:
      ComponentManager
    • getDefaultInstance

      public static ComponentManager getDefaultInstance()
    • reset

      public static void reset()
    • getClassLoader

      public abstract ClassLoader getClassLoader()
    • loadComponents

      public <C extends Component, F extends ComponentInstanceFactory<C>> Iterable<F> loadComponents(Class<C> componentType, Class<F> factoryClass)
    • isEnabled

      public <C extends Component> boolean isEnabled(ComponentInstanceFactory<C> cls, Class<C> type, String name)
    • init

      protected void init() throws SshException
      Throws:
      SshException
    • initializeSsh2CipherFactory

      protected abstract void initializeSsh2CipherFactory(ComponentFactory<SshCipher> ciphers)
      Initialize the SSH2 cipher factory. These ciphers are exclusively used by the SSH2 implementation.
      Parameters:
      ciphers -
    • initializeHmacFactory

      protected abstract void initializeHmacFactory(ComponentFactory<SshHmac> hmacs)
      Initialize the SSH2 HMAC factory.
      Parameters:
      hmacs -
    • initializePublicKeyFactory

      protected abstract void initializePublicKeyFactory(ComponentFactory<SshPublicKey> publickeys)
      Initialize the public key factory.
      Parameters:
      publickeys -
    • initializeDigestFactory

      protected abstract void initializeDigestFactory(ComponentFactory<Digest> digests)
      Initialize the digest factory.
      Parameters:
      digests -
    • setInstance

      public static void setInstance(ComponentManager instance)
      Overide the installed component manager with an alternative implementation.
      Parameters:
      instance -
    • supportedSsh2CiphersSC

      public ComponentFactory<SshCipher> supportedSsh2CiphersSC()
      The supported SSH2 ciphers.
      Returns:
      AbstractComponentFactory
    • supportedSsh2CiphersCS

      public ComponentFactory<SshCipher> supportedSsh2CiphersCS()
      The supported SSH2 ciphers.
      Returns:
      AbstractComponentFactory
    • supportedHMacsSC

      public ComponentFactory<SshHmac> supportedHMacsSC()
      The supported SSH2 Hmacs.
      Returns:
      AbstractComponentFactory
    • supportedHMacsCS

      public ComponentFactory<SshHmac> supportedHMacsCS()
      The supported SSH2 Hmacs.
      Returns:
      AbstractComponentFactory
    • supportedPublicKeys

      public ComponentFactory<SshPublicKey> supportedPublicKeys()
      The supported public keys
      Returns:
      AbstractComponentFactory
    • supportedDigests

      public ComponentFactory<Digest> supportedDigests()
      The supported digests
      Returns:
      AbstractComponentFactory
    • generateRsaKeyPair

      public abstract SshKeyPair generateRsaKeyPair(int bits, int version) throws SshException
      Generate an RSA public/private pair.
      Parameters:
      bits -
      version -
      Returns:
      SshKeyPair
      Throws:
      SshException
    • generateEcdsaKeyPair

      public abstract SshKeyPair generateEcdsaKeyPair(int bits) throws SshException
      Generate a new ECDSA key pair.
      Parameters:
      bits -
      Returns:
      Throws:
      SshException
    • generateEd448KeyPair

      public abstract SshKeyPair generateEd448KeyPair() throws SshException
      Throws:
      SshException
    • generateEd25519KeyPair

      public abstract SshKeyPair generateEd25519KeyPair() throws SshException
      Throws:
      SshException
    • createRsaPublicKey

      public abstract SshRsaPublicKey createRsaPublicKey(BigInteger modulus, BigInteger publicExponent) throws SshException
      Create an instance of an RSA public key.
      Parameters:
      modulus -
      publicExponent -
      version -
      Returns:
      SshRsaPublicKey
      Throws:
      SshException
    • createSsh2RsaPublicKey

      public abstract SshRsaPublicKey createSsh2RsaPublicKey() throws SshException
      Create an instance of an SSH2 RSA public key.
      Returns:
      SshRsaPublicKey
      Throws:
      SshException
    • createRsaPrivateKey

      public abstract SshRsaPrivateKey createRsaPrivateKey(BigInteger modulus, BigInteger privateExponent) throws SshException
      Create an instance of an RSA private key.
      Parameters:
      modulus -
      privateExponent -
      Returns:
      SshRsaPrivateKey
      Throws:
      SshException
    • createRsaPrivateCrtKey

      public abstract SshRsaPrivateCrtKey createRsaPrivateCrtKey(BigInteger modulus, BigInteger publicExponent, BigInteger privateExponent, BigInteger primeP, BigInteger primeQ, BigInteger crtCoefficient) throws SshException
      Create an instance of an RSA co-effecient private key.
      Parameters:
      modulus -
      publicExponent -
      privateExponent -
      primeP -
      primeQ -
      crtCoefficient -
      Returns:
      SshRsaPrivateCrtKey
      Throws:
      SshException
    • createRsaPrivateCrtKey

      public abstract SshRsaPrivateCrtKey createRsaPrivateCrtKey(BigInteger modulus, BigInteger publicExponent, BigInteger privateExponent, BigInteger primeP, BigInteger primeQ, BigInteger primeExponentP, BigInteger primeExponentQ, BigInteger crtCoefficient) throws SshException
      Create an instance of an RSA co-efficent private key.
      Parameters:
      modulus -
      publicExponent -
      privateExponent -
      primeP -
      primeQ -
      primeExponentP -
      primeExponentQ -
      crtCoefficient -
      Returns:
      SshRsaPrivateCrtKey
      Throws:
      SshException
    • generateDsaKeyPair

      public abstract SshKeyPair generateDsaKeyPair(int bits) throws SshException
      Generate a new DSA public/private key pair.
      Parameters:
      bits -
      Returns:
      SshKeyPair
      Throws:
      SshException
    • createDsaPublicKey

      public abstract SshDsaPublicKey createDsaPublicKey(BigInteger p, BigInteger q, BigInteger g, BigInteger y) throws SshException
      Create an instance of a DSA public key.
      Parameters:
      p -
      q -
      g -
      y -
      Returns:
      SshDsaPublicKey
      Throws:
      SshException
    • createDsaPublicKey

      public abstract SshDsaPublicKey createDsaPublicKey()
      Create an uninitialized instance of a DSA public key
      Returns:
      SshDsaPublicKey
    • createDsaPrivateKey

      public abstract SshDsaPrivateKey createDsaPrivateKey(BigInteger p, BigInteger q, BigInteger g, BigInteger x, BigInteger y) throws SshException
      Create an instance of a DSA private key.
      Parameters:
      p -
      q -
      g -
      x -
      y -
      Returns:
      SshDsaPrivateKey
      Throws:
      SshException
    • getRND

      public abstract SshSecureRandomGenerator getRND() throws SshException
      Get the secure random number generator.
      Returns:
      SshSecureRandomGenerator
      Throws:
      SshException
    • getDigest

      public Digest getDigest(String name) throws SshException
      Throws:
      SshException
    • setMinimumSecurityLevel

      public void setMinimumSecurityLevel(SecurityLevel securityLevel) throws SshException
      Throws:
      SshException