# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Protected Ctors | Methods | Inherited Methods

# ExemptionMechanism

`public class ExemptionMechanism`
`extends Object` ``

java.lang.Object
↳ | javax.crypto.ExemptionMechanism

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.

## Summary

### Protected constructors
`ExemptionMechanism(ExemptionMechanismSpi exmechSpi, Provider provider, String mechanism)` Creates a ExemptionMechanism object.

### Public methods
`final int` | `genExemptionBlob(byte[] output)` Generates the exemption mechanism key blob, and stores the result in the `output` buffer.
`final byte[]` | `genExemptionBlob()` Generates the exemption mechanism key blob.
`final 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 final ExemptionMechanism` | `getInstance(String algorithm)` Returns an `ExemptionMechanism` object that implements the specified exemption mechanism algorithm.
`static final ExemptionMechanism` | `getInstance(String algorithm, String provider)` Returns an `ExemptionMechanism` object that implements the specified exemption mechanism algorithm.
`static final ExemptionMechanism` | `getInstance(String algorithm, Provider provider)` Returns an `ExemptionMechanism` object that implements the specified exemption mechanism algorithm.
`final String` | `getName()` Returns the exemption mechanism name of this `ExemptionMechanism` object.
`final 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 `genExemptionBlob` operation, given the input length `inputLen` (in bytes).
`final Provider` | `getProvider()` Returns the provider of this `ExemptionMechanism` object.
`final void` | `init(Key key, AlgorithmParameters params)` Initializes this exemption mechanism with a key and a set of algorithm parameters.
`final void` | `init(Key key, AlgorithmParameterSpec params)` Initializes this exemption mechanism with a key and a set of algorithm parameters.
`final void` | `init(Key key)` Initializes this exemption mechanism with a key.
`final boolean` | `isCryptoAllowed(Key key)` Returns whether the result blob has been generated successfully by this exemption mechanism.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Protected constructors

### ExemptionMechanism

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

Creates a ExemptionMechanism object.

Parameters
`exmechSpi` | `ExemptionMechanismSpi`: the delegate
`provider` | `Provider`: the provider
`mechanism` | `String`: the exemption mechanism

## Public methods

### genExemptionBlob

    public final int genExemptionBlob (byte[] output)

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` | `byte`: the buffer for the result

Returns
`int` | 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 byte[] genExemptionBlob ()

Generates the exemption mechanism key blob.

Returns
`byte[]` | 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,
                    int outputOffset)

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` | `byte`: the buffer for the result
`outputOffset` | `int`: the offset in `output` where the result is stored

Returns
`int` | 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)

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` | `String`: the standard name of the requested exemption mechanism. See the ExemptionMechanism section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard exemption mechanism names.

Returns
`ExemptionMechanism` | the new `ExemptionMechanism` object.

Throws
`NullPointerException` | if `algorithm` is null.
`NoSuchAlgorithmException` | if no Provider supports an ExemptionMechanismSpi implementation for the specified algorithm.

See also:

- `Provider`

### getInstance

    public static final ExemptionMechanism getInstance (String algorithm,
                    String provider)

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` | `String`: the standard name of the requested exemption mechanism. See the ExemptionMechanism section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard exemption mechanism names.
`provider` | `String`: the name of the provider.

Returns
`ExemptionMechanism` | the new `ExemptionMechanism` object.

Throws
`NullPointerException` | if `algorithm` is null.
`NoSuchAlgorithmException` | if an ExemptionMechanismSpi implementation for the specified algorithm is not available from the specified provider.
`NoSuchProviderException` | if the specified provider is not registered in the security provider list.
`IllegalArgumentException` | if the `provider` is null or empty.

See also:

- `Provider`

### getInstance

    public static final ExemptionMechanism getInstance (String algorithm,
                    Provider provider)

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` | `String`: the standard name of the requested exemption mechanism. See the ExemptionMechanism section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard exemption mechanism names.
`provider` | `Provider`: the provider.

Returns
`ExemptionMechanism` | the new `ExemptionMechanism` object.

Throws
`NullPointerException` | if `algorithm` is null.
`NoSuchAlgorithmException` | if an ExemptionMechanismSpi implementation for the specified algorithm is not available from the specified Provider object.
`IllegalArgumentException` | if the `provider` is null.

See also:

- `Provider`

### 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
`String` | the exemption mechanism name of this `ExemptionMechanism` object.

### getOutputSize

    public final 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 `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` | `int`: the input length (in bytes)

Returns
`int` | 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
`Provider` | the provider of this `ExemptionMechanism` object.

### init

    public final void init (Key key,
                    AlgorithmParameters params)

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` | `Key`: the key for this exemption mechanism
`params` | `AlgorithmParameters`: 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)

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` | `Key`: the key for this exemption mechanism
`params` | `AlgorithmParameterSpec`: 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)

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` | `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.

### isCryptoAllowed

    public final boolean isCryptoAllowed (Key key)

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` | `Key`: the key the crypto is going to use.

Returns
`boolean` | 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.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*