- java.lang.Object
-
- javax.xml.crypto.dsig.TransformService
-
- All Implemented Interfaces:
- AlgorithmMethod, Transform, XMLStructure
public abstract class TransformService extends Object implements Transform
A Service Provider Interface for transform and canonicalization algorithms.Each instance of
TransformService
supports a specific transform or canonicalization algorithm and XML mechanism type. To create aTransformService
, call one of the staticgetInstance
methods, passing in the algorithm URI and XML mechanism type desired, for example:TransformService ts = TransformService.getInstance(Transform.XPATH2, "DOM");
TransformService
implementations are registered and loaded using theProvider
mechanism. EachTransformService
service provider implementation should include aMechanismType
service attribute that identifies the XML mechanism type that it supports. If the attribute is not specified, "DOM" is assumed. For example, a service provider that supports the XPath Filter 2 Transform and DOM mechanism would be specified in theProvider
subclass as:put("TransformService." + Transform.XPATH2, "org.example.XPath2TransformService"); put("TransformService." + Transform.XPATH2 + " MechanismType", "DOM");
TransformService
implementations that support the DOM mechanism type must abide by the DOM interoperability requirements defined in the DOM Mechanism Requirements section of the API overview. See the Service Providers section of the API overview for a list of standard mechanism types.Once a
TransformService
has been created, it can be used to processTransform
orCanonicalizationMethod
objects. If theTransform
orCanonicalizationMethod
exists in XML form (for example, when validating an existingXMLSignature
), theinit(XMLStructure, XMLCryptoContext)
method must be first called to initialize the transform and provide document context (even if there are no parameters). Alternatively, if theTransform
orCanonicalizationMethod
is being created from scratch, theinit(TransformParameterSpec)
method is called to initialize the transform with parameters and themarshalParams
method is called to marshal the parameters to XML and provide the transform with document context. Finally, thetransform
method is called to perform the transformation.Concurrent Access
The static methods of this class are guaranteed to be thread-safe. Multiple threads may concurrently invoke the static methods defined in this class with no ill effects.
However, this is not true for the non-static methods defined by this class. Unless otherwise documented by a specific provider, threads that need to access a single
TransformService
instance concurrently should synchronize amongst themselves and provide the necessary locking. Multiple threads each manipulating a differentTransformService
instance need not synchronize.- Since:
- 1.6
-
-
Constructor Summary
Constructors Modifier Constructor and Description protected
TransformService()
Default constructor, for invocation by subclasses.
-
Method Summary
Methods Modifier and Type Method and Description String
getAlgorithm()
Returns the URI of the algorithm supported by thisTransformService
.static TransformService
getInstance(String algorithm, String mechanismType)
Returns aTransformService
that supports the specified algorithm URI (ex:Transform.XPATH2
) and mechanism type (ex: DOM).static TransformService
getInstance(String algorithm, String mechanismType, Provider provider)
Returns aTransformService
that supports the specified algorithm URI (ex:Transform.XPATH2
) and mechanism type (ex: DOM) as supplied by the specified provider.static TransformService
getInstance(String algorithm, String mechanismType, String provider)
Returns aTransformService
that supports the specified algorithm URI (ex:Transform.XPATH2
) and mechanism type (ex: DOM) as supplied by the specified provider.String
getMechanismType()
Returns the mechanism type supported by thisTransformService
.Provider
getProvider()
Returns the provider of thisTransformService
.abstract void
init(TransformParameterSpec params)
Initializes thisTransformService
with the specified parameters.abstract void
init(XMLStructure parent, XMLCryptoContext context)
Initializes thisTransformService
with the specified parameters and document context.abstract void
marshalParams(XMLStructure parent, XMLCryptoContext context)
Marshals the algorithm-specific parameters.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.xml.crypto.dsig.Transform
getParameterSpec, transform, transform
-
Methods inherited from interface javax.xml.crypto.XMLStructure
isFeatureSupported
-
-
-
-
Constructor Detail
-
TransformService
protected TransformService()
Default constructor, for invocation by subclasses.
-
-
Method Detail
-
getInstance
public static TransformService getInstance(String algorithm, String mechanismType) throws NoSuchAlgorithmException
Returns aTransformService
that supports the specified algorithm URI (ex:Transform.XPATH2
) and mechanism type (ex: DOM).This method uses the standard JCA provider lookup mechanism to locate and instantiate a
TransformService
implementation of the desired algorithm andMechanismType
service attribute. It traverses the list of registered securityProvider
s, starting with the most preferredProvider
. A newTransformService
object from the firstProvider
that supports the specified algorithm and mechanism type is returned.Note that the list of registered providers may be retrieved via the
Security.getProviders()
method.- Parameters:
algorithm
- the URI of the algorithmmechanismType
- the type of the XML processing mechanism and representation- Returns:
- a new
TransformService
- Throws:
NullPointerException
- ifalgorithm
ormechanismType
isnull
NoSuchAlgorithmException
- if noProvider
supports aTransformService
implementation for the specified algorithm and mechanism type- See Also:
Provider
-
getInstance
public static TransformService getInstance(String algorithm, String mechanismType, Provider provider) throws NoSuchAlgorithmException
Returns aTransformService
that supports the specified algorithm URI (ex:Transform.XPATH2
) and mechanism type (ex: DOM) as supplied by the specified provider. Note that the specifiedProvider
object does not have to be registered in the provider list.- Parameters:
algorithm
- the URI of the algorithmmechanismType
- the type of the XML processing mechanism and representationprovider
- theProvider
object- Returns:
- a new
TransformService
- Throws:
NullPointerException
- ifprovider
,algorithm
, ormechanismType
isnull
NoSuchAlgorithmException
- if aTransformService
implementation for the specified algorithm and mechanism type is not available from the specifiedProvider
object- See Also:
Provider
-
getInstance
public static TransformService getInstance(String algorithm, String mechanismType, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
Returns aTransformService
that supports the specified algorithm URI (ex:Transform.XPATH2
) and mechanism type (ex: DOM) as supplied by the specified provider. 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 URI of the algorithmmechanismType
- the type of the XML processing mechanism and representationprovider
- the string name of the provider- Returns:
- a new
TransformService
- Throws:
NoSuchProviderException
- if the specified provider is not registered in the security provider listNullPointerException
- ifprovider
,mechanismType
, oralgorithm
isnull
NoSuchAlgorithmException
- if aTransformService
implementation for the specified algorithm and mechanism type is not available from the specified provider- See Also:
Provider
-
getMechanismType
public final String getMechanismType()
Returns the mechanism type supported by thisTransformService
.- Returns:
- the mechanism type
-
getAlgorithm
public final String getAlgorithm()
Returns the URI of the algorithm supported by thisTransformService
.- Specified by:
getAlgorithm
in interfaceAlgorithmMethod
- Returns:
- the algorithm URI
-
getProvider
public final Provider getProvider()
Returns the provider of thisTransformService
.- Returns:
- the provider
-
init
public abstract void init(TransformParameterSpec params) throws InvalidAlgorithmParameterException
Initializes thisTransformService
with the specified parameters.If the parameters exist in XML form, the
init(XMLStructure, XMLCryptoContext)
method should be used to initialize theTransformService
.- Parameters:
params
- the algorithm parameters (may benull
if not required or optional)- Throws:
InvalidAlgorithmParameterException
- if the specified parameters are invalid for this algorithm
-
marshalParams
public abstract void marshalParams(XMLStructure parent, XMLCryptoContext context) throws MarshalException
Marshals the algorithm-specific parameters. If there are no parameters to be marshalled, this method returns without throwing an exception.- Parameters:
parent
- a mechanism-specific structure containing the parent node that the marshalled parameters should be appended tocontext
- theXMLCryptoContext
containing additional context (may benull
if not applicable)- Throws:
ClassCastException
- if the type ofparent
orcontext
is not compatible with thisTransformService
NullPointerException
- ifparent
isnull
MarshalException
- if the parameters cannot be marshalled
-
init
public abstract void init(XMLStructure parent, XMLCryptoContext context) throws InvalidAlgorithmParameterException
Initializes thisTransformService
with the specified parameters and document context.- Parameters:
parent
- a mechanism-specific structure containing the parent structurecontext
- theXMLCryptoContext
containing additional context (may benull
if not applicable)- Throws:
ClassCastException
- if the type ofparent
orcontext
is not compatible with thisTransformService
NullPointerException
- ifparent
isnull
InvalidAlgorithmParameterException
- if the specified parameters are invalid for this algorithm
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
25/11/2024 04:17:26 Cette version de la page est en cache (à la date du 25/11/2024 04:17:26) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 11/06/2005, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/xml/crypto/dsig/transformservice.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.