com.maverick.sshd.components.jce
Class JCEServerComponentManager

java.lang.Object
  extended by com.maverick.sshd.components.ServerComponentManager
      extended by com.maverick.sshd.components.jce.JCEServerComponentManager
All Implemented Interfaces:
com.maverick.ssh.components.jce.JCEAlgorithms

public class JCEServerComponentManager
extends ServerComponentManager
implements com.maverick.ssh.components.jce.JCEAlgorithms

A component manager for the Java runtime JCE provider. By default all algorithms will be selected from the default provider i.e no provider is specified in calls to JCE methods to create components. You can initialize a default provider to be used on all calls with the following code:

 JCEComponentManager.initializeDefaultProvider(new BouncyCastleProvider());
 
Alternatively you can also assign a specific provider for an individual algorithm, all algorithms used by the API are included as static constants in this class.
 JCEComponentManager.initializeProviderForAlgorithm(JCEComponentManager.JCE_DSA, new BouncyCastleProvider());
 

Author:
Lee David Painter

Field Summary
 
Fields inherited from interface com.maverick.ssh.components.jce.JCEAlgorithms
JCE_3DESCBCNOPADDING, JCE_3DESCTRNOPADDING, JCE_AESCBCNOPADDING, JCE_AESCTRNOPADDING, JCE_ARCFOUR, JCE_BLOWFISHCBCNOPADDING, JCE_DESCBCNOPADDING, JCE_DH, JCE_DSA, JCE_HMACMD5, JCE_HMACSHA1, JCE_HMACSHA256, JCE_HMACSHA512, JCE_MD5, JCE_MD5WithRSA, JCE_RSA, JCE_RSANONEPKCS1PADDING, JCE_SHA1, JCE_SHA1PRNG, JCE_SHA1WithDSA, JCE_SHA1WithRSA, JCE_SHA256, JCE_X509
 
Constructor Summary
JCEServerComponentManager()
           
 
Method Summary
 com.maverick.ssh.components.SshDsaPrivateKey createDsaPrivateKey(BigInteger p, BigInteger q, BigInteger g, BigInteger x, BigInteger y)
          Create a DSA private key from DSA parameters.
 com.maverick.ssh.components.SshDsaPublicKey createDsaPublicKey()
          Create an uninitialized instance of a DSA public key.
 com.maverick.ssh.components.SshDsaPublicKey createDsaPublicKey(BigInteger p, BigInteger q, BigInteger g, BigInteger y)
          Create an instance of an DSA public key.
 com.maverick.ssh.components.SshRsaPrivateCrtKey createRsaPrivateCrtKey(BigInteger modulus, BigInteger publicExponent, BigInteger privateExponent, BigInteger primeP, BigInteger primeQ, BigInteger crtCoefficient)
          Create a RSA co-efficient key from RSA parameters.
 com.maverick.ssh.components.SshRsaPrivateCrtKey createRsaPrivateCrtKey(BigInteger modulus, BigInteger publicExponent, BigInteger privateExponent, BigInteger primeP, BigInteger primeQ, BigInteger primeExponentP, BigInteger primeExponentQ, BigInteger crtCoefficient)
          Create an RSA co-efficient key from RSA parameters.
 com.maverick.ssh.components.SshRsaPrivateKey createRsaPrivateKey(BigInteger modulus, BigInteger privateExponent)
          Create an RSA private key from RSA parameters
 com.maverick.ssh.components.SshRsaPublicKey createRsaPublicKey(BigInteger modulus, BigInteger publicExponent, int version)
          Create an instance of an RSA public key from RSA parameters.
 com.maverick.ssh.components.SshRsaPublicKey createSsh2RsaPublicKey()
          Create an uninitialized instance of an RSA public key
 com.maverick.ssh.components.SshKeyPair generateDsaKeyPair(int bits)
          Generate a DSA key pair.
 com.maverick.ssh.components.SshKeyPair generateRsaKeyPair(int bits)
          Generate an RSA key pair.
static Provider getProviderForAlgorithm(String jceAlgorithm)
          Get the provider for a specific algorithm.
 com.maverick.ssh.components.SshSecureRandomGenerator getRND()
          Get the secure number generator implementation.
static SecureRandom getSecureRandom()
          Get the secure random implementation for the API.
static String getSecureRandomAlgorithm()
          Get the algorithm used for secure random number generation.
static void initializeDefaultProvider(Provider provider)
          Initialize the default JCE provider used by the API.
protected  void initializeDigestFactory(com.maverick.ssh.components.ComponentFactory digests)
          Initialize the digest factory.
protected  void initializeHmacFactory(com.maverick.ssh.components.ComponentFactory hmacs)
          Initialize the SSH2 HMac factory.
protected  void initializeKeyExchangeFactory(com.maverick.ssh.components.ComponentFactory keyexchange)
          Initialize the key exchange factory.
static void initializeProviderForAlgorithm(String jceAlgorithm, Provider provider)
          Initialize a provider for a specific algorithm.
protected  void initializePublicKeyFactory(com.maverick.ssh.components.ComponentFactory publickeys)
          Initialize the public key factory.
protected  void initializeSsh2CipherFactory(com.maverick.ssh.components.ComponentFactory ciphers)
          Initialize the SSH2 cipher factory.
 void loadKeystore(File keystoreFile, String alias, String storePassphrase, String keyPassphrase, SshContext context)
          Load a host key from a keystore file.
 void loadKeystore(File keystoreFile, String alias, String storePassphrase, String keyPassphrase, String storeType, SshContext context)
           
 void loadKeystore(InputStream in, String alias, String storePassphrase, String keyPassphrase, SshContext context)
          Load a keystore for use as an SSH host key.
 void loadKeystore(InputStream in, String alias, String storePassphrase, String keyPassphrase, String storeType, SshContext context)
          Load a keystore for use as an SSH host key.
static void setSecureRandomAlgorithm(String secureRandomAlgorithm)
          Set the algorithm used for secure random number generation.
 
Methods inherited from class com.maverick.sshd.components.ServerComponentManager
isEnableNoneCipher, setEnableNoneCipher, supportedCompressionsCS, supportedCompressionsSC, supportedDigests, supportedHMacsCS, supportedHMacsSC, supportedKeyExchanges, supportedPublicKeys, supportedSsh2CiphersCS, supportedSsh2CiphersSC
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCEServerComponentManager

public JCEServerComponentManager()
                          throws com.maverick.ssh.common.SshException
Throws:
com.maverick.ssh.common.SshException
Method Detail

initializeDefaultProvider

public static void initializeDefaultProvider(Provider provider)
Initialize the default JCE provider used by the API.

Parameters:
provider -

initializeProviderForAlgorithm

public static void initializeProviderForAlgorithm(String jceAlgorithm,
                                                  Provider provider)
Initialize a provider for a specific algorithm.

Parameters:
jceAlgorithm -
provider -

getSecureRandomAlgorithm

public static String getSecureRandomAlgorithm()
Get the algorithm used for secure random number generation.

Returns:
String

setSecureRandomAlgorithm

public static void setSecureRandomAlgorithm(String secureRandomAlgorithm)
Set the algorithm used for secure random number generation.

Parameters:
secureRandomAlgorithm -

getProviderForAlgorithm

public static Provider getProviderForAlgorithm(String jceAlgorithm)
Get the provider for a specific algorithm.

Parameters:
jceAlgorithm -
Returns:
Provider

getSecureRandom

public static SecureRandom getSecureRandom()
                                    throws NoSuchAlgorithmException
Get the secure random implementation for the API.

Returns:
SecureRandom
Throws:
NoSuchAlgorithmException

createDsaPrivateKey

public com.maverick.ssh.components.SshDsaPrivateKey createDsaPrivateKey(BigInteger p,
                                                                        BigInteger q,
                                                                        BigInteger g,
                                                                        BigInteger x,
                                                                        BigInteger y)
                                                                 throws com.maverick.ssh.common.SshException
Description copied from class: ServerComponentManager
Create a DSA private key from DSA parameters.

Specified by:
createDsaPrivateKey in class ServerComponentManager
Returns:
SshDsaPrivateKey
Throws:
com.maverick.ssh.common.SshException

createDsaPublicKey

public com.maverick.ssh.components.SshDsaPublicKey createDsaPublicKey(BigInteger p,
                                                                      BigInteger q,
                                                                      BigInteger g,
                                                                      BigInteger y)
                                                               throws com.maverick.ssh.common.SshException
Description copied from class: ServerComponentManager
Create an instance of an DSA public key.

Specified by:
createDsaPublicKey in class ServerComponentManager
Returns:
SshDsaPublicKey
Throws:
com.maverick.ssh.common.SshException

createDsaPublicKey

public com.maverick.ssh.components.SshDsaPublicKey createDsaPublicKey()
Description copied from class: ServerComponentManager
Create an uninitialized instance of a DSA public key.

Specified by:
createDsaPublicKey in class ServerComponentManager
Returns:
SshDsaPublicKey

createRsaPrivateCrtKey

public com.maverick.ssh.components.SshRsaPrivateCrtKey createRsaPrivateCrtKey(BigInteger modulus,
                                                                              BigInteger publicExponent,
                                                                              BigInteger privateExponent,
                                                                              BigInteger primeP,
                                                                              BigInteger primeQ,
                                                                              BigInteger crtCoefficient)
                                                                       throws com.maverick.ssh.common.SshException
Description copied from class: ServerComponentManager
Create a RSA co-efficient key from RSA parameters.

Specified by:
createRsaPrivateCrtKey in class ServerComponentManager
Returns:
SshRsaPrivateCrtKey
Throws:
com.maverick.ssh.common.SshException

createRsaPrivateCrtKey

public com.maverick.ssh.components.SshRsaPrivateCrtKey createRsaPrivateCrtKey(BigInteger modulus,
                                                                              BigInteger publicExponent,
                                                                              BigInteger privateExponent,
                                                                              BigInteger primeP,
                                                                              BigInteger primeQ,
                                                                              BigInteger primeExponentP,
                                                                              BigInteger primeExponentQ,
                                                                              BigInteger crtCoefficient)
                                                                       throws com.maverick.ssh.common.SshException
Description copied from class: ServerComponentManager
Create an RSA co-efficient key from RSA parameters.

Specified by:
createRsaPrivateCrtKey in class ServerComponentManager
Returns:
SshRsaPrivateCrtKey
Throws:
com.maverick.ssh.common.SshException

createRsaPrivateKey

public com.maverick.ssh.components.SshRsaPrivateKey createRsaPrivateKey(BigInteger modulus,
                                                                        BigInteger privateExponent)
                                                                 throws com.maverick.ssh.common.SshException
Description copied from class: ServerComponentManager
Create an RSA private key from RSA parameters

Specified by:
createRsaPrivateKey in class ServerComponentManager
Returns:
SshRsaPrivateKey
Throws:
com.maverick.ssh.common.SshException

createRsaPublicKey

public com.maverick.ssh.components.SshRsaPublicKey createRsaPublicKey(BigInteger modulus,
                                                                      BigInteger publicExponent,
                                                                      int version)
                                                               throws com.maverick.ssh.common.SshException
Description copied from class: ServerComponentManager
Create an instance of an RSA public key from RSA parameters.

Specified by:
createRsaPublicKey in class ServerComponentManager
Returns:
SshRsaPublicKey
Throws:
com.maverick.ssh.common.SshException

createSsh2RsaPublicKey

public com.maverick.ssh.components.SshRsaPublicKey createSsh2RsaPublicKey()
                                                                   throws com.maverick.ssh.common.SshException
Description copied from class: ServerComponentManager
Create an uninitialized instance of an RSA public key

Specified by:
createSsh2RsaPublicKey in class ServerComponentManager
Returns:
SshRsaPublicKey
Throws:
com.maverick.ssh.common.SshException

generateDsaKeyPair

public com.maverick.ssh.components.SshKeyPair generateDsaKeyPair(int bits)
                                                          throws com.maverick.ssh.common.SshException
Description copied from class: ServerComponentManager
Generate a DSA key pair.

Specified by:
generateDsaKeyPair in class ServerComponentManager
Returns:
SshKeyPair
Throws:
com.maverick.ssh.common.SshException

generateRsaKeyPair

public com.maverick.ssh.components.SshKeyPair generateRsaKeyPair(int bits)
                                                          throws com.maverick.ssh.common.SshException
Description copied from class: ServerComponentManager
Generate an RSA key pair.

Specified by:
generateRsaKeyPair in class ServerComponentManager
Returns:
SshKeyPair
Throws:
com.maverick.ssh.common.SshException

getRND

public com.maverick.ssh.components.SshSecureRandomGenerator getRND()
                                                            throws com.maverick.ssh.common.SshException
Description copied from class: ServerComponentManager
Get the secure number generator implementation.

Specified by:
getRND in class ServerComponentManager
Returns:
SshSecureRandomGenerator
Throws:
com.maverick.ssh.common.SshException

initializeDigestFactory

protected void initializeDigestFactory(com.maverick.ssh.components.ComponentFactory digests)
Description copied from class: ServerComponentManager
Initialize the digest factory.

Specified by:
initializeDigestFactory in class ServerComponentManager

initializeHmacFactory

protected void initializeHmacFactory(com.maverick.ssh.components.ComponentFactory hmacs)
Description copied from class: ServerComponentManager
Initialize the SSH2 HMac factory.

Specified by:
initializeHmacFactory in class ServerComponentManager

initializeKeyExchangeFactory

protected void initializeKeyExchangeFactory(com.maverick.ssh.components.ComponentFactory keyexchange)
Description copied from class: ServerComponentManager
Initialize the key exchange factory.

Specified by:
initializeKeyExchangeFactory in class ServerComponentManager

initializePublicKeyFactory

protected void initializePublicKeyFactory(com.maverick.ssh.components.ComponentFactory publickeys)
Description copied from class: ServerComponentManager
Initialize the public key factory.

Specified by:
initializePublicKeyFactory in class ServerComponentManager

initializeSsh2CipherFactory

protected void initializeSsh2CipherFactory(com.maverick.ssh.components.ComponentFactory ciphers)
Description copied from class: ServerComponentManager
Initialize the SSH2 cipher factory.

Specified by:
initializeSsh2CipherFactory in class ServerComponentManager

loadKeystore

public void loadKeystore(InputStream in,
                         String alias,
                         String storePassphrase,
                         String keyPassphrase,
                         SshContext context)
                  throws IOException
Load a keystore for use as an SSH host key. This will create a public key using the X509V3_SIGN_RSA and X509V3_SIGN_RSA_SHA1 host key types. DSA keys are currently not supported.

Specified by:
loadKeystore in class ServerComponentManager
Parameters:
keystoreFile - path to the keystore file
alias - the alias of the key in the keystore
storePassphrase - the passphrase of the keystore
keyPassphrase - the passphrase of the key
Throws:
IOException

loadKeystore

public void loadKeystore(InputStream in,
                         String alias,
                         String storePassphrase,
                         String keyPassphrase,
                         String storeType,
                         SshContext context)
                  throws IOException
Load a keystore for use as an SSH host key. This will create a public key using the X509V3_SIGN_RSA and X509V3_SIGN_RSA_SHA1 host key types. DSA keys are currently not supported.

Specified by:
loadKeystore in class ServerComponentManager
Parameters:
keystoreFile - path to the keystore file
alias - the alias of the key in the keystore
storePassphrase - the passphrase of the keystore
keyPassphrase - the passphrase of the key
Throws:
IOException

loadKeystore

public void loadKeystore(File keystoreFile,
                         String alias,
                         String storePassphrase,
                         String keyPassphrase,
                         SshContext context)
                  throws IOException
Description copied from class: ServerComponentManager
Load a host key from a keystore file.

Specified by:
loadKeystore in class ServerComponentManager
Throws:
IOException

loadKeystore

public void loadKeystore(File keystoreFile,
                         String alias,
                         String storePassphrase,
                         String keyPassphrase,
                         String storeType,
                         SshContext context)
                  throws IOException
Specified by:
loadKeystore in class ServerComponentManager
Throws:
IOException


Copyright © 2012. All Rights Reserved.