TransformService (Java Platform SE 6) (original) (raw)
javax.xml.crypto.dsig
Class TransformService
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 a TransformService
, call one of the static [getInstance](../../../../javax/xml/crypto/dsig/TransformService.html#getInstance%28java.lang.String, java.lang.String%29) 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 the Provider mechanism. Each TransformService
service provider implementation should include a MechanismType
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 the Provider
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](../../../../../technotes/guides/security/xmldsig/overview.html#DOM Mechanism Requirements) section of the API overview. See the[ Service Providers](../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider) section of the API overview for a list of standard mechanism types.
Once a TransformService
has been created, it can be used to process Transform
or CanonicalizationMethod
objects. If the Transform
or CanonicalizationMethod
exists in XML form (for example, when validating an existing XMLSignature
), the [init(XMLStructure, XMLCryptoContext)](../../../../javax/xml/crypto/dsig/TransformService.html#init%28javax.xml.crypto.XMLStructure, javax.xml.crypto.XMLCryptoContext%29) method must be first called to initialize the transform and provide document context (even if there are no parameters). Alternatively, if the Transform
or CanonicalizationMethod
is being created from scratch, the init(TransformParameterSpec) method is called to initialize the transform with parameters and the [marshalParams](../../../../javax/xml/crypto/dsig/TransformService.html#marshalParams%28javax.xml.crypto.XMLStructure, javax.xml.crypto.XMLCryptoContext%29) method is called to marshal the parameters to XML and provide the transform with document context. Finally, the [transform](../../../../javax/xml/crypto/dsig/Transform.html#transform%28javax.xml.crypto.Data, javax.xml.crypto.XMLCryptoContext%29) 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
Field Summary |
---|
Fields inherited from interface javax.xml.crypto.dsig.Transform |
---|
BASE64, ENVELOPED, XPATH, XPATH2, XSLT |
Constructor Summary | |
---|---|
protected | TransformService() Default constructor, for invocation by subclasses. |
Method Summary | |
---|---|
String | getAlgorithm() Returns the URI of the algorithm supported by thisTransformService. |
static TransformService | [getInstance](../../../../javax/xml/crypto/dsig/TransformService.html#getInstance%28java.lang.String, java.lang.String%29)(String algorithm,String mechanismType) Returns a TransformService that supports the specified algorithm URI (ex: Transform.XPATH2) and mechanism type (ex: DOM). |
static TransformService | [getInstance](../../../../javax/xml/crypto/dsig/TransformService.html#getInstance%28java.lang.String, java.lang.String, java.security.Provider%29)(String algorithm,String mechanismType,Provider provider) Returns a TransformService that supports the specified algorithm URI (ex: Transform.XPATH2) and mechanism type (ex: DOM) as supplied by the specified provider. |
static TransformService | [getInstance](../../../../javax/xml/crypto/dsig/TransformService.html#getInstance%28java.lang.String, java.lang.String, java.lang.String%29)(String algorithm,String mechanismType,String provider) Returns a TransformService 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 this TransformService. |
Provider | getProvider() Returns the provider of this TransformService. |
abstract void | init(TransformParameterSpec params) Initializes this TransformService with the specified parameters. |
abstract void | [init](../../../../javax/xml/crypto/dsig/TransformService.html#init%28javax.xml.crypto.XMLStructure, javax.xml.crypto.XMLCryptoContext%29)(XMLStructure parent,XMLCryptoContext context) Initializes this TransformService with the specified parameters and document context. |
abstract void | [marshalParams](../../../../javax/xml/crypto/dsig/TransformService.html#marshalParams%28javax.xml.crypto.XMLStructure, javax.xml.crypto.XMLCryptoContext%29)(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](../../../../java/lang/Object.html#wait%28long, int%29) |
Methods inherited from interface javax.xml.crypto.dsig.Transform |
---|
getParameterSpec, [transform](../../../../javax/xml/crypto/dsig/Transform.html#transform%28javax.xml.crypto.Data, javax.xml.crypto.XMLCryptoContext%29), [transform](../../../../javax/xml/crypto/dsig/Transform.html#transform%28javax.xml.crypto.Data, javax.xml.crypto.XMLCryptoContext, java.io.OutputStream%29) |
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 a TransformService
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 and MechanismType
service attribute. It traverses the list of registered security Provider
s, starting with the most preferred Provider
. A new TransformService
object from the first Provider
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 algorithm
mechanismType
- the type of the XML processing mechanism and representation
Returns:
a new TransformService
Throws:
[NullPointerException](../../../../java/lang/NullPointerException.html "class in java.lang")
- if algorithm
or mechanismType
is null
[NoSuchAlgorithmException](../../../../java/security/NoSuchAlgorithmException.html "class in java.security")
- if no Provider
supports aTransformService
implementation for the specified algorithm and mechanism type
See Also:
getInstance
public static TransformService getInstance(String algorithm, String mechanismType, Provider provider) throws NoSuchAlgorithmException
Returns a TransformService
that supports the specified algorithm URI (ex: Transform.XPATH2) and mechanism type (ex: DOM) as supplied by the specified provider. Note that the specified Provider
object does not have to be registered in the provider list.
Parameters:
algorithm
- the URI of the algorithm
mechanismType
- the type of the XML processing mechanism and representation
provider
- the Provider
object
Returns:
a new TransformService
Throws:
[NullPointerException](../../../../java/lang/NullPointerException.html "class in java.lang")
- if provider
, algorithm
, or mechanismType
is null
[NoSuchAlgorithmException](../../../../java/security/NoSuchAlgorithmException.html "class in java.security")
- if a TransformService
implementation for the specified algorithm and mechanism type is not available from the specified Provider
object
See Also:
getInstance
public static TransformService getInstance(String algorithm, String mechanismType, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
Returns a TransformService
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 algorithm
mechanismType
- the type of the XML processing mechanism and representation
provider
- the string name of the provider
Returns:
a new TransformService
Throws:
[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")
- if provider
, mechanismType
, or algorithm
is null
[NoSuchAlgorithmException](../../../../java/security/NoSuchAlgorithmException.html "class in java.security")
- if a TransformService
implementation for the specified algorithm and mechanism type is not available from the specified provider
See Also:
getMechanismType
public final String getMechanismType()
Returns the mechanism type supported by this TransformService
.
Returns:
the mechanism type
getAlgorithm
public final String getAlgorithm()
Returns the URI of the algorithm supported by thisTransformService
.
Specified by:
[getAlgorithm](../../../../javax/xml/crypto/AlgorithmMethod.html#getAlgorithm%28%29)
in interface [AlgorithmMethod](../../../../javax/xml/crypto/AlgorithmMethod.html "interface in javax.xml.crypto")
Returns:
the algorithm URI
getProvider
public final Provider getProvider()
Returns the provider of this TransformService
.
Returns:
the provider
init
public abstract void init(TransformParameterSpec params) throws InvalidAlgorithmParameterException
Initializes this TransformService
with the specified parameters.
If the parameters exist in XML form, the [init(XMLStructure, XMLCryptoContext)](../../../../javax/xml/crypto/dsig/TransformService.html#init%28javax.xml.crypto.XMLStructure, javax.xml.crypto.XMLCryptoContext%29) method should be used to initialize the TransformService
.
Parameters:
params
- the algorithm parameters (may be null
if not required or optional)
Throws:
[InvalidAlgorithmParameterException](../../../../java/security/InvalidAlgorithmParameterException.html "class in java.security")
- 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 to
context
- the XMLCryptoContext
containing additional context (may be null
if not applicable)
Throws:
[ClassCastException](../../../../java/lang/ClassCastException.html "class in java.lang")
- if the type of parent
orcontext
is not compatible with thisTransformService
[NullPointerException](../../../../java/lang/NullPointerException.html "class in java.lang")
- if parent
is null
[MarshalException](../../../../javax/xml/crypto/MarshalException.html "class in javax.xml.crypto")
- if the parameters cannot be marshalled
init
public abstract void init(XMLStructure parent, XMLCryptoContext context) throws InvalidAlgorithmParameterException
Initializes this TransformService
with the specified parameters and document context.
Parameters:
parent
- a mechanism-specific structure containing the parent structure
context
- the XMLCryptoContext
containing additional context (may be null
if not applicable)
Throws:
[ClassCastException](../../../../java/lang/ClassCastException.html "class in java.lang")
- if the type of parent
orcontext
is not compatible with thisTransformService
[NullPointerException](../../../../java/lang/NullPointerException.html "class in java.lang")
- if parent
is null
[InvalidAlgorithmParameterException](../../../../java/security/InvalidAlgorithmParameterException.html "class in java.security")
- if the specified parameters are invalid for this algorithm
Submit a bug or feature
For further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
Scripting on this page tracks web page traffic, but does not change the content in any way.