|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.crypto.ExemptionMechanism
public class 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.
TODO: This class is not fully implemented, yet!
Field Summary | |
---|---|
(package private) boolean |
done_
States wether the exemption blob has been generated. |
(package private) ExemptionMechanismSpi |
exmechSpi_
The exemption mechanism implementation used by this instance. |
(package private) boolean |
init_
States wether this exemption mechanism has been initialised. |
(package private) Key |
key_
The key for this exemption mechanism. |
(package private) String |
mechanism_
The exemption mechanism used by this instance. |
(package private) Provider |
provider_
The provider used by this instance. |
Constructor Summary | |
---|---|
protected |
ExemptionMechanism(ExemptionMechanismSpi exmechSpi,
Provider provider,
String mechanism)
Creates a new ExemptionMechanism object. |
Method Summary | |
---|---|
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. |
byte[] |
genExemptionBlob()
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 offset)
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 |
getName()
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 genExemptionBlob operation,
given the input length inputLen (in bytes). |
Provider |
getProvider()
Returns the provider of this ExemptionMechanism object. |
void |
init(Key key)
Initializes this exemption mechanism with a key. |
void |
init(Key key,
AlgorithmParameters params)
Initializes this exemption mechanism with a key and a set of algorithm parameters. |
void |
init(Key key,
AlgorithmParameterSpec params)
Initializes this exemption mechanism with a key and a set of algorithm parameters. |
boolean |
isCryptoAllowed(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 |
Field Detail |
---|
ExemptionMechanismSpi exmechSpi_
Provider provider_
String mechanism_
boolean init_
boolean done_
Key key_
Constructor Detail |
---|
protected ExemptionMechanism(ExemptionMechanismSpi exmechSpi, Provider provider, String mechanism)
exmechSpi
- the delegate.provider
- the provider.mechanism
- the exemption mechanism.Method Detail |
---|
public final 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.public static final ExemptionMechanism getInstance(String algorithm) throws NoSuchAlgorithmException
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.
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
NullPointerException
- if algorithm
is null.
NoSuchAlgorithmException
- if the specified algorithm is not
available in the default provider package or any of the other
provider packages that were searched.public static final ExemptionMechanism getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
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
NullPointerException
- if algorithm
is null.
NoSuchAlgorithmException
- if the specified algorithm is not
available from the specified provider.
NoSuchProviderException
- if the specified provider has not
been configured.
IllegalArgumentException
- if the provider
is null.public static final ExemptionMechanism getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
ExemptionMechanism
object for the specified
exemption mechanism algorithm from the specified provider.
Note: the provider
doesn't have to be registered.
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
NullPointerException
- if algorithm
is null.
NoSuchAlgorithmException
- if the specified algorithm is not
available from the specified provider.
IllegalArgumentException
- if the provider
is null.public final Provider getProvider()
ExemptionMechanism
object.
ExemptionMechanism
object.public final boolean isCryptoAllowed(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.public final int getOutputSize(int inputLen) throws 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).
IllegalArgumentException
- if this exemption mechanism is in a
wrong state (e.g., has not yet been initialized)
IllegalStateException
public final void init(Key key) throws 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.
InvalidKeyException
- if the given key is inappropriate for this
exemption mechanism.
ExemptionMechanismException
- if problem(s) encountered in the
process of initializing.public final void init(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, 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 mechanismparams
- the algorithm parameters
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.public final void init(Key key, AlgorithmParameters params) throws InvalidKeyException, 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 mechanismparams
- the algorithm parameters
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.public final byte[] genExemptionBlob() throws IllegalStateException, ExemptionMechanismException
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.public final int genExemptionBlob(byte[] output) throws IllegalStateException, ShortBufferException, ExemptionMechanismException
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
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.public final int genExemptionBlob(byte[] output, int offset) throws IllegalStateException, ShortBufferException, ExemptionMechanismException
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 resultoffset
- the offset in output where the result is stored
output
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.protected void finalize()
finalize
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |