|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.xml.crypto.dsig.XMLSignatureFactory
A factory for creating 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 section of the API overview. See the Service Providers section of the API overview for a list of standard mechanism types.
Note that a caller must use the same XMLSignatureFactory
instance to create the XMLStructure
s of a particular
XMLSignature
that is to be generated. The behavior is
undefined if XMLStructure
s from different providers or
different mechanism types are used together.
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.
Constructor Summary | |
protected |
XMLSignatureFactory()
Default constructor, for invocation by subclasses. |
Method Summary | |
static XMLSignatureFactory |
getInstance()
Returns an XMLSignatureFactory that supports the
default XML processing mechanism and representation type ("DOM"). |
static XMLSignatureFactory |
getInstance(java.lang.String mechanismType)
Returns an XMLSignatureFactory that supports the
specified XML processing mechanism and representation type (ex: "DOM"). |
static XMLSignatureFactory |
getInstance(java.lang.String mechanismType,
java.security.Provider provider)
Returns an XMLSignatureFactory that supports the
requested XML processing mechanism and representation type (ex: "DOM"),
as supplied by the specified provider. |
static XMLSignatureFactory |
getInstance(java.lang.String mechanismType,
java.lang.String provider)
Returns an XMLSignatureFactory that supports the
requested XML processing mechanism and representation type (ex: "DOM"),
as supplied by the specified provider. |
KeyInfoFactory |
getKeyInfoFactory()
Returns a KeyInfoFactory that creates KeyInfo
objects. |
java.lang.String |
getMechanismType()
Returns the type of the XML processing mechanism and representation supported by this XMLSignatureFactory (ex: "DOM"). |
java.security.Provider |
getProvider()
Returns the provider of this XMLSignatureFactory . |
abstract URIDereferencer |
getURIDereferencer()
Returns a reference to the URIDereferencer that is used by
default to dereference URIs in Reference objects. |
abstract boolean |
isFeatureSupported(java.lang.String feature)
Indicates whether a specified feature is supported. |
abstract CanonicalizationMethod |
newCanonicalizationMethod(java.lang.String algorithm,
C14NMethodParameterSpec params)
Creates a CanonicalizationMethod for the specified
algorithm URI and parameters. |
abstract DigestMethod |
newDigestMethod(java.lang.String algorithm,
DigestMethodParameterSpec params)
Creates a DigestMethod for the specified algorithm URI
and parameters. |
abstract Manifest |
newManifest(java.util.List references)
Creates a Manifest containing the specified
list of Reference s. |
abstract Manifest |
newManifest(java.util.List references,
java.lang.String id)
Creates a Manifest containing the specified
list of Reference s and optional id. |
abstract Reference |
newReference(java.lang.String uri,
DigestMethod dm)
Creates a Reference with the specified URI and digest
method. |
abstract Reference |
newReference(java.lang.String uri,
DigestMethod dm,
java.util.List transforms,
java.lang.String type,
java.lang.String id)
Creates a Reference with the specified parameters. |
abstract SignatureMethod |
newSignatureMethod(java.lang.String algorithm,
SignatureMethodParameterSpec params)
Creates a SignatureMethod for the specified algorithm URI
and parameters. |
abstract SignatureProperties |
newSignatureProperties(java.util.List properties,
java.lang.String id)
Creates a SignatureProperties containing the specified
list of SignatureProperty s and optional id. |
abstract SignatureProperty |
newSignatureProperty(java.util.List content,
java.lang.String target,
java.lang.String id)
Creates a SignatureProperty containing the specified
list of XMLStructure s, target URI and optional id. |
abstract SignedInfo |
newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm,
java.util.List references)
Creates a SignedInfo with the specified canonicalization
and signature methods, and list of one or more references. |
abstract SignedInfo |
newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm,
java.util.List references,
java.lang.String id)
Creates a SignedInfo with the specified parameters. |
abstract Transform |
newTransform(java.lang.String algorithm,
TransformParameterSpec params)
Creates a Transform for the specified algorithm URI
and parameters. |
abstract XMLObject |
newXMLObject(java.util.List content,
java.lang.String id,
java.lang.String mimeType,
java.lang.String encoding)
Creates an XMLObject from the specified parameters. |
abstract XMLSignature |
newXMLSignature(SignedInfo si,
KeyInfo ki)
Creates an XMLSignature and initializes it with the contents
of the specified SignedInfo and KeyInfo
objects. |
abstract XMLSignature |
newXMLSignature(SignedInfo si,
KeyInfo ki,
java.util.List objects,
java.lang.String id,
java.lang.String signatureValueId)
Creates an XMLSignature and initializes it with the
specified parameters. |
abstract XMLSignature |
unmarshalXMLSignature(XMLValidateContext context)
Unmarshals a new XMLSignature instance from a
mechanism-specific XMLValidateContext instance. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected XMLSignatureFactory()
Method Detail |
public static XMLSignatureFactory getInstance(java.lang.String mechanismType)
XMLSignatureFactory
that supports the
specified XML processing mechanism and representation type (ex: "DOM").
This method uses the standard JCA provider lookup mechanism to
locate and instantiate an XMLSignatureFactory
implementation of the desired mechanism type.
mechanismType
- the type of the XML processing mechanism and
representation. See the Service
Providers section of the API overview for a list of standard
mechanism types.
XMLSignatureFactory
java.lang.NullPointerException
- if mechanismType
is
null
NoSuchMechanismException
- if an implementation of the requested
mechanismType
cannot be foundpublic static XMLSignatureFactory getInstance(java.lang.String mechanismType, java.security.Provider provider)
XMLSignatureFactory
that supports the
requested XML processing mechanism and representation type (ex: "DOM"),
as supplied by the specified provider.
mechanismType
- the type of the XML processing mechanism and
representation. See the Service
Providers section of the API overview for a list of standard
mechanism types.provider
- the provider
XMLSignatureFactory
java.lang.NullPointerException
- if provider
or
mechanismType
is null
NoSuchMechanismException
- if an implementation of the requested
mechanismType
is not available from the specified
providerpublic static XMLSignatureFactory getInstance(java.lang.String mechanismType, java.lang.String provider) throws java.security.NoSuchProviderException
XMLSignatureFactory
that supports the
requested XML processing mechanism and representation type (ex: "DOM"),
as supplied by the specified provider.
mechanismType
- the type of the XML processing mechanism and
representation. See the Service
Providers section of the API overview for a list of standard
mechanism types.provider
- the name of the provider
XMLSignatureFactory
java.security.NoSuchProviderException
- if provider
has not been
configured
java.lang.NullPointerException
- if provider
or
mechanismType
is null
NoSuchMechanismException
- if an implementation of the requested
mechanismType
is not available from the specified
providerpublic static XMLSignatureFactory getInstance()
XMLSignatureFactory
that supports the
default XML processing mechanism and representation type ("DOM").
This method uses the standard JCA provider lookup mechanism to
locate and instantiate an XMLSignatureFactory
implementation of the default mechanism type.
XMLSignatureFactory
NoSuchMechanismException
- if an implementation for the default
mechanism type cannot be foundpublic final java.lang.String getMechanismType()
XMLSignatureFactory
(ex: "DOM").
XMLSignatureFactory
public final java.security.Provider getProvider()
XMLSignatureFactory
.
XMLSignatureFactory
public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki)
XMLSignature
and initializes it with the contents
of the specified SignedInfo
and KeyInfo
objects.
si
- the signed infoki
- the key info (may be null
)
XMLSignature
java.lang.NullPointerException
- if si
is null
public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki, java.util.List objects, java.lang.String id, java.lang.String signatureValueId)
XMLSignature
and initializes it with the
specified parameters.
si
- the signed infoki
- the key info (may be null
)objects
- a list of XMLObject
s (may be empty or
null
)id
- the Id (may be null
)signatureValueId
- the SignatureValue Id (may be null
)
XMLSignature
java.lang.NullPointerException
- if si
is null
java.lang.ClassCastException
- if any of the objects
are not of
type XMLObject
public abstract Reference newReference(java.lang.String uri, DigestMethod dm)
Reference
with the specified URI and digest
method.
uri
- the reference URI (may be null
)dm
- the digest method
Reference
java.lang.IllegalArgumentException
- if uri
is not RFC 2396
compliant
java.lang.NullPointerException
- if dm
is null
public abstract Reference newReference(java.lang.String uri, DigestMethod dm, java.util.List transforms, java.lang.String type, java.lang.String id)
Reference
with the specified parameters.
uri
- the reference URI (may be null
)dm
- the digest methodtransforms
- a list of Transform
s. The list is defensively
copied to protect against subsequent modification. May be
null
or empty.type
- the reference type, as a URI (may be null
)id
- the reference ID (may be null
)
Reference
java.lang.ClassCastException
- if any of the transforms
are
not of type Transform
java.lang.IllegalArgumentException
- if uri
is not RFC 2396
compliant
java.lang.NullPointerException
- if dm
is null
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, java.util.List references)
SignedInfo
with the specified canonicalization
and signature methods, and list of one or more references.
cm
- the canonicalization methodsm
- the signature methodreferences
- a list of one or more Reference
s. The list is
defensively copied to protect against subsequent modification.
SignedInfo
java.lang.ClassCastException
- if any of the references are not of
type Reference
java.lang.IllegalArgumentException
- if references
is empty
java.lang.NullPointerException
- if any of the parameters
are null
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, java.util.List references, java.lang.String id)
SignedInfo
with the specified parameters.
cm
- the canonicalization methodsm
- the signature methodreferences
- a list of one or more Reference
s. The list is
defensively copied to protect against subsequent modification.id
- the id (may be null
)
SignedInfo
java.lang.ClassCastException
- if any of the references are not of
type Reference
java.lang.IllegalArgumentException
- if references
is empty
java.lang.NullPointerException
- if cm
, sm
, or
references
are null
public abstract XMLObject newXMLObject(java.util.List content, java.lang.String id, java.lang.String mimeType, java.lang.String encoding)
XMLObject
from the specified parameters.
content
- a list of XMLStructure
s. The list
is defensively copied to protect against subsequent modification.
May be null
or empty.id
- the Id (may be null
)mimeType
- the mime type (may be null
)encoding
- the encoding (may be null
)
XMLObject
java.lang.ClassCastException
- if content
contains any
entries that are not of type XMLStructure
public abstract Manifest newManifest(java.util.List references)
Manifest
containing the specified
list of Reference
s.
references
- a list of one or more Reference
s. The list
is defensively copied to protect against subsequent modification.
Manifest
java.lang.NullPointerException
- if references
is
null
java.lang.IllegalArgumentException
- if references
is empty
java.lang.ClassCastException
- if references
contains any
entries that are not of type Reference
public abstract Manifest newManifest(java.util.List references, java.lang.String id)
Manifest
containing the specified
list of Reference
s and optional id.
references
- a list of one or more Reference
s. The list
is defensively copied to protect against subsequent modification.id
- the id (may be null
)
Manifest
java.lang.NullPointerException
- if references
is
null
java.lang.IllegalArgumentException
- if references
is empty
java.lang.ClassCastException
- if references
contains any
entries that are not of type Reference
public abstract SignatureProperty newSignatureProperty(java.util.List content, java.lang.String target, java.lang.String id)
SignatureProperty
containing the specified
list of XMLStructure
s, target URI and optional id.
content
- a list of one or more XMLStructure
s. The list
is defensively copied to protect against subsequent modification.target
- the target URI of the Signature that this property applies
toid
- the id (may be null
)
SignatureProperty
java.lang.NullPointerException
- if content
or
target
is null
java.lang.IllegalArgumentException
- if content
is empty
java.lang.ClassCastException
- if content
contains any
entries that are not of type XMLStructure
public abstract SignatureProperties newSignatureProperties(java.util.List properties, java.lang.String id)
SignatureProperties
containing the specified
list of SignatureProperty
s and optional id.
properties
- a list of one or more SignatureProperty
s.
The list is defensively copied to protect against subsequent
modification.id
- the id (may be null
)
SignatureProperties
java.lang.NullPointerException
- if properties
is null
java.lang.IllegalArgumentException
- if properties
is empty
java.lang.ClassCastException
- if properties
contains any
entries that are not of type SignatureProperty
public abstract DigestMethod newDigestMethod(java.lang.String algorithm, DigestMethodParameterSpec params) throws java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterException
DigestMethod
for the specified algorithm URI
and parameters.
algorithm
- the URI identifying the digest algorithmparams
- algorithm-specific digest parameters (may be
null
)
DigestMethod
java.security.InvalidAlgorithmParameterException
- if the specified parameters
are inappropriate for the requested algorithm
java.security.NoSuchAlgorithmException
- if an implementation of the
specified algorithm cannot be found
java.lang.NullPointerException
- if algorithm
is
null
public abstract SignatureMethod newSignatureMethod(java.lang.String algorithm, SignatureMethodParameterSpec params) throws java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterException
SignatureMethod
for the specified algorithm URI
and parameters.
algorithm
- the URI identifying the signature algorithmparams
- algorithm-specific signature parameters (may be
null
)
SignatureMethod
java.security.InvalidAlgorithmParameterException
- if the specified parameters
are inappropriate for the requested algorithm
java.security.NoSuchAlgorithmException
- if an implementation of the
specified algorithm cannot be found
java.lang.NullPointerException
- if algorithm
is
null
public abstract Transform newTransform(java.lang.String algorithm, TransformParameterSpec params) throws java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterException
Transform
for the specified algorithm URI
and parameters.
algorithm
- the URI identifying the transform algorithmparams
- algorithm-specific transform parameters (may be
null
)
Transform
java.security.InvalidAlgorithmParameterException
- if the specified parameters
are inappropriate for the requested algorithm
java.security.NoSuchAlgorithmException
- if an implementation of the
specified algorithm cannot be found
java.lang.NullPointerException
- if algorithm
is
null
public abstract CanonicalizationMethod newCanonicalizationMethod(java.lang.String algorithm, C14NMethodParameterSpec params) throws java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterException
CanonicalizationMethod
for the specified
algorithm URI and parameters.
algorithm
- the URI identifying the canonicalization algorithmparams
- algorithm-specific canonicalization parameters (may be
null
)
CanonicalizationMethod
java.security.InvalidAlgorithmParameterException
- if the specified parameters
are inappropriate for the requested algorithm
java.security.NoSuchAlgorithmException
- if an implementation of the
specified algorithm cannot be found
java.lang.NullPointerException
- if algorithm
is
null
public final KeyInfoFactory getKeyInfoFactory()
KeyInfoFactory
that creates KeyInfo
objects. The returned KeyInfoFactory
has the same
mechanism type and provider as this XMLSignatureFactory
.
KeyInfoFactory
NoSuchMechanismException
- if a KeyFactory
implementation with the same mechanism type and provider
is not availablepublic abstract XMLSignature unmarshalXMLSignature(XMLValidateContext context) throws MarshalException
XMLSignature
instance from a
mechanism-specific XMLValidateContext
instance.
context
- a mechanism-specific context from which to unmarshal the
signature from
XMLSignature
java.lang.NullPointerException
- if input
is null
java.lang.ClassCastException
- if the type of context
is
inappropriate for this factory
MarshalException
- if an unrecoverable exception occurs
during unmarshallingpublic abstract boolean isFeatureSupported(java.lang.String feature)
feature
- the feature name (as an absolute URI)
true
if the specified feature is supported,
false
otherwise
java.lang.NullPointerException
- if feature
is null
public abstract URIDereferencer getURIDereferencer()
URIDereferencer
that is used by
default to dereference URIs in Reference
objects.
URIDereferencer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |