- java.lang.Object
-
- javax.crypto.ExemptionMechanism
-
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
Constructors Modifier Constructor and Description protected
ExemptionMechanism(ExemptionMechanismSpi exmechSpi, Provider provider, String mechanism)
Creates a ExemptionMechanism object.
-
Method Summary
Methods Modifier and Type Method and Description 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 theoutput
buffer.int
genExemptionBlob(byte[] output, int outputOffset)
Generates the exemption mechanism key blob, and stores the result in theoutput
buffer, starting atoutputOffset
inclusive.static ExemptionMechanism
getInstance(String algorithm)
Returns anExemptionMechanism
object that implements the specified exemption mechanism algorithm.static ExemptionMechanism
getInstance(String algorithm, Provider provider)
Returns anExemptionMechanism
object that implements the specified exemption mechanism algorithm.static ExemptionMechanism
getInstance(String algorithm, String provider)
Returns anExemptionMechanism
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 lengthinputLen
(in bytes).Provider
getProvider()
Returns the provider of thisExemptionMechanism
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.
-
-
-
Constructor Detail
-
ExemptionMechanism
protected ExemptionMechanism(ExemptionMechanismSpi exmechSpi, Provider provider, String mechanism)
Creates a ExemptionMechanism object.- Parameters:
exmechSpi
- the delegateprovider
- the providermechanism
- the exemption mechanism
-
-
Method Detail
-
getName
public final String getName()
Returns the exemption mechanism name of thisExemptionMechanism
object.This is the same name that was specified in one of the
getInstance
calls that created thisExemptionMechanism
object.- Returns:
- the exemption mechanism name of this
ExemptionMechanism
object.
-
getInstance
public static final ExemptionMechanism getInstance(String algorithm) throws NoSuchAlgorithmException
Returns anExemptionMechanism
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
- 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:
- the new
ExemptionMechanism
object. - Throws:
NullPointerException
- ifalgorithm
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) throws NoSuchAlgorithmException, NoSuchProviderException
Returns anExemptionMechanism
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 Cryptography Architecture Standard Algorithm Name Documentation for information about standard exemption mechanism names.provider
- the name of the provider.- Returns:
- the new
ExemptionMechanism
object. - Throws:
NullPointerException
- ifalgorithm
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 theprovider
is null or empty.- See Also:
Provider
-
getInstance
public static final ExemptionMechanism getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
Returns anExemptionMechanism
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 Cryptography Architecture Standard Algorithm Name Documentation for information about standard exemption mechanism names.provider
- the provider.- Returns:
- the new
ExemptionMechanism
object. - Throws:
NullPointerException
- ifalgorithm
is null.NoSuchAlgorithmException
- if an ExemptionMechanismSpi implementation for the specified algorithm is not available from the specified Provider object.IllegalArgumentException
- if theprovider
is null.- See Also:
Provider
-
getProvider
public final Provider getProvider()
Returns the provider of thisExemptionMechanism
object.- Returns:
- the provider of this
ExemptionMechanism
object.
-
isCryptoAllowed
public final boolean isCryptoAllowed(Key key) throws ExemptionMechanismException
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 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.
-
getOutputSize
public final int getOutputSize(int inputLen) throws IllegalStateException
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 lengthinputLen
(in bytes).The actual output length of the next
genExemptionBlob
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
- if this exemption mechanism is in a wrong state (e.g., has not yet been initialized)
-
init
public final void init(Key key) throws InvalidKeyException, ExemptionMechanismException
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, anInvalidKeyException
is raised.- Parameters:
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.
-
init
public final void init(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException, ExemptionMechanismException
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, anInvalidAlgorithmParameterException
is raised.- Parameters:
key
- the key for this exemption mechanismparams
- 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, AlgorithmParameters params) throws InvalidKeyException, InvalidAlgorithmParameterException, ExemptionMechanismException
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, anInvalidAlgorithmParameterException
is raised.- Parameters:
key
- the key for this exemption mechanismparams
- 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.
-
genExemptionBlob
public final byte[] genExemptionBlob() throws IllegalStateException, ExemptionMechanismException
Generates the exemption mechanism key blob.- Returns:
- 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) throws IllegalStateException, ShortBufferException, ExemptionMechanismException
Generates the exemption mechanism key blob, and stores the result in theoutput
buffer.If the
output
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 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 int genExemptionBlob(byte[] output, int outputOffset) throws IllegalStateException, ShortBufferException, ExemptionMechanismException
Generates the exemption mechanism key blob, and stores the result in theoutput
buffer, starting atoutputOffset
inclusive.If the
output
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 resultoutputOffset
- the offset inoutput
where the result is stored- Returns:
- 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.
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/crypto/exemptionmechanism.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.