public class ExemptionMechanism extends Object
Applications or applets that use an exemption mechanism may be granted stronger encryption capabilities than those which don't.
Modifier | Constructor | Description |
---|---|---|
protected |
Creates an ExemptionMechanism object. |
Modifier and Type | Method | Description |
---|---|---|
final byte[] |
genExemptionBlob() |
Generates the exemption mechanism key blob. |
final int |
genExemptionBlob |
Generates the exemption mechanism key blob, and stores the result in the output buffer. |
final int |
genExemptionBlob |
Generates the exemption mechanism key blob, and stores the result in the output buffer, starting at outputOffset inclusive. |
static final ExemptionMechanism |
getInstance |
Returns an ExemptionMechanism object that implements the specified exemption mechanism algorithm. |
static final ExemptionMechanism |
getInstance |
Returns an ExemptionMechanism object that implements the specified exemption mechanism algorithm. |
static final ExemptionMechanism |
getInstance |
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 |
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 |
Initializes this exemption mechanism with a key. |
final void |
init |
Initializes this exemption mechanism with a key and a set of algorithm parameters. |
final void |
init |
Initializes this exemption mechanism with a key and a set of algorithm parameters. |
final boolean |
isCryptoAllowed |
Returns whether the result blob has been generated successfully by this exemption mechanism. |
protected ExemptionMechanism(ExemptionMechanismSpi exmechSpi, Provider provider, String mechanism)
ExemptionMechanism
object.exmechSpi
- the delegateprovider
- the providermechanism
- the exemption mechanismpublic 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. 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.
jdk.security.provider.preferred
Security
property to determine the preferred provider order for the specified algorithm. This may be different from the order of providers returned by Security.getProviders()
.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.ExemptionMechanism
objectNoSuchAlgorithmException
- if no Provider
supports an ExemptionMechanismSpi
implementation for the specified algorithmNullPointerException
- if algorithm
is null
public static final ExemptionMechanism getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, 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 the ExemptionMechanism section in the Java Security Standard Algorithm Names Specification for information about standard exemption mechanism names.provider
- the name of the provider.ExemptionMechanism
objectIllegalArgumentException
- if the provider
is null
or emptyNoSuchAlgorithmException
- if an ExemptionMechanismSpi
implementation for the specified algorithm is not available from the specified providerNoSuchProviderException
- if the specified provider is not registered in the security provider listNullPointerException
- if algorithm
is null
public static final ExemptionMechanism getInstance(String algorithm, Provider provider) throws 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 the ExemptionMechanism section in the Java Security Standard Algorithm Names Specification for information about standard exemption mechanism names.provider
- the provider.ExemptionMechanism
objectIllegalArgumentException
- if the provider
is null
NoSuchAlgorithmException
- if an ExemptionMechanismSpi
implementation for the specified algorithm is not available from the specified Provider
objectNullPointerException
- if algorithm
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.false
if 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)IllegalStateException
- if this exemption mechanism is in a wrong state (e.g., has not yet been initialized)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 mechanismInvalidKeyException
- 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 parametersInvalidKeyException
- 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 parametersInvalidKeyException
- 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
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 resultoutput
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 outputOffset) throws 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 resultoutputOffset
- the offset in output
where the result is storedoutput
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.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/crypto/ExemptionMechanism.html