public class KeyManagerImpl extends java.lang.Object implements VerifierKeyManager, SignerKeyManager
SignerKeyManager and SignerKeyManager, and therefore it can be used both in
the signature creation and in the signature verification use case.
A lot of different key information hints can be used with XML signatures. This key manager copes with
this large amount of information by employing so called key providers. A key provider is responsible
for a certain type of key information hints, such as KeyValue or X509Data hints. The functionality, which
this key manager requires form a key provider both in the signature creation and in the signature
verification use case, is specified in the interface KeyProviderInterface.
If this key manager is initialized with the DOM representation of the XML signature's KeyInfo element, it tries to instantiate a key provider for each type of key information found in this element. If a key provider is actually instantiated, depends on the associations between key information types and their corresponding implementation classes provided with the IXSIL keymanager properties.
If this key manager is asked to provide the verification key in the verification use case, it delegates this request to its registerred key providers. If the first registerred key provider fails to provide the verfication key, the second registerred key provider is asked for it, and so forth. If a key provider can provide the key, no more key providers are asked.
In the signature creation use case, key providers are registerred with the method addKeyProvider(iaik.ixsil.keyinfo.KeyProviderInterface). If the key manager is asked by IXSIL to provide the DOM representation of the KeyInfo
XML element, which should be incorporated into the XML signature, it asks every registerred key provider
for the DOM representation of the key information hints the key provider is responsible for, collects
the hints provided by all key providers into a XML KeyInfo element, and delivers this XML KeyInfo element
to IXSIL.
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
id_
Value for the "Id" attribute of the XML Object element.
|
protected java.util.Vector |
keyProviders_
A list of all key providers (
KeyProviderInterface), which are registerred at this key manager. |
protected org.w3c.dom.Document |
signatureDOMDoc_
The DOM document bearing the XML signature.
|
protected URIResolverParameters |
uRIResolverParameters_
Parameters used by the key manager when resolving URIs.
|
| Constructor and Description |
|---|
KeyManagerImpl()
This constructor will be used by IXSIL in case of signature verification.
|
KeyManagerImpl(org.w3c.dom.Document signatureDOMDoc)
This constructor can be used in case of signature creation, if the application wants to create a new
key manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addKeyProvider(KeyProviderInterface keyProvider)
Used by the application to register a key provider at this key manager.
|
java.lang.String |
getId()
Gets the Id attribute of the KeyInfo Element represented by this this KeyManagerImpl object.
|
org.w3c.dom.Element |
getKeyInfo()
Gets the DOM representation of the XML KeyInfo element including all the keying information, which
should be incorporated into the XML signature.
|
KeyProviderInterface |
getKeyProvider()
Returns a reference to the particular key provider that provided the verification public key
to this
KeyManagerImpl. |
KeyProviderInterface[] |
getKeyProviders()
Gets an array of all key providers registerred at this key manager.
|
protected java.lang.String |
getSubelementName(int ranking)
Gets the name of the preferred KeyInfo subelement with the specified ranking from the IXSIL
keymanager properties.
|
java.security.Key |
getVerifierKey()
Gets the key which will be used to verify the XML signature.
|
void |
removeKeyProvider(KeyProviderInterface keyProvider)
Removes the specified key provider from this key manager's list of registerred key providers.
|
void |
setId(java.lang.String id)
Sets the Id attribute of the KeyInfo Element represented by this KeyManagerImpl object.
|
void |
setKeyInfo(org.w3c.dom.Element keyInfo)
Initializes this key manager with the DOM representation of the XML KeyInfo element, as found in the
XML signature to be verified.
|
void |
setURIResolverParameters(URIResolverParameters params)
Sets the parameters to be used by the key mananger when resolving URIs.
|
protected java.lang.String id_
protected java.util.Vector keyProviders_
KeyProviderInterface), which are registerred at this key manager.protected org.w3c.dom.Document signatureDOMDoc_
getKeyInfo() to create DOM nodes.protected URIResolverParameters uRIResolverParameters_
public KeyManagerImpl()
public KeyManagerImpl(org.w3c.dom.Document signatureDOMDoc)
signatureDOMDoc - A reference to the DOM document bearing the XML Signature. Used in method getKeyInfo() to create DOM nodes. Must not be null.public void setId(java.lang.String id)
null, the attribute will be removed.id - The value for the Id attribute.public java.lang.String getId()
getId in interface SignerKeyManagergetId in interface VerifierKeyManagernull if the attribute is not set.public java.security.Key getVerifierKey()
throws KeyManagerException
getVerifierKey in interface VerifierKeyManagerKeyManagerException - if no key provider is registerred, or if none of the registerred key
providers can deliver the key.public org.w3c.dom.Element getKeyInfo()
throws KeyManagerException
getKeyInfoSubelements of each registerred
key provider will be invoked in order to collect all key information hints which should be incorporated
into the XML KeyInfo element.getKeyInfo in interface SignerKeyManagernull, if there are no key information hints available.KeyManagerException - if producing the XML KeyInfo element fails for any reason.public void setKeyInfo(org.w3c.dom.Element keyInfo)
throws KeyManagerException
KeyProviderInterface
implementation class will be instantiated and initialized if such subelements are found within the
KeyInfo element.
The mappings between subelement name and KeyProviderInterface implementation classname are
specified in the IXSIL KeyInfo Properties.setKeyInfo in interface VerifierKeyManagerkeyInfo - The DOM representation of the XML KeyInfo element, as found in the XML signature.KeyManagerException - if the KeyInfo element cannot be interpreted well.public void addKeyProvider(KeyProviderInterface keyProvider)
keyProvider - The key provider to be added to this key manager. Must not be null.public void removeKeyProvider(KeyProviderInterface keyProvider)
keyProvider - The key provider to be removed. Must not be null. If the specified
key provider is not registerred, this method will have no effect.public KeyProviderInterface[] getKeyProviders()
getKeyProviders in interface SignerKeyManagergetKeyProviders in interface VerifierKeyManagernull, if there are no registerred
providers available.public KeyProviderInterface getKeyProvider()
KeyManagerImpl.getKeyProvider in interface VerifierKeyManagernull, if there is no such key provider.protected java.lang.String getSubelementName(int ranking)
throws InitException
ranking - The ranking of the preferred subelement, which name is requested. Must match interval
[1,99].null,
if no preferred KeyInfo subelement is available for the specified ranking.InitException - if the IXSIL KeyInfo Properties cannot be found.public void setURIResolverParameters(URIResolverParameters params)
setURIResolverParameters in interface SignerKeyManagersetURIResolverParameters in interface VerifierKeyManagerparams - The parameters to be set. May be null to indicate a restore of the default
values. The base URI will be set to a dummy value in that case.