javax.crypto

Class ExemptionMechanism

  1. java.lang.Object
  2. extended byjavax.crypto.ExemptionMechanism

  1. public class ExemptionMechanism
  2. extends java.lang.Object
This class provides the functionality of an exemption mechanism, examples of which are key recovery, key weakening, and key escrow.

Applications or applets that use an exemption mechanism may be granted stronger encryption capabilities than those which don't.

Since:
1.4
Version:
1.12, 01/06/04

Constructor Summary

Modifier Constructor and Description
  1. protected
ExemptionMechanism(ExemptionMechanismSpi exmechSpi,java.security.Provider provider,java.lang.String mechanism)
Creates a ExemptionMechanism object.

Method Summary

Modifier and Type Method and Description
  1. protected
  2. void
finalize()
Ensures that the key stored away by this ExemptionMechanism object will be wiped out when there are no more references to it.
  1. byte[]
genExemptionBlob()
Generates the exemption mechanism key blob.
  1. int
genExemptionBlob(byte[] output)
Generates the exemption mechanism key blob, and stores the result in the output buffer.
  1. int
genExemptionBlob(byte[] output,int outputOffset)
Generates the exemption mechanism key blob, and stores the result in the output buffer, starting at outputOffset inclusive.
  1. static
  2. ExemptionMechanism
getInstance(java.lang.String algorithm)
Returns an ExemptionMechanism object that implements the specified exemption mechanism algorithm.
  1. static
  2. ExemptionMechanism
getInstance(java.lang.String algorithm,java.security.Provider provider)
Returns an ExemptionMechanism object that implements the specified exemption mechanism algorithm.
  1. static
  2. ExemptionMechanism
getInstance(java.lang.String algorithm,java.lang.String provider)
Returns an ExemptionMechanism object that implements the specified exemption mechanism algorithm.
  1. java.lang.String
getName()
Returns the exemption mechanism name of this ExemptionMechanism object.
  1. int
getOutputSize(int inputLen)
Returns the length in bytes that an output buffer would need to be in order to hold the result of the next genExemptionBloboperation, given the input length inputLen (in bytes).
  1. java.security.Provider
getProvider()
Returns the provider of this ExemptionMechanism object.
  1. void
init(java.security.Key key)
Initializes this exemption mechanism with a key.
  1. void
init(java.security.Key key,java.security.AlgorithmParameters params)
Initializes this exemption mechanism with a key and a set of algorithm parameters.
  1. void
init(java.security.Key key,java.security.spec.AlgorithmParameterSpec params)
Initializes this exemption mechanism with a key and a set of algorithm parameters.
  1. boolean
isCryptoAllowed(java.security.Key key)
Returns whether the result blob has been generated successfully by this exemption mechanism.
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

ExemptionMechanism

  1. protected ExemptionMechanism(ExemptionMechanismSpi exmechSpi,
  2. java.security.Provider provider,
  3. java.lang.String mechanism)
Creates a ExemptionMechanism object.
Parameters:
exmechSpi - the delegate
provider - the provider
mechanism - the exemption mechanism

Method Detail

getName

  1. public final java.lang.String getName( )
Returns the exemption mechanism name of this ExemptionMechanism object.

This is the same name that was specified in one of the getInstance calls that created this ExemptionMechanism object.

Returns:
the exemption mechanism name of this ExemptionMechanism object.

getInstance

  1. public static final ExemptionMechanism getInstance( java.lang.String algorithm)
  2. throws java.security.NoSuchAlgorithmException
Returns an ExemptionMechanism object that implements the specified exemption mechanism algorithm.

This method traverses the list of registered security Providers, starting with the most preferred Provider. A new ExemptionMechanism object encapsulating the ExemptionMechanismSpi implementation from the first Provider that supports the specified algorithm is returned.

Note that the list of registered providers may be retrieved via the Security.getProviders() method.

Parameters:
algorithm - the standard name of the requested exemption mechanism. See Appendix A in the Java Cryptography Extension Reference Guide for information about standard exemption mechanism names.
Returns:
the new ExemptionMechanism object.
Throws:
java.lang.NullPointerException - if algorithm is null.
java.security.NoSuchAlgorithmException - if no Provider supports an ExemptionMechanismSpi implementation for the specified algorithm.
See Also:
Provider

getInstance

  1. public static final ExemptionMechanism getInstance( java.lang.String algorithm,
  2. java.lang.String provider)
  3. throws java.security.NoSuchAlgorithmException
  4. java.security.NoSuchProviderException
Returns an ExemptionMechanism object that implements the specified exemption mechanism algorithm.

A new ExemptionMechanism object encapsulating the ExemptionMechanismSpi implementation from the specified provider is returned. The specified provider must be registered in the security provider list.

Note that the list of registered providers may be retrieved via the Security.getProviders() method.

Parameters:
algorithm - the standard name of the requested exemption mechanism. See Appendix A in the Java Cryptography Extension Reference Guide for information about standard exemption mechanism names.
provider - the name of the provider
Returns:
the new ExemptionMechanism object.
Throws:
java.lang.NullPointerException - if algorithm is null.
java.security.NoSuchAlgorithmException - if an ExemptionMechanismSpi implementation for the specified algorithm is not available from the specified provider.
java.security.NoSuchProviderException - if the specified provider is not registered in the security provider list.
java.lang.IllegalArgumentException - if the provider is null or empty.
See Also:
Provider

getInstance

  1. public static final ExemptionMechanism getInstance( java.lang.String algorithm,
  2. java.security.Provider provider)
  3. throws java.security.NoSuchAlgorithmException
Returns an ExemptionMechanism object that implements the specified exemption mechanism algorithm.

A new ExemptionMechanism object encapsulating the ExemptionMechanismSpi implementation from the specified Provider object is returned. Note that the specified Provider object does not have to be registered in the provider list.

Parameters:
algorithm - the standard name of the requested exemption mechanism. See Appendix A in the Java Cryptography Extension Reference Guide for information about standard exemption mechanism names.
provider - the provider.
Returns:
the new ExemptionMechanism object.
Throws:
java.lang.NullPointerException - if algorithm is null.
java.security.NoSuchAlgorithmException - if an ExemptionMechanismSpi implementation for the specified algorithm is not available from the specified Provider object.
java.lang.IllegalArgumentException - if the provider is null.
See Also:
Provider

getProvider

  1. public final java.security.Provider getProvider( )
Returns the provider of this ExemptionMechanism object.
Returns:
the provider of this ExemptionMechanism object.

isCryptoAllowed

  1. public final boolean isCryptoAllowed( java.security.Key key)
  2. throws ExemptionMechanismException
Returns whether the result blob has been generated successfully by this exemption mechanism.

The method also makes sure that the key passed in is the same as the one this exemption mechanism used in initializing and generating phases.

Parameters:
key - the key the crypto is going to use.
Returns:
whether the result blob of the same key has been generated successfully by this exemption mechanism; false if key is null.
Throws:
ExemptionMechanismException - if problem(s) encountered while determining whether the result blob has been generated successfully by this exemption mechanism object.

getOutputSize

  1. public final int getOutputSize( int inputLen)
  2. throws java.lang.IllegalStateException
Returns the length in bytes that an output buffer would need to be in order to hold the result of the next genExemptionBlob operation, given the input length inputLen (in bytes).

The actual output length of the next genExemptionBlob call may be smaller than the length returned by this method.

Parameters:
inputLen - the input length (in bytes)
Returns:
the required output buffer size (in bytes)
Throws:
java.lang.IllegalStateException - if this exemption mechanism is in a wrong state (e.g., has not yet been initialized)

init

  1. public final void init(java.security.Key key)
  2. throws java.security.InvalidKeyException
  3. ExemptionMechanismException
Initializes this exemption mechanism with a key.

If this exemption mechanism requires any algorithm parameters that cannot be derived from the given key, the underlying exemption mechanism implementation is supposed to generate the required parameters itself (using provider-specific default values); in the case that algorithm parameters must be specified by the caller, an InvalidKeyException is raised.

Parameters:
key - the key for this exemption mechanism
Throws:
java.security.InvalidKeyException - if the given key is inappropriate for this exemption mechanism.
ExemptionMechanismException - if problem(s) encountered in the process of initializing.

init

  1. public final void init(java.security.Key key,
  2. java.security.spec.AlgorithmParameterSpec params)
  3. throws java.security.InvalidKeyException
  4. java.security.InvalidAlgorithmParameterException
  5. ExemptionMechanismException
Initializes this exemption mechanism with a key and a set of algorithm parameters.

If this exemption mechanism requires any algorithm parameters and params is null, the underlying exemption mechanism implementation is supposed to generate the required parameters itself (using provider-specific default values); in the case that algorithm parameters must be specified by the caller, an InvalidAlgorithmParameterException is raised.

Parameters:
key - the key for this exemption mechanism
params - the algorithm parameters
Throws:
java.security.InvalidKeyException - if the given key is inappropriate for this exemption mechanism.
java.security.InvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for this exemption mechanism.
ExemptionMechanismException - if problem(s) encountered in the process of initializing.

init

  1. public final void init(java.security.Key key,
  2. java.security.AlgorithmParameters params)
  3. throws java.security.InvalidKeyException
  4. java.security.InvalidAlgorithmParameterException
  5. ExemptionMechanismException
Initializes this exemption mechanism with a key and a set of algorithm parameters.

If this exemption mechanism requires any algorithm parameters and params is null, the underlying exemption mechanism implementation is supposed to generate the required parameters itself (using provider-specific default values); in the case that algorithm parameters must be specified by the caller, an InvalidAlgorithmParameterException is raised.

Parameters:
key - the key for this exemption mechanism
params - the algorithm parameters
Throws:
java.security.InvalidKeyException - if the given key is inappropriate for this exemption mechanism.
java.security.InvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for this exemption mechanism.
ExemptionMechanismException - if problem(s) encountered in the process of initializing.

genExemptionBlob

  1. public final byte[] genExemptionBlob( )
  2. throws java.lang.IllegalStateException
  3. ExemptionMechanismException
Generates the exemption mechanism key blob.
Returns:
the new buffer with the result key blob.
Throws:
java.lang.IllegalStateException - if this exemption mechanism is in a wrong state (e.g., has not been initialized).
ExemptionMechanismException - if problem(s) encountered in the process of generating.

genExemptionBlob

  1. public final int genExemptionBlob( byte[] output)
  2. throws java.lang.IllegalStateException
  3. ShortBufferException
  4. ExemptionMechanismException
Generates the exemption mechanism key blob, and stores the result in the output buffer.

If the output buffer is too small to hold the result, a ShortBufferException is thrown. In this case, repeat this call with a larger output buffer. Use getOutputSize to determine how big the output buffer should be.

Parameters:
output - the buffer for the result
Returns:
the number of bytes stored in output
Throws:
java.lang.IllegalStateException - if this exemption mechanism is in a wrong state (e.g., has not been initialized).
ShortBufferException - if the given output buffer is too small to hold the result.
ExemptionMechanismException - if problem(s) encountered in the process of generating.

genExemptionBlob

  1. public final int genExemptionBlob( byte[] output,
  2. int outputOffset)
  3. throws java.lang.IllegalStateException
  4. ShortBufferException
  5. ExemptionMechanismException
Generates the exemption mechanism key blob, and stores the result in the output buffer, starting at outputOffset inclusive.

If the output buffer is too small to hold the result, a ShortBufferException is thrown. In this case, repeat this call with a larger output buffer. Use getOutputSize to determine how big the output buffer should be.

Parameters:
output - the buffer for the result
outputOffset - the offset in output where the result is stored
Returns:
the number of bytes stored in output
Throws:
java.lang.IllegalStateException - if this exemption mechanism is in a wrong state (e.g., has not been initialized).
ShortBufferException - if the given output buffer is too small to hold the result.
ExemptionMechanismException - if problem(s) encountered in the process of generating.

finalize

  1. protected void finalize()
Ensures that the key stored away by this ExemptionMechanism object will be wiped out when there are no more references to it.
Overrides:
finalize in class java.lang.Object