ExemptionMechanism (Java SE 15 & JDK 15) (original) (raw)
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.
Since:
1.4
Constructor Summary
Method Summary
Modifier and Type | Method | Description |
---|---|---|
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 outputOffset) | Generates the exemption mechanism key blob, and stores the result in the output buffer, starting at outputOffset inclusive. |
static ExemptionMechanism | getInstance(String algorithm) | Returns an ExemptionMechanism object that implements the specified exemption mechanism algorithm. |
static ExemptionMechanism | getInstance(String algorithm,String provider) | Returns an ExemptionMechanism object that implements the specified exemption mechanism algorithm. |
static ExemptionMechanism | getInstance(String algorithm,Provider provider) | Returns an ExemptionMechanism object that implements the specified exemption mechanism algorithm. |
String | getName() | Returns the exemption mechanism name of thisExemptionMechanism 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 nextgenExemptionBlob 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 declared in class java.lang.Object
[clone](../../java/lang/Object.html#clone%28%29), [equals](../../java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../java/lang/Object.html#finalize%28%29), [getClass](../../java/lang/Object.html#getClass%28%29), [hashCode](../../java/lang/Object.html#hashCode%28%29), [notify](../../java/lang/Object.html#notify%28%29), [notifyAll](../../java/lang/Object.html#notifyAll%28%29), [toString](../../java/lang/Object.html#toString%28%29), [wait](../../java/lang/Object.html#wait%28%29), [wait](../../java/lang/Object.html#wait%28long%29), [wait](../../java/lang/Object.html#wait%28long,int%29)
Constructor Details
ExemptionMechanism
Creates a ExemptionMechanism object.
Parameters:
exmechSpi
- the delegate
provider
- the provider
mechanism
- the exemption mechanismMethod Details
getName
public final String getName()
Returns the exemption mechanism name of thisExemptionMechanism
object.
This is the same name that was specified in one of thegetInstance
calls that created thisExemptionMechanism
object.
Returns:
the exemption mechanism name of thisExemptionMechanism
object.getInstance
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.
Implementation Note:
The JDK Reference Implementation additionally uses thejdk.security.provider.preferred
Security property to determine the preferred provider order for the specified algorithm. This may be different than the order of providers returned bySecurity.getProviders().
Parameters:
algorithm
- the standard name of the requested exemption mechanism. See the ExemptionMechanism section in the Java Security Standard Algorithm Names Specification for information about standard exemption mechanism names.
Returns:
the newExemptionMechanism
object
Throws:
[NoSuchAlgorithmException](../../java/security/NoSuchAlgorithmException.html "class in java.security")
- if noProvider
supports anExemptionMechanismSpi
implementation for the specified algorithm
[NullPointerException](../../java/lang/NullPointerException.html "class in java.lang")
- ifalgorithm
isnull
See Also:
ProvidergetInstance
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 the ExemptionMechanism section in the Java Security Standard Algorithm Names Specification for information about standard exemption mechanism names.
provider
- the name of the provider.
Returns:
the newExemptionMechanism
object
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if theprovider
isnull
or empty
[NoSuchAlgorithmException](../../java/security/NoSuchAlgorithmException.html "class in java.security")
- if anExemptionMechanismSpi
implementation for the specified algorithm is not available from the specified provider
[NoSuchProviderException](../../java/security/NoSuchProviderException.html "class in java.security")
- if the specified provider is not registered in the security provider list
[NullPointerException](../../java/lang/NullPointerException.html "class in java.lang")
- ifalgorithm
isnull
See Also:
ProvidergetInstance
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 the ExemptionMechanism section in the Java Security Standard Algorithm Names Specification for information about standard exemption mechanism names.
provider
- the provider.
Returns:
the newExemptionMechanism
object
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if theprovider
is null
[NoSuchAlgorithmException](../../java/security/NoSuchAlgorithmException.html "class in java.security")
- if anExemptionMechanismSpi
implementation for the specified algorithm is not available from the specifiedProvider object
[NullPointerException](../../java/lang/NullPointerException.html "class in java.lang")
- ifalgorithm
isnull
See Also:
ProvidergetProvider
public final Provider getProvider()
Returns the provider of thisExemptionMechanism
object.
Returns:
the provider of thisExemptionMechanism
object.isCryptoAllowed
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 ifkey
is null.
Throws:
[ExemptionMechanismException](ExemptionMechanismException.html "class in javax.crypto")
- if problem(s) encountered while determining whether the result blob has been generated successfully by this exemption mechanism object.getOutputSize
Returns the length in bytes that an output buffer would need to be in order to hold the result of the nextgenExemptionBlob operation, given the input length
inputLen
(in bytes).
The actual output length of the nextgenExemptionBlob 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](../../java/lang/IllegalStateException.html "class in java.lang")
- if this exemption mechanism is in a wrong state (e.g., has not yet been initialized)init
Initializes this exemption mechanism with a key.
If this exemption mechanism requires any algorithm parameters that cannot be derived from the givenkey
, 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, anInvalidKeyException
is raised.
Parameters:
key
- the key for this exemption mechanism
Throws:
[InvalidKeyException](../../java/security/InvalidKeyException.html "class in java.security")
- if the given key is inappropriate for this exemption mechanism.
[ExemptionMechanismException](ExemptionMechanismException.html "class in javax.crypto")
- if problem(s) encountered in the process of initializing.init
Initializes this exemption mechanism with a key and a set of algorithm parameters.
If this exemption mechanism requires any algorithm parameters andparams
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, anInvalidAlgorithmParameterException
is raised.
Parameters:
key
- the key for this exemption mechanism
params
- the algorithm parameters
Throws:
[InvalidKeyException](../../java/security/InvalidKeyException.html "class in java.security")
- if the given key is inappropriate for this exemption mechanism.
[InvalidAlgorithmParameterException](../../java/security/InvalidAlgorithmParameterException.html "class in java.security")
- if the given algorithm parameters are inappropriate for this exemption mechanism.
[ExemptionMechanismException](ExemptionMechanismException.html "class in javax.crypto")
- if problem(s) encountered in the process of initializing.init
Initializes this exemption mechanism with a key and a set of algorithm parameters.
If this exemption mechanism requires any algorithm parameters andparams
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, anInvalidAlgorithmParameterException
is raised.
Parameters:
key
- the key for this exemption mechanism
params
- the algorithm parameters
Throws:
[InvalidKeyException](../../java/security/InvalidKeyException.html "class in java.security")
- if the given key is inappropriate for this exemption mechanism.
[InvalidAlgorithmParameterException](../../java/security/InvalidAlgorithmParameterException.html "class in java.security")
- if the given algorithm parameters are inappropriate for this exemption mechanism.
[ExemptionMechanismException](ExemptionMechanismException.html "class in javax.crypto")
- if problem(s) encountered in the process of initializing.genExemptionBlob
Generates the exemption mechanism key blob.
Returns:
the new buffer with the result key blob.
Throws:
[IllegalStateException](../../java/lang/IllegalStateException.html "class in java.lang")
- if this exemption mechanism is in a wrong state (e.g., has not been initialized).
[ExemptionMechanismException](ExemptionMechanismException.html "class in javax.crypto")
- if problem(s) encountered in the process of generating.genExemptionBlob
Generates the exemption mechanism key blob, and stores the result in the
output
buffer.
If theoutput
buffer is too small to hold the result, aShortBufferException
is thrown. In this case, repeat this call with a larger output buffer. UsegetOutputSize to determine how big the output buffer should be.
Parameters:
output
- the buffer for the result
Returns:
the number of bytes stored inoutput
Throws:
[IllegalStateException](../../java/lang/IllegalStateException.html "class in java.lang")
- if this exemption mechanism is in a wrong state (e.g., has not been initialized).
[ShortBufferException](ShortBufferException.html "class in javax.crypto")
- if the given output buffer is too small to hold the result.
[ExemptionMechanismException](ExemptionMechanismException.html "class in javax.crypto")
- if problem(s) encountered in the process of generating.genExemptionBlob
Generates the exemption mechanism key blob, and stores the result in the
output
buffer, starting atoutputOffset
inclusive.
If theoutput
buffer is too small to hold the result, aShortBufferException
is thrown. In this case, repeat this call with a larger output buffer. UsegetOutputSize to determine how big the output buffer should be.
Parameters:
output
- the buffer for the result
outputOffset
- the offset inoutput
where the result is stored
Returns:
the number of bytes stored inoutput
Throws:
[IllegalStateException](../../java/lang/IllegalStateException.html "class in java.lang")
- if this exemption mechanism is in a wrong state (e.g., has not been initialized).
[ShortBufferException](ShortBufferException.html "class in javax.crypto")
- if the given output buffer is too small to hold the result.
[ExemptionMechanismException](ExemptionMechanismException.html "class in javax.crypto")
- if problem(s) encountered in the process of generating.