|
XML Digital Signature and Encryption, 1.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.xml.crypto.enc.XMLEncryptionFactory
public abstract class XMLEncryptionFactory
A factory for creating EncryptedType
objects (such as EncryptedData
,
EncryptedKey
) from scratch or
for unmarshalling an EncryptedType
object from a corresponding
XML representation.
Each instance of XMLEncryptionFactory
supports a specific
XML mechanism type. To create an XMLEncryptionFactory
, call one
of the static getInstance
methods, passing in the XML
mechanism type desired, for example:
XMLEncryptionFactory factory = XMLEncryptionFactory.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.
Note that a caller must use the same XMLEncryptionFactory
instance to create the XMLStructure
s of a particular
EncryptedType
that is to be generated. The behavior is
undefined if XMLStructure
s from different providers or
different mechanism types are used together.
Once the XMLEncryptionFactory
has been created, objects
can be instantiated by calling the appropriate method.
Alternatively, an EncryptedData
may be created from an
existing XML representation by invoking the unmarshalEncryptedType
method and passing it a mechanism-specific
XMLDecryptContext
instance containing the XML content:
DOMDecryptContext context = new DOMDecryptContext(key, encElement); EncryptedData data = (EncryptedData) factory.unmarshalEncryptedType(context);Each
XMLEncryptionFactory
must support the required
XMLDecryptContext
types for that factory type, but may support
others. A DOM XMLEncryptionFactory
must support DOMDecryptContext
objects.
EncryptedData
created by the factory can also be
marshalled back to an XML representation, by invoking the
encrypt
method of the
EncryptedData
object and passing it a mechanism-specific
XMLEncryptContext
object
that will hold the marshalled representation; for example:
DOMEncryptContext context = new DOMEncryptContext(key, document); data.encrypt(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 XMLEncryptionFactory
instance
concurrently should synchronize amongst themselves and provide the
necessary locking. Multiple threads each manipulating a different
XMLEncryptionFactory
instance need not synchronize.
Constructor Summary | |
---|---|
protected |
XMLEncryptionFactory()
Default constructor, for invocation by subclasses. |
Method Summary | |
---|---|
static XMLEncryptionFactory |
getInstance()
Returns an XMLEncryptionFactory that supports the
default XML processing mechanism and representation type ("DOM"). |
static XMLEncryptionFactory |
getInstance(java.lang.String mechanismType)
Returns an XMLEncryptionFactory that supports the
specified XML processing mechanism and representation type (ex: "DOM"). |
static XMLEncryptionFactory |
getInstance(java.lang.String mechanismType,
java.security.Provider provider)
Returns an XMLEncryptionFactory that supports the
requested XML processing mechanism and representation type (ex: "DOM"),
as supplied by the specified provider. |
static XMLEncryptionFactory |
getInstance(java.lang.String mechanismType,
java.lang.String provider)
Returns an XMLEncryptionFactory that supports the
requested XML processing mechanism and representation type (ex: "DOM"),
as supplied by the specified provider. |
java.lang.String |
getMechanismType()
Returns the type of the XML processing mechanism and representation supported by this XMLEncryptionFactory (ex: "DOM"). |
java.security.Provider |
getProvider()
Returns the provider of this XMLEncryptionFactory . |
abstract boolean |
isFeatureSupported(java.lang.String feature)
Indicates whether a specified feature is supported. |
abstract AgreementMethod |
newAgreementMethod(java.lang.String algorithm,
byte[] kaNonce,
KeyInfo originatorKeyInfo,
KeyInfo recipientKeyInfo,
AgreementMethodParameterSpec params)
Creates an AgreementMethod . |
abstract CanonicalizationMethod |
newCanonicalizationMethod(java.lang.String algorithm,
C14NMethodParameterSpec params)
Creates a CanonicalizationMethod for the specified
algorithm URI and parameters. |
abstract CipherReference |
newCipherReference(java.lang.String uri,
java.util.List transforms)
Creates a CipherReference from the specified parameters. |
abstract DataReference |
newDataReference(java.lang.String uri,
java.util.List content)
Creates a DataReference from the specified URI. |
abstract DHKeyValue |
newDHKeyValue(java.security.PublicKey key)
Creates a DHKeyValue from the specified key |
abstract EncryptedData |
newEncryptedData(ToBeEncrypted toBeEncrypted,
EncryptionMethod encMethod,
KeyInfo keyInfo,
EncryptionProperties properties,
java.lang.String id)
Creates an EncryptedData which contains a CipherValue . |
abstract EncryptedData |
newEncryptedData(ToBeEncrypted toBeEncrypted,
EncryptionMethod encMethod,
KeyInfo keyInfo,
EncryptionProperties properties,
java.lang.String id,
CipherReference cipherRef)
Creates an EncryptedData which contains a CiphereReference . |
abstract EncryptedKey |
newEncryptedKey(ToBeEncryptedKey key,
EncryptionMethod encMethod,
KeyInfo keyInfo,
EncryptionProperties properties,
java.util.List references,
java.lang.String id,
java.lang.String carriedKeyName,
java.lang.String recipient)
Creates an EncryptedKey which contains a CipherValue . |
abstract EncryptedKey |
newEncryptedKey(ToBeEncryptedKey key,
EncryptionMethod encMethod,
KeyInfo keyInfo,
EncryptionProperties properties,
java.util.List references,
java.lang.String id,
java.lang.String carriedKeyName,
java.lang.String recipient,
CipherReference cipherRef)
Creates an EncryptedKey . |
abstract EncryptionMethod |
newEncryptionMethod(java.lang.String algorithm,
java.lang.Integer keySize,
EncryptionMethodParameterSpec params)
Creates a EncryptionMethod for the specified algorithm URI,
key size, and parameters. |
abstract EncryptionProperties |
newEncryptionProperties(java.util.List properties,
java.lang.String id)
Creates a EncryptionProperties containing the specified
list of EncryptionProperty s and optional id. |
abstract EncryptionProperty |
newEncryptionProperty(java.util.List content,
java.lang.String target,
java.lang.String id,
java.util.Map attributes)
Creates an EncryptionProperty containing the specified
list of XMLStructure s, target URI and optional id. |
abstract KeyReference |
newKeyReference(java.lang.String uri,
java.util.List content)
Creates a KeyReference from the specified URI. |
abstract KeyInfo |
newOriginatorKeyInfo(java.util.List content,
java.lang.String id)
Creates an originator KeyInfo containing the specified list of key information. |
abstract KeyInfo |
newRecipientKeyInfo(java.util.List content,
java.lang.String id)
Creates a recipient KeyInfo containing the specified list of key information. |
abstract EncryptedType |
unmarshalEncryptedType(XMLDecryptContext context)
Unmarshals a new EncryptedType instance from a
mechanism-specific XMLDecryptContext instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected XMLEncryptionFactory()
Method Detail |
---|
public static XMLEncryptionFactory getInstance(java.lang.String mechanismType) throws NoSuchMechanismException
XMLEncryptionFactory
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 XMLEncryptionFactory
implementation of the desired mechanism type.
mechanismType
- the type of the XML processing mechanism and
representation
XMLEncryptionFactory
java.lang.NullPointerException
- if mechanismType
is
null
NoSuchMechanismException
- if an implementation of the requested
mechanismType
cannot be foundpublic static XMLEncryptionFactory getInstance(java.lang.String mechanismType, java.security.Provider provider) throws NoSuchMechanismException
XMLEncryptionFactory
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
XMLEncryptionFactory
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 XMLEncryptionFactory getInstance(java.lang.String mechanismType, java.lang.String provider) throws java.security.NoSuchProviderException, NoSuchMechanismException
XMLEncryptionFactory
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
XMLEncryptionFactory
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 XMLEncryptionFactory getInstance() throws NoSuchMechanismException
XMLEncryptionFactory
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 XMLEncryptionFactory
implementation of the default mechanism type.
XMLEncryptionFactory
NoSuchMechanismException
- if an implementation for the default
mechanism type cannot be foundpublic final java.lang.String getMechanismType()
XMLEncryptionFactory
(ex: "DOM").
XMLEncryptionFactory
public final java.security.Provider getProvider()
XMLEncryptionFactory
.
XMLEncryptionFactory
public abstract EncryptedData newEncryptedData(ToBeEncrypted toBeEncrypted, EncryptionMethod encMethod, KeyInfo keyInfo, EncryptionProperties properties, java.lang.String id)
EncryptedData
which contains a CipherValue
.
toBeEncrypted
- the data to be encrypted in this EncryptedDataencMethod
- the encryption method (may be null
)keyInfo
- the key info (may be null
)properties
- the encryption properties (may be null
)id
- the ID (may be null
)
EncryptedData
java.lang.IllegalArgumentException
- if ToBeEncryptedKey is passed in as toBeEncrypted
java.lang.NullPointerException
- if toBeEncrypted
is null.public abstract EncryptedData newEncryptedData(ToBeEncrypted toBeEncrypted, EncryptionMethod encMethod, KeyInfo keyInfo, EncryptionProperties properties, java.lang.String id, CipherReference cipherRef)
EncryptedData
which contains a CiphereReference
.
toBeEncrypted
- the data to be encrypted in this EncryptedDataencMethod
- the encryption method (may be null
)keyInfo
- the key info (may be null
)properties
- the encryption properties (may be null
)id
- the ID (may be null
)cipherRef
- the CiphereReference this EncryptedData will contain
EncryptedData
java.lang.IllegalArgumentException
- if ToBeEncryptedKey is passed in as toBeEncrypted
java.lang.NullPointerException
- if toBeEncrypted
or cipherRef
is nullpublic abstract DataReference newDataReference(java.lang.String uri, java.util.List content)
DataReference
from the specified URI.
uri
- the uri that refers to an EncryptedData
elementcontent
- a list of XMLStructure
s (may be null or empty). The
list is defensively copied to protect against subsequent modification.
DataReference
java.lang.IllegalArgumentException
- if uri
is not
RFC2396 compliant
java.lang.ClassCastException
- if content
contains any
entries that are not of type XMLStructure
java.lang.NullPointerException
- if uri
is null
public abstract KeyReference newKeyReference(java.lang.String uri, java.util.List content)
KeyReference
from the specified URI.
uri
- the uri that refers to an EncryptedKey
elementcontent
- a list of XMLStructure
s (may be null or empty). The
list is defensively copied to protect against subsequent modification.
KeyReference
java.lang.IllegalArgumentException
- if uri
is not
RFC2396 compliant
java.lang.ClassCastException
- if content
contains any
entries that are not of type XMLStructure
java.lang.NullPointerException
- if uri
is null
public abstract EncryptionProperty newEncryptionProperty(java.util.List content, java.lang.String target, java.lang.String id, java.util.Map attributes)
EncryptionProperty
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 EncryptedType
that
this property applies to (may be null
)id
- the id (may be null
)attributes
- a map of attributes from the XML namespace (may
be empty or null
). The map is defensively copied to
protect against subsequent modification.
EncryptionProperty
java.lang.NullPointerException
- if content
is null
java.lang.IllegalArgumentException
- if content
is empty or
one or more of the attributes
are not from the XML
namespace
java.lang.ClassCastException
- if content
contains any
entries that are not of type XMLStructure
public abstract EncryptionProperties newEncryptionProperties(java.util.List properties, java.lang.String id)
EncryptionProperties
containing the specified
list of EncryptionProperty
s and optional id.
properties
- a list of one or more EncryptionProperty
s.
The list is defensively copied to protect against subsequent
modification.id
- the id (may be null
)
EncryptionProperties
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 EncryptionProperty
public abstract EncryptionMethod newEncryptionMethod(java.lang.String algorithm, java.lang.Integer keySize, EncryptionMethodParameterSpec params) throws java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterException
EncryptionMethod
for the specified algorithm URI,
key size, and parameters.
algorithm
- the URI identifying the encryption algorithm. Supported
algorithms are defined in EncryptionMethod interface.keySize
- the size of the key to be used (or null
if
not applicable)params
- algorithm-specific encryption parameters (may be
null
)
EncryptionMethod
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 CipherReference newCipherReference(java.lang.String uri, java.util.List transforms)
CipherReference
from the specified parameters.
uri
- the URI that identifies the encrypted octet sequencetransforms
- a list of Transform
s. The list is defensively
copied to protect against subsequent modification. May be null or
empty.
CipherReference
java.lang.IllegalArgumentException
- if uri
is not
RFC2396 compliant
java.lang.NullPointerException
- if uri
is null
java.lang.ClassCastException
- if transforms
contains any
entries that are not of type Transformpublic 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 abstract EncryptedType unmarshalEncryptedType(XMLDecryptContext context) throws MarshalException
EncryptedType
instance from a
mechanism-specific XMLDecryptContext
instance.
context
- the mechanism-specific decryption context
EncryptedType
java.lang.NullPointerException
- if context
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 AgreementMethod newAgreementMethod(java.lang.String algorithm, byte[] kaNonce, KeyInfo originatorKeyInfo, KeyInfo recipientKeyInfo, AgreementMethodParameterSpec params) throws java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterException
AgreementMethod
.
algorithm
- the URI identifying the key agreement algorithmkaNonce
- the KA-Nonce (may be null
). The value of
kaNonce is cloned to protect against subsequent modificationoriginatorKeyInfo
- the originator's key info (may be
null
)recipientKeyInfo
- the recipient's key info (may be
null
)params
- algorithm-specific agreement method parameters
(may be null
)
AgreementMethod
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 EncryptedKey newEncryptedKey(ToBeEncryptedKey key, EncryptionMethod encMethod, KeyInfo keyInfo, EncryptionProperties properties, java.util.List references, java.lang.String id, java.lang.String carriedKeyName, java.lang.String recipient)
EncryptedKey
which contains a CipherValue
.
key
- the key to be encryptedencMethod
- the encryption method (may be null
)keyInfo
- the key info (may be null
)properties
- the encryption properties (may be null
)references
- a list of DataReference
s or KeyReference
s (may be null
or empty)id
- the ID of the EncryptedKeyElement (may be null
)carriedKeyName
- the carried key name (may be null
)recipient
- the recipient (may be null
)
EncryptedKey
java.lang.ClassCastException
- if references
contains any
entries that are not of type DataReference
or
KeyReference
java.lang.NullPointerException
- if key
is null
public abstract EncryptedKey newEncryptedKey(ToBeEncryptedKey key, EncryptionMethod encMethod, KeyInfo keyInfo, EncryptionProperties properties, java.util.List references, java.lang.String id, java.lang.String carriedKeyName, java.lang.String recipient, CipherReference cipherRef)
EncryptedKey
.
key
- the key to be encryptedencMethod
- the encryption method (may be null
)keyInfo
- the key info (may be null
)properties
- the encryption properties (may be null
)references
- a list of DataReference
s or KeyReference
s (may be null
or empty)id
- the ID of the EncryptedKey element (may be null
)carriedKeyName
- the carried key name (may be null
)recipient
- the recipient (may be null
)cipherRef
- the CiphereReference this EncryptedData will contain
EncryptedKey
java.lang.ClassCastException
- if references
contains any
entries that are not of type DataReference
or
KeyReference
java.lang.NullPointerException
- if key
or cipherRef
is nullpublic abstract KeyInfo newOriginatorKeyInfo(java.util.List content, java.lang.String id)
content
- a list of one or more XMLStructures representing key
information types. The list is defensively copied to protect against
subsequent modification.id
- the value of an XML ID (may be null)
java.lang.NullPointerException
- if content is null
java.lang.IllegalArgumentException
- if content is empty
java.lang.ClassCastException
- if content contains any entities that are not
of type XMLStructurepublic abstract KeyInfo newRecipientKeyInfo(java.util.List content, java.lang.String id)
content
- a list of one or more XMLStructures representing key
information types. The list is defensively copied to protect against
subsequent modification.id
- the value of an XML ID (may be null)
java.lang.NullPointerException
- if content is null
java.lang.IllegalArgumentException
- if content is empty
java.lang.ClassCastException
- if content contains any entities that are not
of type XMLStructurepublic abstract DHKeyValue newDHKeyValue(java.security.PublicKey key) throws java.security.KeyException
key
- the public key for DH algorithm
java.security.KeyException
- if the key can not be used to create
the DHKeyValue
java.lang.NullPointerException
- if the key is null
|
XML Digital Signature and Encryption, 1.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |