com.maverick.ssh.components.jce
Class JCEComponentManager

java.lang.Object
  extended by com.maverick.ssh.components.ComponentManager
      extended by com.maverick.ssh.components.jce.JCEComponentManager
All Implemented Interfaces:
JCEAlgorithms

public class JCEComponentManager
extends ComponentManager
implements 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_AESCBCNOPADDING, JCE_AESCTRNOPADDING, JCE_BLOWFISHCBCNOPADDING, JCE_DESCBCNOPADDING, JCE_DH, JCE_DSA, JCE_HMACMD5, JCE_HMACSHA1, JCE_MD5, JCE_RSA, JCE_RSANONEPKCS1PADDING, JCE_SHA1, JCE_SHA1PRNG, JCE_SHA1WithDSA, JCE_SHA1WithRSA, JCE_X509
 
Constructor Summary
JCEComponentManager()
           
 
Method Summary
 SshDsaPrivateKey createDsaPrivateKey(BigInteger p, BigInteger q, BigInteger g, BigInteger x, BigInteger y)
           
 SshDsaPublicKey createDsaPublicKey()
           
 SshDsaPublicKey createDsaPublicKey(BigInteger p, BigInteger q, BigInteger g, BigInteger y)
           
 SshRsaPrivateCrtKey createRsaPrivateCrtKey(BigInteger modulus, BigInteger publicExponent, BigInteger privateExponent, BigInteger primeP, BigInteger primeQ, BigInteger crtCoefficient)
           
 SshRsaPrivateCrtKey createRsaPrivateCrtKey(BigInteger modulus, BigInteger publicExponent, BigInteger privateExponent, BigInteger primeP, BigInteger primeQ, BigInteger primeExponentP, BigInteger primeExponentQ, BigInteger crtCoefficient)
           
 SshRsaPrivateKey createRsaPrivateKey(BigInteger modulus, BigInteger privateExponent)
           
 SshRsaPublicKey createRsaPublicKey(BigInteger modulus, BigInteger publicExponent, int version)
           
 SshRsaPublicKey createSsh2RsaPublicKey()
           
 SshKeyPair generateDsaKeyPair(int bits)
           
 SshKeyPair generateRsaKeyPair(int bits, int version)
           
static Provider getProviderForAlgorithm(String jceAlgorithm)
          Get the provider for a specific algorithm.
 SshSecureRandomGenerator getRND()
           
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(ComponentFactory digests)
           
protected  void initializeHmacFactory(ComponentFactory hmacs)
           
protected  void initializeKeyExchangeFactory(ComponentFactory keyexchange)
           
static void initializeProviderForAlgorithm(String jceAlgorithm, Provider provider)
          Initialize a provider for a specific algorithm.
protected  void initializePublicKeyFactory(ComponentFactory publickeys)
           
protected  void initializeSsh1CipherFactory(ComponentFactory ciphers)
           
protected  void initializeSsh2CipherFactory(ComponentFactory ciphers)
           
static void setSecureRandomAlgorithm(String secureRandomAlgorithm)
          Set the algorithm used for secure random number generation.
 
Methods inherited from class com.maverick.ssh.components.ComponentManager
getInstance, getPerContextAlgorithmPreferences, init, isEnableNoneCipher, setEnableNoneCipher, setInstance, setPerContextAlgorithmPreferences, supportedDigests, supportedHMacsCS, supportedHMacsSC, supportedKeyExchanges, supportedPublicKeys, supportedSsh1CiphersCS, supportedSsh1CiphersSC, supportedSsh2CiphersCS, supportedSsh2CiphersSC
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCEComponentManager

public JCEComponentManager()
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 SshDsaPrivateKey createDsaPrivateKey(BigInteger p,
                                            BigInteger q,
                                            BigInteger g,
                                            BigInteger x,
                                            BigInteger y)
                                     throws SshException
Specified by:
createDsaPrivateKey in class ComponentManager
Throws:
SshException

createDsaPublicKey

public SshDsaPublicKey createDsaPublicKey(BigInteger p,
                                          BigInteger q,
                                          BigInteger g,
                                          BigInteger y)
                                   throws SshException
Specified by:
createDsaPublicKey in class ComponentManager
Throws:
SshException

createDsaPublicKey

public SshDsaPublicKey createDsaPublicKey()
Specified by:
createDsaPublicKey in class ComponentManager

createRsaPrivateCrtKey

public SshRsaPrivateCrtKey createRsaPrivateCrtKey(BigInteger modulus,
                                                  BigInteger publicExponent,
                                                  BigInteger privateExponent,
                                                  BigInteger primeP,
                                                  BigInteger primeQ,
                                                  BigInteger crtCoefficient)
                                           throws SshException
Specified by:
createRsaPrivateCrtKey in class ComponentManager
Throws:
SshException

createRsaPrivateCrtKey

public SshRsaPrivateCrtKey createRsaPrivateCrtKey(BigInteger modulus,
                                                  BigInteger publicExponent,
                                                  BigInteger privateExponent,
                                                  BigInteger primeP,
                                                  BigInteger primeQ,
                                                  BigInteger primeExponentP,
                                                  BigInteger primeExponentQ,
                                                  BigInteger crtCoefficient)
                                           throws SshException
Specified by:
createRsaPrivateCrtKey in class ComponentManager
Throws:
SshException

createRsaPrivateKey

public SshRsaPrivateKey createRsaPrivateKey(BigInteger modulus,
                                            BigInteger privateExponent)
                                     throws SshException
Specified by:
createRsaPrivateKey in class ComponentManager
Throws:
SshException

createRsaPublicKey

public SshRsaPublicKey createRsaPublicKey(BigInteger modulus,
                                          BigInteger publicExponent,
                                          int version)
                                   throws SshException
Specified by:
createRsaPublicKey in class ComponentManager
Throws:
SshException

createSsh2RsaPublicKey

public SshRsaPublicKey createSsh2RsaPublicKey()
                                       throws SshException
Specified by:
createSsh2RsaPublicKey in class ComponentManager
Throws:
SshException

generateDsaKeyPair

public SshKeyPair generateDsaKeyPair(int bits)
                              throws SshException
Specified by:
generateDsaKeyPair in class ComponentManager
Throws:
SshException

generateRsaKeyPair

public SshKeyPair generateRsaKeyPair(int bits,
                                     int version)
                              throws SshException
Specified by:
generateRsaKeyPair in class ComponentManager
Throws:
SshException

getRND

public SshSecureRandomGenerator getRND()
                                throws SshException
Specified by:
getRND in class ComponentManager
Throws:
SshException

initializeDigestFactory

protected void initializeDigestFactory(ComponentFactory digests)
Specified by:
initializeDigestFactory in class ComponentManager

initializeHmacFactory

protected void initializeHmacFactory(ComponentFactory hmacs)
Specified by:
initializeHmacFactory in class ComponentManager

initializeKeyExchangeFactory

protected void initializeKeyExchangeFactory(ComponentFactory keyexchange)
Specified by:
initializeKeyExchangeFactory in class ComponentManager

initializePublicKeyFactory

protected void initializePublicKeyFactory(ComponentFactory publickeys)
Specified by:
initializePublicKeyFactory in class ComponentManager

initializeSsh1CipherFactory

protected void initializeSsh1CipherFactory(ComponentFactory ciphers)
Specified by:
initializeSsh1CipherFactory in class ComponentManager

initializeSsh2CipherFactory

protected void initializeSsh2CipherFactory(ComponentFactory ciphers)
Specified by:
initializeSsh2CipherFactory in class ComponentManager


Copyright © 2012. All Rights Reserved.