FileDocCategorySizeDatePackage
KeyInfo.javaAPI DocJava SE 6 API38892Tue Jun 10 00:23:02 BST 2008com.sun.org.apache.xml.internal.security.keys

KeyInfo

public class KeyInfo extends SignatureElementProxy
This class stand for KeyInfo Element that may contain keys, names, certificates and other public key management information, such as in-band key distribution or key agreement data.
KeyInfo Element has two basic functions: One is KeyResolve for getting the public key in signature validation processing. the other one is toElement for getting the element in signature generation processing.
The lengthXXX() methods provide access to the internal Key objects:
  • If the KeyInfo was constructed from an Element (Signature verification), the lengthXXX() methods searches for child elements of ds:KeyInfo for known types.
  • If the KeyInfo was constructed from scratch (during Signature generation), the lengthXXX() methods return the number of XXXs objects already passed to the KeyInfo

The addXXX() methods are used for adding Objects of the appropriate type to the KeyInfo. This is used during signature generation.
The itemXXX(int i) methods return the i'th object of the corresponding type.
The containsXXX() methods return whether the KeyInfo contains the corresponding type.
author
$Author: raul $

Fields Summary
static Logger
log
{@link java.util.logging} logging facility
List
_internalKeyResolvers
Stores the individual (per-KeyInfo) {@link KeyResolver}s
List
_storageResolvers
Field _storageResolvers
static boolean
_alreadyInitialized
Constructors Summary
public KeyInfo(Document doc)
Constructor KeyInfo

param
doc




           
      

      super(doc);

      XMLUtils.addReturnToElement(this._constructionElement);


   
public KeyInfo(Element element, String BaseURI)
Constructor KeyInfo

param
element
param
BaseURI
throws
XMLSecurityException


      super(element, BaseURI);

   
Methods Summary
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue rsakeyvalue)
Method add

param
rsakeyvalue

      this.add(new KeyValue(this._doc, rsakeyvalue));
   
public voidadd(java.security.PublicKey pk)
Method add

param
pk

      this.add(new KeyValue(this._doc, pk));
   
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.KeyValue keyvalue)
Method add

param
keyvalue


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(keyvalue.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.MgmtData mgmtdata)
Method add

param
mgmtdata


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(mgmtdata.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.PGPData pgpdata)
Method addPGPData

param
pgpdata


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(pgpdata.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.RetrievalMethod retrievalmethod)
Method add

param
retrievalmethod


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(retrievalmethod.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.SPKIData spkidata)
Method add

param
spkidata


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(spkidata.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.X509Data x509data)
Method addX509Data

param
x509data


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(x509data.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidadd(com.sun.org.apache.xml.internal.security.encryption.EncryptedKey encryptedKey)
Method addEncryptedKey

param
encryptedKey
throws
XMLEncryptionException


		if (this._state == MODE_SIGN) {
			XMLCipher cipher = XMLCipher.getInstance();
			this._constructionElement.appendChild(cipher.martial(encryptedKey));
		}

	
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.KeyName keyname)
Method add

param
keyname


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(keyname.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public voidadd(com.sun.org.apache.xml.internal.security.keys.content.keyvalues.DSAKeyValue dsakeyvalue)
Method add

param
dsakeyvalue

      this.add(new KeyValue(this._doc, dsakeyvalue));
   
public voidaddKeyName(java.lang.String keynameString)
Method addKeyName

param
keynameString

      this.add(new KeyName(this._doc, keynameString));
   
public voidaddKeyValue(java.security.PublicKey pk)
Method addKeyValue

param
pk

      this.add(new KeyValue(this._doc, pk));
   
public voidaddKeyValue(org.w3c.dom.Element unknownKeyValueElement)
Method addKeyValue

param
unknownKeyValueElement

      this.add(new KeyValue(this._doc, unknownKeyValueElement));
   
public voidaddMgmtData(java.lang.String mgmtdata)
Method addMgmtData

param
mgmtdata

      this.add(new MgmtData(this._doc, mgmtdata));
   
public voidaddRetrievalMethod(java.lang.String URI, com.sun.org.apache.xml.internal.security.transforms.Transforms transforms, java.lang.String Type)
Method addRetrievalMethod

param
URI
param
transforms
param
Type

      this.add(new RetrievalMethod(this._doc, URI, transforms, Type));
   
public voidaddStorageResolver(com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver storageResolver)
Method addStorageResolver

param
storageResolver


           
       

      if (storageResolver != null) {
         this._storageResolvers.add(storageResolver);
      }
   
public voidaddUnknownElement(org.w3c.dom.Element element)
Method addUnknownElement

param
element


      if (this._state == MODE_SIGN) {
         this._constructionElement.appendChild(element);
         XMLUtils.addReturnToElement(this._constructionElement);
      }
   
public booleancontainsKeyName()
Method containsKeyName

return
If the KeyInfo contains a KeyName node

      return this.lengthKeyName() > 0;
   
public booleancontainsKeyValue()
Method containsKeyValue

return
If the KeyInfo contains a KeyValue node

      return this.lengthKeyValue() > 0;
   
public booleancontainsMgmtData()
Method containsMgmtData

return
If the KeyInfo contains a MgmtData node

      return this.lengthMgmtData() > 0;
   
public booleancontainsPGPData()
Method containsPGPData

return
If the KeyInfo contains a PGPData node

      return this.lengthPGPData() > 0;
   
public booleancontainsRetrievalMethod()
Method containsRetrievalMethod

return
If the KeyInfo contains a RetrievalMethod node

      return this.lengthRetrievalMethod() > 0;
   
public booleancontainsSPKIData()
Method containsSPKIData

return
If the KeyInfo contains a SPKIData node

      return this.lengthSPKIData() > 0;
   
public booleancontainsUnknownElement()
Method containsUnknownElement

return
If the KeyInfo contains a UnknownElement node

      return this.lengthUnknownElement() > 0;
   
public booleancontainsX509Data()
Method containsX509Data

return
If the KeyInfo contains a X509Data node

      return this.lengthX509Data() > 0;
   
public java.lang.StringgetBaseLocalName()

inheritDoc

      return Constants._TAG_KEYINFO;
   
public java.lang.StringgetId()
Returns the Id attribute

return
the Id attribute

      return this._constructionElement.getAttributeNS(null, Constants._ATT_ID);
   
public java.security.PublicKeygetPublicKey()
This method returns the public key.

return
If the KeyInfo contains a PublicKey node
throws
KeyResolverException


      PublicKey pk = this.getPublicKeyFromInternalResolvers();

      if (pk != null) {
         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I could find a key using the per-KeyInfo key resolvers");

         return pk;
      } 
      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I couldn't find a key using the per-KeyInfo key resolvers");      

      pk = this.getPublicKeyFromStaticResolvers();

      if (pk != null) {
         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I could find a key using the system-wide key resolvers");

         return pk;
      }
      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I couldn't find a key using the system-wide key resolvers");      

      return null;
   
java.security.PublicKeygetPublicKeyFromInternalResolvers()
Searches the per-KeyInfo keyresolvers for public keys

return
The publick contained in this Node.
throws
KeyResolverException


      for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
         KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
         if (true)
         	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());

         Node currentChild=this._constructionElement.getFirstChild();
         while (currentChild!=null)      {    
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
               if (this._storageResolvers.size() == 0) {

                  // if we do not have storage resolvers, we verify with null
                  StorageResolver storage = null;

                  if (keyResolver.engineCanResolve((Element) currentChild,
                                                   this.getBaseURI(),
                                                   storage)) {
                     PublicKey pk =
                        keyResolver
                           .engineResolvePublicKey((Element) currentChild, this
                              .getBaseURI(), storage);

                     if (pk != null) {
                        return pk;
                     }
                  }
               } else {
                  for (int k = 0; k < this._storageResolvers.size(); k++) {
                     StorageResolver storage =
                        (StorageResolver) this._storageResolvers.get(k);

                     if (keyResolver.engineCanResolve((Element) currentChild,
                                                      this.getBaseURI(),
                                                      storage)) {
                        PublicKey pk = keyResolver
                           .engineResolvePublicKey((Element) currentChild, this
                              .getBaseURI(), storage);

                        if (pk != null) {
                           return pk;
                        }
                     }
                  }
               }
            }
            currentChild=currentChild.getNextSibling();
         }
      }

      return null;
   
java.security.PublicKeygetPublicKeyFromStaticResolvers()
Searches the library wide keyresolvers for public keys

return
The publick contained in this Node.
throws
KeyResolverException


      for (int i = 0; i < KeyResolver.length(); i++) {
         KeyResolver keyResolver = KeyResolver.item(i);
         Node currentChild=this._constructionElement.getFirstChild();
         while (currentChild!=null)      {       
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
               if (this._storageResolvers.size() == 0) {

                  // if we do not have storage resolvers, we verify with null
                  StorageResolver storage = null;

                  if (keyResolver.canResolve((Element) currentChild,
                                             this.getBaseURI(), storage)) {
                     PublicKey pk =
                        keyResolver.resolvePublicKey((Element) currentChild,
                                                     this.getBaseURI(),
                                                     storage);

                     if (pk != null) {
                        return pk;
                     }
                  }
               } else {
                  for (int k = 0; k < this._storageResolvers.size(); k++) {
                     StorageResolver storage =
                        (StorageResolver) this._storageResolvers.get(k);

                     if (keyResolver.canResolve((Element) currentChild,
                                                this.getBaseURI(), storage)) {
                        PublicKey pk =
                           keyResolver.resolvePublicKey((Element) currentChild,
                                                        this.getBaseURI(),
                                                        storage);

                        if (pk != null) {
                           return pk;
                        }
                     }
                  }
               }               
            }
            currentChild=currentChild.getNextSibling();
         }      
      }
      return null;
   
public javax.crypto.SecretKeygetSecretKey()
This method returns a secret (symmetric) key. This is for XML Encryption.

return
the secret key contained in this KeyInfo
throws
KeyResolverException

      SecretKey sk = this.getSecretKeyFromInternalResolvers();

      if (sk != null) {
         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I could find a secret key using the per-KeyInfo key resolvers");

         return sk;
      } 
      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I couldn't find a secret key using the per-KeyInfo key resolvers");
      

      sk = this.getSecretKeyFromStaticResolvers();

      if (sk != null) {
         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I could find a secret key using the system-wide key resolvers");

         return sk;
      } 
      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I couldn't find a secret key using the system-wide key resolvers");
      

      return null;
   
javax.crypto.SecretKeygetSecretKeyFromInternalResolvers()
Searches the per-KeyInfo keyresolvers for secret keys

return
the secret key contained in this KeyInfo
throws
KeyResolverException


      for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
         KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
         if (true)
         	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());

         Node currentChild=this._constructionElement.getFirstChild();
         while (currentChild!=null)      {    
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
               if (this._storageResolvers.size() == 0) {

                  // if we do not have storage resolvers, we verify with null
                  StorageResolver storage = null;

                  if (keyResolver.engineCanResolve((Element) currentChild,
                                                   this.getBaseURI(),
                                                   storage)) {
                     SecretKey sk =
                        keyResolver
                           .engineResolveSecretKey((Element) currentChild, this
                              .getBaseURI(), storage);

                     if (sk != null) {
                        return sk;
                     }
                  }
               } else {
                  for (int k = 0; k < this._storageResolvers.size(); k++) {
                     StorageResolver storage =
                        (StorageResolver) this._storageResolvers.get(k);

                     if (keyResolver.engineCanResolve((Element) currentChild,
                                                      this.getBaseURI(),
                                                      storage)) {
                        SecretKey sk = keyResolver
                           .engineResolveSecretKey((Element) currentChild, this
                              .getBaseURI(), storage);

                        if (sk != null) {
                           return sk;
                        }
                     }
                  }
               }
            }
            currentChild=currentChild.getNextSibling();
         }
      }

      return null;
   
javax.crypto.SecretKeygetSecretKeyFromStaticResolvers()
Searches the library wide keyresolvers for Secret keys

return
the secret key contained in this KeyInfo
throws
KeyResolverException


      for (int i = 0; i < KeyResolver.length(); i++) {
         KeyResolver keyResolver = KeyResolver.item(i);

         Node currentChild=this._constructionElement.getFirstChild();
         while (currentChild!=null)      {    
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
               if (this._storageResolvers.size() == 0) {

                  // if we do not have storage resolvers, we verify with null
                  StorageResolver storage = null;

                  if (keyResolver.canResolve((Element) currentChild,
                                             this.getBaseURI(), storage)) {
                     SecretKey sk  =
                        keyResolver.resolveSecretKey((Element) currentChild,
                                                     this.getBaseURI(),
                                                     storage);

                     if (sk != null) {
                        return sk;
                     }
                  }
               } else {
                  for (int k = 0; k < this._storageResolvers.size(); k++) {
                     StorageResolver storage =
                        (StorageResolver) this._storageResolvers.get(k);

                     if (keyResolver.canResolve((Element) currentChild,
                                                this.getBaseURI(), storage)) {
                        SecretKey sk =
                           keyResolver.resolveSecretKey((Element) currentChild,
                                                        this.getBaseURI(),
                                                        storage);

                        if (sk != null) {
                           return sk;
                        }
                     }
                  }
               }
            }
            currentChild=currentChild.getNextSibling();
         }
      }
      return null;
   
java.util.ListgetStorageResolvers()
Method getStorageResolvers

return
the internalStorages

      return this._storageResolvers;
   
public java.security.cert.X509CertificategetX509Certificate()
Method getX509Certificate

return
The certificate contined in this KeyInfo
throws
KeyResolverException


      // First search using the individual resolvers from the user
      X509Certificate cert = this.getX509CertificateFromInternalResolvers();

      if (cert != null) {
         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, 
            "I could find a X509Certificate using the per-KeyInfo key resolvers");

         return cert;
      } 
      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, 
            "I couldn't find a X509Certificate using the per-KeyInfo key resolvers");
      

      // Then use the system-wide Resolvers
      cert = this.getX509CertificateFromStaticResolvers();

      if (cert != null) {
         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, 
            "I could find a X509Certificate using the system-wide key resolvers");

         return cert;
      } 
      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, 
            "I couldn't find a X509Certificate using the system-wide key resolvers");
      

      return null;
   
java.security.cert.X509CertificategetX509CertificateFromInternalResolvers()
Method getX509CertificateFromInternalResolvers

return
The certificate contined in this KeyInfo
throws
KeyResolverException

      if (true)
      	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromInternalResolvers() with "
                + this.lengthInternalKeyResolver() + " resolvers");

      for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
         KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
         if (true)
         	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());

         Node currentChild=this._constructionElement.getFirstChild();
         while (currentChild!=null)      {    
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
               if (this._storageResolvers.size() == 0) {

                  // if we do not have storage resolvers, we verify with null
                  StorageResolver storage = null;

                  if (keyResolver.engineCanResolve((Element) currentChild,
                                                   this.getBaseURI(),
                                                   storage)) {
                     X509Certificate cert =
                        keyResolver.engineResolveX509Certificate(
                           (Element) currentChild, this.getBaseURI(), storage);

                     if (cert != null) {
                        return cert;
                     }
                  }
               } else {
                  for (int k = 0; k < this._storageResolvers.size(); k++) {
                     StorageResolver storage =
                        (StorageResolver) this._storageResolvers.get(k);

                     if (keyResolver.engineCanResolve((Element) currentChild,
                                                      this.getBaseURI(),
                                                      storage)) {
                        X509Certificate cert =
                           keyResolver.engineResolveX509Certificate(
                              (Element) currentChild, this.getBaseURI(),
                              storage);

                        if (cert != null) {
                           return cert;
                        }
                     }
                  }
               }
            }
            currentChild=currentChild.getNextSibling();
         }
      }

      return null;
   
java.security.cert.X509CertificategetX509CertificateFromStaticResolvers()
This method uses each System-wide {@link KeyResolver} to search the child elements. Each combination of {@link KeyResolver} and child element is checked against all {@link StorageResolver}s.

return
The certificate contined in this KeyInfo
throws
KeyResolverException

      if (true)
      	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromStaticResolvers() with "
                + KeyResolver.length() + " resolvers");

      for (int i = 0; i < KeyResolver.length(); i++) {
         KeyResolver keyResolver = KeyResolver.item(i);
         Node currentChild=this._constructionElement.getFirstChild();
         while (currentChild!=null)      {       
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
               if (this._storageResolvers.size() == 0) {

                  // if we do not have storage resolvers, we verify with null
                  StorageResolver storage = null;

                  if (keyResolver.canResolve((Element) currentChild,
                                             this.getBaseURI(), storage)) {
                     X509Certificate cert =
                        keyResolver
                           .resolveX509Certificate((Element) currentChild, this
                              .getBaseURI(), storage);

                     if (cert != null) {
                        return cert;
                     }
                  }
               } else {
                  for (int k = 0; k < this._storageResolvers.size(); k++) {
                     StorageResolver storage =
                        (StorageResolver) this._storageResolvers.get(k);

                     if (keyResolver.canResolve((Element) currentChild,
                                                this.getBaseURI(), storage)) {
                        X509Certificate cert = keyResolver
                           .resolveX509Certificate((Element) currentChild, this
                              .getBaseURI(), storage);

                        if (cert != null) {
                           return cert;
                        }
                     }
                  }
               }               
            }
            currentChild=currentChild.getNextSibling();
         }      
      }
      return null;
   
public static voidinit()
init the keyinfo (Still needed?)

        
       

      if (!KeyInfo._alreadyInitialized) {
         if (KeyInfo.log == null) {

            /**
             * $todo$ why the hell does the static initialization from the
             *  start not work ?
             */
            KeyInfo.log =
                    java.util.logging.Logger.getLogger(KeyInfo.class.getName());

            log.log(java.util.logging.Level.SEVERE, "Had to assign log in the init() function");
         }

         // KeyInfo._contentHandlerHash = new HashMap(10);
         KeyInfo._alreadyInitialized = true;
      }
   
public booleanisEmpty()
Method isEmpty

return
true if the element has no descedants.

      return this._constructionElement.getFirstChild()==null;
   
public com.sun.org.apache.xml.internal.security.encryption.EncryptedKeyitemEncryptedKey(int i)
Method itemEncryptedKey

param
i
return
the asked EncryptedKey element, null if the index is too big
throws
XMLSecurityException


		Element e = 
			XMLUtils.selectXencNode(this._constructionElement.getFirstChild(),
										  EncryptionConstants._TAG_ENCRYPTEDKEY,i);

		if (e != null) {
			XMLCipher cipher = XMLCipher.getInstance();
			cipher.init(XMLCipher.UNWRAP_MODE, null);
			return cipher.loadEncryptedKey(e);
		}
		return null;
   
com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpiitemInternalKeyResolver(int i)
Method itemInternalKeyResolver

param
i the index
return
the KeyResolverSpi for the index.

      return (KeyResolverSpi) this._internalKeyResolvers.get(i);
   
public com.sun.org.apache.xml.internal.security.keys.content.KeyNameitemKeyName(int i)
Method itemKeyName

param
i
return
the asked KeyName element, null if the index is too big
throws
XMLSecurityException


      Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                Constants._TAG_KEYNAME,i);

      if (e != null) {
         return new KeyName(e, this._baseURI);
      } 
      return null;      
   
public com.sun.org.apache.xml.internal.security.keys.content.KeyValueitemKeyValue(int i)
Method itemKeyValue

param
i
return
the asked KeyValue element, null if the index is too big
throws
XMLSecurityException


      Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                Constants._TAG_KEYVALUE,i);

      if (e != null) {
         return new KeyValue(e, this._baseURI);
      } 
      return null;      
   
public com.sun.org.apache.xml.internal.security.keys.content.MgmtDataitemMgmtData(int i)
Method itemMgmtData

param
i
return
the asked MgmtData element, null if the index is too big
throws
XMLSecurityException


      Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                Constants._TAG_MGMTDATA,i);

      if (e != null) {
         return new MgmtData(e, this._baseURI);
      } 
       return null;      
   
public com.sun.org.apache.xml.internal.security.keys.content.PGPDataitemPGPData(int i)
Method itemPGPData

param
i
return
the asked PGPData element, null if the index is too big
throws
XMLSecurityException


      Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                Constants._TAG_PGPDATA,i);

      if (e != null) {
         return new PGPData(e, this._baseURI);
      } 
      return null;      
   
public com.sun.org.apache.xml.internal.security.keys.content.RetrievalMethoditemRetrievalMethod(int i)
Method itemRetrievalMethod

param
i
return
the asked RetrievalMethod element, null if the index is too big
throws
XMLSecurityException


      Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                Constants._TAG_RETRIEVALMETHOD,i);

      if (e != null) {
         return new RetrievalMethod(e, this._baseURI);
      } 
      return null;
   
public com.sun.org.apache.xml.internal.security.keys.content.SPKIDataitemSPKIData(int i)
Method itemSPKIData

param
i
return
the asked SPKIData element, null if the index is too big
throws
XMLSecurityException


      Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                Constants._TAG_SPKIDATA,i);

      if (e != null) {
         return new SPKIData(e, this._baseURI);
      } 
      return null;     
   
public org.w3c.dom.ElementitemUnknownElement(int i)
Method itemUnknownElement

param
i index
return
the element number of the unknown elemens


      NodeList nl = this._constructionElement.getChildNodes();
      int res = 0;

      for (int j = 0; j < nl.getLength(); j++) {
         Node current = nl.item(j);

         /**
          * $todo$ using this method, we don't see unknown Elements
          *  from Signature NS; revisit
          */
         if ((current.getNodeType() == Node.ELEMENT_NODE)
                 && current.getNamespaceURI()
                    .equals(Constants.SignatureSpecNS)) {
            res++;

            if (res == i) {
               return (Element) current;
            }
         }
      }

      return null;
   
public com.sun.org.apache.xml.internal.security.keys.content.X509DataitemX509Data(int i)
Method itemX509Data

return
the asked X509Data element, null if the index is too big
param
i
throws
XMLSecurityException


      Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                Constants._TAG_X509DATA,i);

      if (e != null) {
         return new X509Data(e, this._baseURI);
      } 
      return null;
   
intlengthInternalKeyResolver()
Method lengthInternalKeyResolver

return
the length of the key

      return this._internalKeyResolvers.size();
   
public intlengthKeyName()
Method lengthKeyName

return
the number of the KeyName tags

      return this.length(Constants.SignatureSpecNS, Constants._TAG_KEYNAME);
   
public intlengthKeyValue()
Method lengthKeyValue

return
the number of the KeyValue tags

      return this.length(Constants.SignatureSpecNS, Constants._TAG_KEYVALUE);
   
public intlengthMgmtData()
Method lengthMgmtData

return
the number of the MgmtData tags

      return this.length(Constants.SignatureSpecNS, Constants._TAG_MGMTDATA);
   
public intlengthPGPData()
Method lengthPGPData

return
the number of the PGPDat. tags

      return this.length(Constants.SignatureSpecNS, Constants._TAG_PGPDATA);
   
public intlengthRetrievalMethod()
Method lengthRetrievalMethod

return
the number of the RetrievalMethod tags

      return this.length(Constants.SignatureSpecNS,
                         Constants._TAG_RETRIEVALMETHOD);
   
public intlengthSPKIData()
Method lengthSPKIData

return
the number of the SPKIData tags

      return this.length(Constants.SignatureSpecNS, Constants._TAG_SPKIDATA);
   
public intlengthUnknownElement()
Method lengthUnknownElement NOTE posibly buggy.

return
the number of the UnknownElement tags


      int res = 0;
      NodeList nl = this._constructionElement.getChildNodes();

      for (int i = 0; i < nl.getLength(); i++) {
         Node current = nl.item(i);

         /**
          * $todo$ using this method, we don't see unknown Elements
          *  from Signature NS; revisit
          */
         if ((current.getNodeType() == Node.ELEMENT_NODE)
                 && current.getNamespaceURI()
                    .equals(Constants.SignatureSpecNS)) {
            res++;
         }
      }

      return res;
   
public intlengthX509Data()
Method lengthX509Data

return
the number of the X509Data tags

      return this.length(Constants.SignatureSpecNS, Constants._TAG_X509DATA);
   
public voidregisterInternalKeyResolver(com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi realKeyResolver)
This method is used to add a custom {@link KeyResolverSpi} to a KeyInfo object.

param
realKeyResolver


                       
       
      this._internalKeyResolvers.add(realKeyResolver);
   
public voidsetId(java.lang.String Id)
Sets the Id attribute

param
Id ID


      if ((this._state == MODE_SIGN) && (Id != null)) {
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
         IdResolver.registerElementById(this._constructionElement, Id);
      }