- All Implemented Interfaces:
- AlgorithmMethod,- Transform,- XMLStructure
public abstract class TransformService extends Object implements Transform
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 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. See the TransformService section in the 
 Java Security Standard Algorithm Names Specification for a list of
 standard algorithm URIs and 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)
 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 method is called to marshal the
 parameters to XML and provide the transform with document context. Finally,
 the transform 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 different
 TransformService instance need not synchronize.
- Since:
- 1.6
- 
Field Summary
- 
Constructor SummaryConstructors Modifier Constructor Description protectedTransformService()Default constructor, for invocation by subclasses.
- 
Method SummaryModifier and Type Method Description StringgetAlgorithm()Returns the URI of the algorithm supported by thisTransformService.static TransformServicegetInstance(String algorithm, String mechanismType)Returns aTransformServicethat supports the specified algorithm URI (ex:Transform.XPATH2) and mechanism type (ex: DOM).static TransformServicegetInstance(String algorithm, String mechanismType, String provider)Returns aTransformServicethat supports the specified algorithm URI (ex:Transform.XPATH2) and mechanism type (ex: DOM) as supplied by the specified provider.static TransformServicegetInstance(String algorithm, String mechanismType, Provider provider)Returns aTransformServicethat supports the specified algorithm URI (ex:Transform.XPATH2) and mechanism type (ex: DOM) as supplied by the specified provider.StringgetMechanismType()Returns the mechanism type supported by thisTransformService.ProvidergetProvider()Returns the provider of thisTransformService.abstract voidinit(TransformParameterSpec params)Initializes thisTransformServicewith the specified parameters.abstract voidinit(XMLStructure parent, XMLCryptoContext context)Initializes thisTransformServicewith the specified parameters and document context.abstract voidmarshalParams(XMLStructure parent, XMLCryptoContext context)Marshals the algorithm-specific parameters.Methods declared in class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods declared in interface javax.xml.crypto.dsig.TransformgetParameterSpec, transform, transform
- 
Constructor Details- 
TransformServiceprotected TransformService()Default constructor, for invocation by subclasses.
 
- 
- 
Method Details- 
getInstancepublic static TransformService getInstance(String algorithm, String mechanismType) throws NoSuchAlgorithmExceptionReturns aTransformServicethat 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 TransformServiceimplementation of the desired algorithm andMechanismTypeservice attribute. It traverses the list of registered securityProviders, starting with the most preferredProvider. A newTransformServiceobject from the firstProviderthat supports the specified algorithm and mechanism type 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 the
 jdk.security.provider.preferredSecurityproperty 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 URI of the algorithm. See the- TransformServicesection in the Java Security Standard Algorithm Names Specification for a list of standard transform algorithms.
- mechanismType- the type of the XML processing mechanism and representation. See the- TransformServicesection in the Java Security Standard Algorithm Names Specification for a list of standard mechanism types.
- Returns:
- a new TransformService
- Throws:
- NullPointerException- if- algorithmor- mechanismTypeis- null
- NoSuchAlgorithmException- if no- Providersupports a- TransformServiceimplementation for the specified algorithm and mechanism type
- See Also:
- Provider
 
- 
getInstancepublic static TransformService getInstance(String algorithm, String mechanismType, Provider provider) throws NoSuchAlgorithmExceptionReturns aTransformServicethat supports the specified algorithm URI (ex:Transform.XPATH2) and mechanism type (ex: DOM) as supplied by the specified provider. Note that the specifiedProviderobject does not have to be registered in the provider list.- Parameters:
- algorithm- the URI of the algorithm. See the- TransformServicesection in the Java Security Standard Algorithm Names Specification for a list of standard transform algorithms.
- mechanismType- the type of the XML processing mechanism and representation. See the- TransformServicesection in the Java Security Standard Algorithm Names Specification for a list of standard mechanism types.
- provider- the- Providerobject
- Returns:
- a new TransformService
- Throws:
- NullPointerException- if- provider,- algorithm, or- mechanismTypeis- null
- NoSuchAlgorithmException- if a- TransformServiceimplementation for the specified algorithm and mechanism type is not available from the specified- Providerobject
- See Also:
- Provider
 
- 
getInstancepublic static TransformService getInstance(String algorithm, String mechanismType, String provider) throws NoSuchAlgorithmException, NoSuchProviderExceptionReturns aTransformServicethat 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. See the- TransformServicesection in the Java Security Standard Algorithm Names Specification for a list of standard transform algorithms.
- mechanismType- the type of the XML processing mechanism and representation. See the- TransformServicesection in the Java Security Standard Algorithm Names Specification for a list of standard mechanism types.
- provider- the string name of the provider
- Returns:
- a new TransformService
- Throws:
- NoSuchProviderException- if the specified provider is not registered in the security provider list
- NullPointerException- if- provider,- mechanismType, or- algorithmis- null
- NoSuchAlgorithmException- if a- TransformServiceimplementation for the specified algorithm and mechanism type is not available from the specified provider
- See Also:
- Provider
 
- 
getMechanismTypeReturns the mechanism type supported by thisTransformService.- Returns:
- the mechanism type
 
- 
getAlgorithmReturns the URI of the algorithm supported by thisTransformService.- Specified by:
- getAlgorithmin interface- AlgorithmMethod
- Returns:
- the algorithm URI
 
- 
getProviderReturns the provider of thisTransformService.- Returns:
- the provider
 
- 
initInitializes thisTransformServicewith 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 be- nullif not required or optional)
- Throws:
- InvalidAlgorithmParameterException- if the specified parameters are invalid for this algorithm
 
- 
marshalParamspublic abstract void marshalParams(XMLStructure parent, XMLCryptoContext context) throws MarshalExceptionMarshals 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- XMLCryptoContextcontaining additional context (may be- nullif not applicable)
- Throws:
- ClassCastException- if the type of- parentor- contextis not compatible with this- TransformService
- NullPointerException- if- parentis- null
- MarshalException- if the parameters cannot be marshalled
 
- 
initpublic abstract void init(XMLStructure parent, XMLCryptoContext context) throws InvalidAlgorithmParameterExceptionInitializes thisTransformServicewith the specified parameters and document context.- Parameters:
- parent- a mechanism-specific structure containing the parent structure
- context- the- XMLCryptoContextcontaining additional context (may be- nullif not applicable)
- Throws:
- ClassCastException- if the type of- parentor- contextis not compatible with this- TransformService
- NullPointerException- if- parentis- null
- InvalidAlgorithmParameterException- if the specified parameters are invalid for this algorithm
 
 
-