Class ComponentManager
java.lang.Object
com.sshtools.common.ssh.components.ComponentManager
- Direct Known Subclasses:
JCEComponentManager
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract SshDsaPrivateKeycreateDsaPrivateKey(BigInteger p, BigInteger q, BigInteger g, BigInteger x, BigInteger y) Create an instance of a DSA private key.abstract SshDsaPublicKeyCreate an uninitialized instance of a DSA public keyabstract SshDsaPublicKeycreateDsaPublicKey(BigInteger p, BigInteger q, BigInteger g, BigInteger y) Create an instance of a DSA public key.abstract SshRsaPrivateCrtKeycreateRsaPrivateCrtKey(BigInteger modulus, BigInteger publicExponent, BigInteger privateExponent, BigInteger primeP, BigInteger primeQ, BigInteger crtCoefficient) Create an instance of an RSA co-effecient private key.abstract SshRsaPrivateCrtKeycreateRsaPrivateCrtKey(BigInteger modulus, BigInteger publicExponent, BigInteger privateExponent, BigInteger primeP, BigInteger primeQ, BigInteger primeExponentP, BigInteger primeExponentQ, BigInteger crtCoefficient) Create an instance of an RSA co-efficent private key.abstract SshRsaPrivateKeycreateRsaPrivateKey(BigInteger modulus, BigInteger privateExponent) Create an instance of an RSA private key.abstract SshRsaPublicKeycreateRsaPublicKey(BigInteger modulus, BigInteger publicExponent) Create an instance of an RSA public key.abstract SshRsaPublicKeyCreate an instance of an SSH2 RSA public key.voiddisableAlgorithm(String algorithm) voidenableAlgorithm(String algorithm) abstract SshKeyPairgenerateDsaKeyPair(int bits) Generate a new DSA public/private key pair.abstract SshKeyPairgenerateEcdsaKeyPair(int bits) Generate a new ECDSA key pair.abstract SshKeyPairabstract SshKeyPairabstract SshKeyPairgenerateRsaKeyPair(int bits, int version) Generate an RSA public/private pair.abstract ClassLoaderstatic ComponentManagerstatic ComponentManagerGet the installed component manager.abstract SshSecureRandomGeneratorgetRND()Get the secure random number generator.protected voidinit()protected abstract voidinitializeDigestFactory(ComponentFactory<Digest> digests) Initialize the digest factory.protected abstract voidInitialize the SSH2 HMAC factory.protected abstract voidinitializePublicKeyFactory(ComponentFactory<SshPublicKey> publickeys) Initialize the public key factory.protected abstract voidInitialize the SSH2 cipher factory.isDefaultEnabled(Class<C> factoryType, String key) booleanisDisabled(String algorithm) <C extends Component>
booleanisEnabled(ComponentInstanceFactory<C> cls, Class<C> type, String name) static booleanstatic boolean<C extends Component,F extends ComponentInstanceFactory<C>>
Iterable<F>loadComponents(Class<C> componentType, Class<F> factoryClass) static voidreset()static <C extends Component>
voidsetDefaultEnabled(Class<C> componentType, String key, boolean enabled) static voidsetEnableNoneCipher(boolean enableNoneCipher) static voidsetEnableNoneMac(boolean enableNoneCipher) static voidsetInstance(ComponentManager instance) Overide the installed component manager with an alternative implementation.voidsetMinimumSecurityLevel(SecurityLevel securityLevel) The supported digestsThe supported SSH2 Hmacs.The supported SSH2 Hmacs.The supported public keysThe supported SSH2 ciphers.The supported SSH2 ciphers.
-
Field Details
-
instance
-
-
Constructor Details
-
ComponentManager
protected ComponentManager()
-
-
Method Details
-
disableAlgorithm
-
isDisabled
-
enableAlgorithm
-
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
-
setDefaultEnabled
-
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
-
reset
public static void reset() -
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
- Throws:
SshException
-
initializeSsh2CipherFactory
Initialize the SSH2 cipher factory. These ciphers are exclusively used by the SSH2 implementation.- Parameters:
ciphers-
-
initializeHmacFactory
Initialize the SSH2 HMAC factory.- Parameters:
hmacs-
-
initializePublicKeyFactory
Initialize the public key factory.- Parameters:
publickeys-
-
initializeDigestFactory
Initialize the digest factory.- Parameters:
digests-
-
setInstance
Overide the installed component manager with an alternative implementation.- Parameters:
instance-
-
supportedSsh2CiphersSC
The supported SSH2 ciphers.- Returns:
- AbstractComponentFactory
-
supportedSsh2CiphersCS
The supported SSH2 ciphers.- Returns:
- AbstractComponentFactory
-
supportedHMacsSC
The supported SSH2 Hmacs.- Returns:
- AbstractComponentFactory
-
supportedHMacsCS
The supported SSH2 Hmacs.- Returns:
- AbstractComponentFactory
-
supportedPublicKeys
The supported public keys- Returns:
- AbstractComponentFactory
-
supportedDigests
The supported digests- Returns:
- AbstractComponentFactory
-
generateRsaKeyPair
Generate an RSA public/private pair.- Parameters:
bits-version-- Returns:
- SshKeyPair
- Throws:
SshException
-
generateEcdsaKeyPair
Generate a new ECDSA key pair.- Parameters:
bits-- Returns:
- Throws:
SshException
-
generateEd448KeyPair
- Throws:
SshException
-
generateEd25519KeyPair
- 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
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
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
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
Get the secure random number generator.- Returns:
- SshSecureRandomGenerator
- Throws:
SshException
-
getDigest
- Throws:
SshException
-
setMinimumSecurityLevel
- Throws:
SshException
-