XMLSignature objects from scratch or
for unmarshalling an XMLSignature object from a corresponding
XML representation.
Each instance of XMLSignatureFactory supports a specific
XML mechanism type. To create an XMLSignatureFactory, call one
of the static getInstance methods, passing in the XML
mechanism type desired, for example:
XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
The objects that this factory produces will be based
on DOM and abide by the DOM interoperability requirements as defined in the
DOM Mechanism Requirements.
See the XMLSignatureFactory section in the
Java Security Standard Algorithm Names Specification for a list of
standard mechanism types.
XMLSignatureFactory implementations are registered and loaded
using the java. mechanism.
For example, a service provider that supports the
DOM mechanism would be specified in the Provider subclass as:
put("XMLSignatureFactory.DOM", "org.example.DOMXMLSignatureFactory");
An implementation MUST minimally support the default mechanism type: DOM.
Note that a caller must use the same XMLSignatureFactory
instance to create the XMLStructures of a particular
XMLSignature that is to be generated. The behavior is
undefined if XMLStructures from different providers or
different mechanism types are used together.
Also, the XMLStructures that are created by this factory
may contain state specific to the XMLSignature and are not
intended to be reusable.
Once the XMLSignatureFactory has been created, objects
can be instantiated by calling the appropriate method. For example, a
Reference instance may be created by invoking one of the
newReference methods.
Alternatively, an XMLSignature may be created from an
existing XML representation by invoking the unmarshalXMLSignature method and passing it a mechanism-specific
XMLValidateContext instance containing the XML content:
DOMValidateContext context = new DOMValidateContext(key, signatureElement); XMLSignature signature = factory.unmarshalXMLSignature(context);Each
XMLSignatureFactory must support the required
XMLValidateContext types for that factory type, but may support
others. A DOM XMLSignatureFactory must support DOMValidateContext objects.
XMLSignature created by the factory can also be
marshalled to an XML representation and signed, by invoking the
sign method of the
XMLSignature object and passing it a mechanism-specific
XMLSignContext object containing the signing key and
marshalling parameters (see DOMSignContext).
For example:
DOMSignContext context = new DOMSignContext(privateKey, document); signature.sign(context);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 XMLSignatureFactory instance
concurrently should synchronize amongst themselves and provide the
necessary locking. Multiple threads each manipulating a different
XMLSignatureFactory instance need not synchronize.
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static XMLSignatureFactory | Returns: a newXMLSignatureFactorythe type of the XML processing mechanism and
representation. See the mechanismType)XMLSignatureFactory section in the
Java Security Standard Algorithm Names Specification for a list of
standard mechanism types.Returns an |
| public static XMLSignatureFactory | Returns: a newXMLSignatureFactorythe type of the XML processing mechanism and
representation. See the mechanismType, Provider XMLSignatureFactory section in the
Java Security Standard Algorithm Names Specification for a list of
standard mechanism types.the provider)Provider objectReturns an |
| public static XMLSignatureFactory | Returns: a newXMLSignatureFactorythe type of the XML processing mechanism and
representation. See the mechanismType, String XMLSignatureFactory section in the
Java Security Standard Algorithm Names Specification for a list of
standard mechanism types.the string name of the provider provider)Returns an |
| public static XMLSignatureFactory | Returns: a newXMLSignatureFactoryReturns an |
| public final KeyInfoFactory | |
| public final String | Returns: the XML processing mechanism type supported by thisXMLSignatureFactoryReturns the type of the XML processing mechanism and representation
supported by this |
| public final Provider | Returns: the provider of thisXMLSignatureFactoryReturns the provider of this |
| public abstract URIDereferencer | Returns: a reference to the defaultURIDereferencer (never
null)Returns a reference to the |
| public abstract boolean | Returns: true if the specified feature is supported,
false otherwisethe feature name (as an absolute URI) feature)Indicates whether a specified feature is supported. |
| public abstract CanonicalizationMethod | Returns: theCanonicalizationMethodthe URI identifying the canonicalization algorithm algorithm, C14NMethodParameterSpec algorithm-specific canonicalization parameters (may be
params)null)Creates a |
| public abstract CanonicalizationMethod | Returns: theCanonicalizationMethodthe URI identifying the canonicalization algorithm algorithm, XMLStructure a mechanism-specific XML structure from which to
unmarshal the parameters from (may be params)null if
not required or optional)Creates a |
| public abstract DigestMethod | Returns: theDigestMethodthe URI identifying the digest algorithm algorithm, DigestMethodParameterSpec algorithm-specific digest parameters (may be
params)null)Creates a |
| public abstract Manifest | Returns: aManifesta list of one or more references)References. The list
is defensively copied to protect against subsequent modification.Creates a |
| public abstract Manifest | Returns: aManifesta list of one or more references, String References. The list
is defensively copied to protect against subsequent modification.the id (may be id)null)Creates a |
| public abstract Reference | Returns: aReferencethe reference URI (may be uri, DigestMethod null)the digest method dm)Creates a |
| public abstract Reference | Returns: aReferencethe reference URI (may be uri, DigestMethod null)the digest method dm, List<? extends Transform> a list of transforms, String Transforms. The list is defensively
copied to protect against subsequent modification. May be
null or empty.the reference type, as a URI (may be type, String null)the reference ID (may be id)null)Creates a |
| public abstract Reference | Returns: aReferencethe reference URI (may be uri, DigestMethod null)the digest method dm, List<? extends Transform> a list of transforms, String Transforms. The list is defensively
copied to protect against subsequent modification. May be
null or empty.the reference type, as a URI (may be type, String null)the reference ID (may be id, byte[] null)the digest value. The array is cloned to protect
against subsequent modification. digestValue)Creates a |
| public abstract Reference | Returns: aReferencethe reference URI (may be uri, DigestMethod null)the digest method dm, List<? extends Transform> a list of appliedTransforms, Data Transforms that have
already been applied. The list is defensively
copied to protect against subsequent modification. The list must
contain at least one entry.the result of processing the sequence of
result, List<? extends Transform> appliedTransformsa list of transforms, String Transforms that are to be applied
when generating the signature. The list is defensively copied to
protect against subsequent modification. May be null
or empty.the reference type, as a URI (may be type, String null)the reference ID (may be id)null)Creates a |
| public abstract SignatureMethod | Returns: theSignatureMethodthe URI identifying the signature algorithm algorithm, SignatureMethodParameterSpec algorithm-specific signature parameters (may be
params)null)Creates a |
| public abstract SignatureProperties | Returns: aSignaturePropertiesa list of one or more properties, String SignaturePropertys.
The list is defensively copied to protect against subsequent
modification.the id (may be id)null)Creates a |
| public abstract SignatureProperty | Returns: aSignaturePropertya list of one or more content, String XMLStructures. The list
is defensively copied to protect against subsequent modification.the target URI of the Signature that this property applies
to target, String the id (may be id)null)Creates a |
| public abstract SignedInfo | Returns: aSignedInfothe canonicalization method cm, SignatureMethod the signature method sm, List<? extends Reference> a list of one or more references)References. The list is
defensively copied to protect against subsequent modification.Creates a |
| public abstract SignedInfo | Returns: aSignedInfothe canonicalization method cm, SignatureMethod the signature method sm, List<? extends Reference> a list of one or more references, String References. The list is
defensively copied to protect against subsequent modification.the id (may be id)null)Creates a |
| public abstract Transform | Returns: theTransformthe URI identifying the transform algorithm algorithm, TransformParameterSpec algorithm-specific transform parameters (may be
params)null)Creates a |
| public abstract Transform | Returns: theTransformthe URI identifying the transform algorithm algorithm, XMLStructure a mechanism-specific XML structure from which to
unmarshal the parameters from (may be params)null if
not required or optional)Creates a |
| public abstract XMLObject | Returns: anXMLObjecta list of content, String XMLStructures. The list
is defensively copied to protect against subsequent modification.
May be null or empty.the Id (may be id, String null)the mime type (may be mimeType, String null)the encoding (may be encoding)null)Creates an |
| public abstract XMLSignature | Returns: anXMLSignaturethe signed info si, KeyInfo the key info (may be ki)null)Creates an |
| public abstract XMLSignature | Returns: anXMLSignaturethe signed info si, KeyInfo the key info (may be ki, List<? extends XMLObject> null)a list of objects, String XMLObjects (may be empty or
null)the Id (may be id, String null)the SignatureValue Id (may be signatureValueId)null)Creates an |
| public abstract XMLSignature | Returns: theXMLSignaturea mechanism-specific context from which to unmarshal the
signature from context)Unmarshals a new |
| public abstract XMLSignature | Returns: theXMLSignaturea mechanism-specific XML structure from which to
unmarshal the signature from xmlStructure)Unmarshals a new |
| mechanismType | back to summary |
|---|---|
| private String mechanismType | |
| provider | back to summary |
|---|---|
| private Provider provider | |
| XMLSignatureFactory | back to summary |
|---|---|
| protected XMLSignatureFactory() Default constructor, for invocation by subclasses. | |
| getInstance | back to summary |
|---|---|
| public static XMLSignatureFactory getInstance(String mechanismType) Returns an This method uses the standard JCA provider lookup mechanism to
locate and instantiate an Note that the list of registered providers may be retrieved via
the Implementation Note The JDK Reference Implementation additionally uses the
| |
| getInstance | back to summary |
|---|---|
| public static XMLSignatureFactory getInstance(String mechanismType, Provider provider) Returns an
| |
| getInstance | back to summary |
|---|---|
| public static XMLSignatureFactory getInstance(String mechanismType, String provider) throws NoSuchProviderException Returns an Note that the list of registered providers may be retrieved via
the
| |
| getInstance | back to summary |
|---|---|
| public static XMLSignatureFactory getInstance() Returns an This method uses the standard JCA provider lookup mechanism to
locate and instantiate an Note that the list of registered providers may be retrieved via
the
| |
| getKeyInfoFactory | back to summary |
|---|---|
| public final KeyInfoFactory getKeyInfoFactory() Returns a
| |
| getMechanismType | back to summary |
|---|---|
| public final String getMechanismType() Returns the type of the XML processing mechanism and representation
supported by this
| |
| getProvider | back to summary |
|---|---|
| public final Provider getProvider() Returns the provider of this
| |
| getURIDereferencer | back to summary |
|---|---|
| public abstract URIDereferencer getURIDereferencer() Returns a reference to the
| |
| isFeatureSupported | back to summary |
|---|---|
| public abstract boolean isFeatureSupported(String feature) Indicates whether a specified feature is supported.
| |
| newCanonicalizationMethod | back to summary |
|---|---|
| public abstract CanonicalizationMethod newCanonicalizationMethod(String algorithm, C14NMethodParameterSpec params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException Creates a
| |
| newCanonicalizationMethod | back to summary |
|---|---|
| public abstract CanonicalizationMethod newCanonicalizationMethod(String algorithm, XMLStructure params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException Creates a
| |
| newDigestMethod | back to summary |
|---|---|
| public abstract DigestMethod newDigestMethod(String algorithm, DigestMethodParameterSpec params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException Creates a
| |
| newManifest | back to summary |
|---|---|
| public abstract Manifest newManifest(List<? extends Reference> references) Creates a
| |
| newManifest | back to summary |
|---|---|
| public abstract Manifest newManifest(List<? extends Reference> references, String id) Creates a
| |
| newReference | back to summary |
|---|---|
| public abstract Reference newReference(String uri, DigestMethod dm) Creates a
| |
| newReference | back to summary |
|---|---|
| public abstract Reference newReference(String uri, DigestMethod dm, List<? extends Transform> transforms, String type, String id) Creates a
| |
| newReference | back to summary |
|---|---|
| public abstract Reference newReference(String uri, DigestMethod dm, List<? extends Transform> transforms, String type, String id, byte[] digestValue) Creates a This method is useful when the digest value of a
| |
| newReference | back to summary |
|---|---|
| public abstract Reference newReference(String uri, DigestMethod dm, List<? extends Transform> appliedTransforms, Data result, List<? extends Transform> transforms, String type, String id) Creates a This method is useful when a list of transforms have already been
applied to the When an
| |
| newSignatureMethod | back to summary |
|---|---|
| public abstract SignatureMethod newSignatureMethod(String algorithm, SignatureMethodParameterSpec params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException Creates a
| |
| newSignatureProperties | back to summary |
|---|---|
| public abstract SignatureProperties newSignatureProperties(List<? extends SignatureProperty> properties, String id) Creates a
| |
| newSignatureProperty | back to summary |
|---|---|
| public abstract SignatureProperty newSignatureProperty(List<? extends XMLStructure> content, String target, String id) Creates a
| |
| newSignedInfo | back to summary |
|---|---|
| public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, List<? extends Reference> references) Creates a
| |
| newSignedInfo | back to summary |
|---|---|
| public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, List<? extends Reference> references, String id) Creates a
| |
| newTransform | back to summary |
|---|---|
| public abstract Transform newTransform(String algorithm, TransformParameterSpec params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException Creates a
| |
| newTransform | back to summary |
|---|---|
| public abstract Transform newTransform(String algorithm, XMLStructure params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException Creates a
| |
| newXMLObject | back to summary |
|---|---|
| public abstract XMLObject newXMLObject(List<? extends XMLStructure> content, String id, String mimeType, String encoding) Creates an
| |
| newXMLSignature | back to summary |
|---|---|
| public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki) Creates an
| |
| newXMLSignature | back to summary |
|---|---|
| public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki, List<? extends XMLObject> objects, String id, String signatureValueId) Creates an
| |
| unmarshalXMLSignature | back to summary |
|---|---|
| public abstract XMLSignature unmarshalXMLSignature(XMLValidateContext context) throws MarshalException Unmarshals a new
| |
| unmarshalXMLSignature | back to summary |
|---|---|
| public abstract XMLSignature unmarshalXMLSignature(XMLStructure xmlStructure) throws MarshalException Unmarshals a new
| |