javax.crypto
Class ExemptionMechanism
- java.lang.Object
javax.crypto.ExemptionMechanism
- public class ExemptionMechanism
- extends java.lang.Object
Applications or applets that use an exemption mechanism may be granted stronger encryption capabilities than those which don't.
Constructor Summary
Modifier | Constructor and Description |
---|---|
|
ExemptionMechanism(ExemptionMechanismSpi exmechSpi,java.security.Provider provider,java.lang.String mechanism)
Creates a ExemptionMechanism object.
|
Method Summary
Modifier and Type | Method and Description |
---|---|
|
finalize()
Ensures that the key stored away by this ExemptionMechanism
object will be wiped out when there are no more references to it.
|
|
genExemptionBlob()
Generates the exemption mechanism key blob.
|
|
genExemptionBlob(byte[] output)
Generates the exemption mechanism key blob, and stores the result in
the
output buffer.
|
|
genExemptionBlob(byte[] output,int outputOffset)
Generates the exemption mechanism key blob, and stores the result in
the
output buffer, starting at outputOffset
inclusive.
|
|
getInstance(java.lang.String algorithm)
Returns an
ExemptionMechanism object that implements the
specified exemption mechanism algorithm.
|
|
getInstance(java.lang.String algorithm,java.security.Provider provider)
Returns an
ExemptionMechanism object that implements the
specified exemption mechanism algorithm.
|
|
getInstance(java.lang.String algorithm,java.lang.String provider)
Returns an
ExemptionMechanism object that implements the
specified exemption mechanism algorithm.
|
|
getName()
Returns the exemption mechanism name of this
ExemptionMechanism object.
|
|
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).
|
|
getProvider()
Returns the provider of this
ExemptionMechanism object.
|
|
init(java.security.Key key)
Initializes this exemption mechanism with a key.
|
|
init(java.security.Key key,java.security.AlgorithmParameters params)
Initializes this exemption mechanism with a key and a set of algorithm
parameters.
|
|
init(java.security.Key key,java.security.spec.AlgorithmParameterSpec params)
Initializes this exemption mechanism with a key and a set of algorithm
parameters.
|
|
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
- protected ExemptionMechanism(ExemptionMechanismSpi exmechSpi,
- java.security.Provider provider,
- java.lang.String mechanism)
exmechSpi
- the delegate provider
- the provider mechanism
- the exemption mechanism Method Detail
getName
- public final java.lang.String getName( )
ExemptionMechanism
object.
This is the same name that was specified in one of the
getInstance
calls that created this
ExemptionMechanism
object.
ExemptionMechanism
object. getInstance
- public static final ExemptionMechanism getInstance( java.lang.String algorithm)
- throws java.security.NoSuchAlgorithmException
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.
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. ExemptionMechanism
object. java.lang.NullPointerException
- if algorithm
is null. java.security.NoSuchAlgorithmException
- if no Provider supports an
ExemptionMechanismSpi implementation for the
specified algorithm. Provider
getInstance
- public static final ExemptionMechanism getInstance( java.lang.String algorithm,
- java.lang.String provider)
- throws java.security.NoSuchAlgorithmException
- java.security.NoSuchProviderException
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.
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 ExemptionMechanism
object. 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. Provider
getInstance
- public static final ExemptionMechanism getInstance( java.lang.String algorithm,
- java.security.Provider provider)
- throws java.security.NoSuchAlgorithmException
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.
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. ExemptionMechanism
object. 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. Provider
getProvider
- public final java.security.Provider getProvider( )
ExemptionMechanism
object.
ExemptionMechanism
object. isCryptoAllowed
- public final boolean isCryptoAllowed( java.security.Key key)
- throws ExemptionMechanismException
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.
key
- the key the crypto is going to use. key
is null. ExemptionMechanismException
- if problem(s) encountered
while determining whether the result blob has been generated successfully
by this exemption mechanism object. getOutputSize
- public final int getOutputSize( int inputLen)
- throws java.lang.IllegalStateException
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.
inputLen
- the input length (in bytes) java.lang.IllegalStateException
- if this exemption mechanism is in a
wrong state (e.g., has not yet been initialized) init
- public final void init(java.security.Key key)
- throws java.security.InvalidKeyException
- ExemptionMechanismException
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.
key
- the key for this exemption mechanism java.security.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(java.security.Key key,
- java.security.spec.AlgorithmParameterSpec params)
- throws java.security.InvalidKeyException
- java.security.InvalidAlgorithmParameterException
- ExemptionMechanismException
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.
key
- the key for this exemption mechanism params
- the algorithm parameters 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
- public final void init(java.security.Key key,
- java.security.AlgorithmParameters params)
- throws java.security.InvalidKeyException
- java.security.InvalidAlgorithmParameterException
- ExemptionMechanismException
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.
key
- the key for this exemption mechanism params
- the algorithm parameters 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
- public final byte[] genExemptionBlob( )
- throws java.lang.IllegalStateException
- ExemptionMechanismException
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
- public final int genExemptionBlob( byte[] output)
- throws java.lang.IllegalStateException
- ShortBufferException
- ExemptionMechanismException
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.
output
- the buffer for the result output
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
- public final int genExemptionBlob( byte[] output,
- int outputOffset)
- throws java.lang.IllegalStateException
- ShortBufferException
- ExemptionMechanismException
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.
output
- the buffer for the result outputOffset
- the offset in output
where the result
is stored output
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
- protected void finalize()
finalize
in class java.lang.Object