com.sshtools.jce
Class JCEProviderMapping

java.lang.Object
  extended bycom.sshtools.jce.JCEProviderMapping

public class JCEProviderMapping
extends java.lang.Object

This class provides the ability to configure the Maverick API to use a JCE rather than the internal Maverick Crypto API. To enable JCE usage simply call the following method:

 // To enable JCE with default provider
 JCEProviderMapping.enableJCEProvider(true);

 // To enable JCE with specific provider
 JCEProviderMapping.enableJCEProvider("Bouncycastle");

 // To disable JCE
 JCEProviderMapping.enableJCEProvider(false);
 

When a JCE is in use the default behaviour is to request all algorithm implementations without specifying a provider; this enables JCE to work with the Sun reference and SunJCE providers that are installed by default. You can configure a provider either for all or for an individual algorithm. The algorithms required for a default installation are:

 DESede/CBC/NoPadding (Cipher)
 Blowfish/CBC/NoPadding (Cipher)
 MD5 (Digest)
 SHA-1 (Digest)
 HmacSha1 (HMAC)
 HmacMD5 (HMAC)
 RSA (Public key)
 DSA (Public key)
 SHA1withRSA (Signature)
 SHA1withDSA (Signature)
 

If you add any further algorithm implementations or you want to change from the default provider you will need to specify the provider using:

 // To configure an provider for an individual algorithm
 JCEProviderMapping.setProviderForAlgorithm("AES/CBC/NoPadding", "Bouncycastle");

 // To configure a provider for all algorithms
 JCEProviderMapping.setProvider("Bouncycastle");
 

Author:
Lee David Painter

Field Summary
static java.lang.String DEFAULT_PROVIDER
          Identifies the default provider
 
Constructor Summary
JCEProviderMapping()
           
 
Method Summary
static boolean containsProvider(java.lang.String algorithm)
           
static void enableJCEProvider(boolean enabled)
          Enable JCE mode and configure all algorithms to use the default provider.
static void enableJCEProvider(java.lang.String provider)
          Enable JCE mode and configure all algorithms to use the specified provider.
static java.lang.String getProvider(java.lang.String algorithm)
           
static java.lang.String[] getRequiredAlgorithms()
          Returns an array of all the algorithms currently required by the Maverick API.
static boolean isJCEEnabled()
          Determine if JCE mode is enabled
static void setProvider(java.lang.String provider)
          Sets the provider for all currently configured algorithms.
static void setProviderForAlgorithm(java.lang.String algorithm, java.lang.String provider)
          Set the provider for an individual algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PROVIDER

public static java.lang.String DEFAULT_PROVIDER
Identifies the default provider

Constructor Detail

JCEProviderMapping

public JCEProviderMapping()
Method Detail

containsProvider

public static boolean containsProvider(java.lang.String algorithm)

getProvider

public static java.lang.String getProvider(java.lang.String algorithm)

setProvider

public static void setProvider(java.lang.String provider)
Sets the provider for all currently configured algorithms.

Parameters:
provider - String

isJCEEnabled

public static boolean isJCEEnabled()
Determine if JCE mode is enabled

Returns:
boolean

getRequiredAlgorithms

public static java.lang.String[] getRequiredAlgorithms()
Returns an array of all the algorithms currently required by the Maverick API.

Returns:
String[]

enableJCEProvider

public static void enableJCEProvider(java.lang.String provider)
Enable JCE mode and configure all algorithms to use the specified provider.

Parameters:
provider - String

enableJCEProvider

public static void enableJCEProvider(boolean enabled)
Enable JCE mode and configure all algorithms to use the default provider.

Parameters:
enabled - boolean

setProviderForAlgorithm

public static void setProviderForAlgorithm(java.lang.String algorithm,
                                           java.lang.String provider)
Set the provider for an individual algorithm.

Parameters:
algorithm - String
provider - String


Copyright © 2003 3SP LTD. All Rights Reserved.