This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.crypto
class ExemptionMechanism

java.lang.Object extended by javax.crypto.ExemptionMechanism

public class ExemptionMechanism
extends 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.


Constructor Summary
protected
ExemptionMechanism(ExemptionMechanismSpi exmechSpi, Provider provider, String mechanism)

          Creates a ExemptionMechanism object.
 
Method Summary
protected void

          Ensures that the key stored away by this ExemptionMechanism object will be wiped out when there are no more references to it.
 byte[]

          Generates the exemption mechanism key blob.
 int
genExemptionBlob(byte[] output)

          Generates the exemption mechanism key blob, and stores the result in the output buffer.
 int
genExemptionBlob(byte[] output, int outputOffset)

          Generates the exemption mechanism key blob, and stores the result in the output buffer, starting at outputOffset inclusive.
static ExemptionMechanism
getInstance(String algorithm)

          Generates a ExemptionMechanism object that implements the specified exemption mechanism algorithm.
static ExemptionMechanism
getInstance(String algorithm, Provider provider)

          Generates a ExemptionMechanism object for the specified exemption mechanism algorithm from the specified provider.
static ExemptionMechanism
getInstance(String algorithm, String provider)

          Generates a ExemptionMechanism object for the specified exemption mechanism from the specified provider.
 String

          Returns the exemption mechanism name of this ExemptionMechanism object.
 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 javax.crypto.ExemptionMechanism.genExemptionBlob operation, given the input length inputLen (in bytes).
 Provider

          Returns the provider of this ExemptionMechanism object.
 void
init(Key key)

          Initializes this exemption mechanism with a key.
 void

          Initializes this exemption mechanism with a key and a set of algorithm parameters.
 void

          Initializes this exemption mechanism with a key and a set of algorithm parameters.
 boolean

          Returns whether the result blob has been generated successfully by this exemption mechanism.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExemptionMechanism

protected ExemptionMechanism(ExemptionMechanismSpi exmechSpi,
                             Provider provider,
                             String mechanism)
Creates a ExemptionMechanism object.

Parameters:
exmechSpi - the delegate
provider - the provider
mechanism - the exemption mechanism
Method Detail

finalize

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 Object

genExemptionBlob

public final byte[] genExemptionBlob()
                              throws IllegalStateException,
                                     ExemptionMechanismException
Generates the exemption mechanism key blob.

Returns:
the new buffer with the result key blob.
Throws:
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

public final int genExemptionBlob(byte[] output)
                           throws IllegalStateException,
                                  ShortBufferException,
                                  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 {@link #getOutputSize(int) 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:
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

public final int genExemptionBlob(byte[] output,
                                  int outputOffset)
                           throws IllegalStateException,
                                  ShortBufferException,
                                  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 {@link #getOutputSize(int) 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:
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.

getInstance

public static final ExemptionMechanism getInstance(String algorithm)
                                            throws NoSuchAlgorithmException
Generates a ExemptionMechanism object that implements the specified exemption mechanism algorithm. If the default provider package provides an implementation of the requested exemption mechanism algorithm, an instance of ExemptionMechanism containing that implementation is returned. If the exemption mechanism is not available in the default provider package, other provider packages are searched.

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:
NoSuchAlgorithmException - if the specified algorithm is not available in the default provider package or any of the other provider packages that were searched.

getInstance

public static final ExemptionMechanism getInstance(String algorithm,
                                                   Provider provider)
                                            throws NoSuchAlgorithmException
Generates a ExemptionMechanism object for the specified exemption mechanism algorithm from the specified provider. Note: the provider doesn't have to be registered.

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:
NoSuchAlgorithmException - if the specified algorithm is not available from the specified provider.

getInstance

public static final ExemptionMechanism getInstance(String algorithm,
                                                   String provider)
                                            throws NoSuchAlgorithmException,
                                                   NoSuchProviderException
Generates a ExemptionMechanism object for the specified exemption mechanism from the specified provider.

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:
NoSuchAlgorithmException - if the specified algorithm is not available from the specified provider.
NoSuchProviderException - if the specified provider has not been configured.

getName

public final 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.

getOutputSize

public final int getOutputSize(int inputLen)
                        throws IllegalStateException
Returns the length in bytes that an output buffer would need to be in order to hold the result of the next {@link #genExemptionBlob(byte[]) genExemptionBlob} operation, given the input length inputLen (in bytes).

The actual output length of the next {@link #genExemptionBlob(byte[]) 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:
IllegalStateException - if this exemption mechanism is in a wrong state (e.g., has not yet been initialized)

getProvider

public final Provider getProvider()
Returns the provider of this ExemptionMechanism object.

Returns:
the provider of this ExemptionMechanism object.

init

public final void init(Key key)
                throws InvalidKeyException,
                       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:
InvalidKeyException - if the given key is inappropriate for this exemption mechanism.
ExemptionMechanismException - if problem(s) encountered in the process of initializing.

init

public final void init(Key key,
                       AlgorithmParameters params)
                throws InvalidKeyException,
                       InvalidAlgorithmParameterException,
                       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:
InvalidKeyException - if the given key is inappropriate for this exemption mechanism.
InvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for this exemption mechanism.
ExemptionMechanismException - if problem(s) encountered in the process of initializing.

init

public final void init(Key key,
                       AlgorithmParameterSpec params)
                throws InvalidKeyException,
                       InvalidAlgorithmParameterException,
                       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:
InvalidKeyException - if the given key is inappropriate for this exemption mechanism.
InvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for this exemption mechanism.
ExemptionMechanismException - if problem(s) encountered in the process of initializing.

isCryptoAllowed

public final boolean isCryptoAllowed(Key key)
                              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.


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.