FileDocCategorySizeDatePackage
X509CertificateResolver.javaAPI DocJava SE 6 API5797Tue Jun 10 00:23:02 BST 2008com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations

X509CertificateResolver

public class X509CertificateResolver extends KeyResolverSpi
Resolves Certificates which are directly contained inside a ds:X509Certificate Element.
author
$Author: raul $

Fields Summary
static Logger
log
{@link java.util.logging} logging facility
Element[]
_x509CertKeyElements
Field _dsaKeyElement
XMLX509Certificate[]
_x509certObject
Field _x509certObject[]
Constructors Summary
Methods Summary
public booleanengineCanResolve(org.w3c.dom.Element element, java.lang.String BaseURI, com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver storage)
Method engineCanResolve

inheritDoc
param
element
param
BaseURI
param
storage


                
        
                                     
   	  if (true)
   	  	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");

      if (!XMLUtils.elementIsInSignatureSpace(element,
                 Constants._TAG_X509DATA)) {
         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");

         return false;
      }
         

         this._x509CertKeyElements = XMLUtils.selectDsNodes(element.getFirstChild(),
                 Constants._TAG_X509CERTIFICATE);

         if ((this._x509CertKeyElements != null)
                 && (this._x509CertKeyElements.length > 0)) {
            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Yes Sir, I can");

            return true;
         }

      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");

      return false;
   
public java.security.PublicKeyengineResolvePublicKey(org.w3c.dom.Element element, java.lang.String BaseURI, com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver storage)
Method engineResolvePublicKey

inheritDoc
param
element
param
BaseURI
param
storage
throws
KeyResolverException


                  
     
                
                

      X509Certificate cert = this.engineResolveX509Certificate(element,
                                BaseURI, storage);

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

      return null;
   
public javax.crypto.SecretKeyengineResolveSecretKey(org.w3c.dom.Element element, java.lang.String BaseURI, com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver storage)
Method engineResolveSecretKey

inheritDoc
param
element
param
BaseURI
param
storage

      return null;
   
public java.security.cert.X509CertificateengineResolveX509Certificate(org.w3c.dom.Element element, java.lang.String BaseURI, com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver storage)
Method engineResolveX509Certificate

inheritDoc
param
element
param
BaseURI
param
storage
throws
KeyResolverException


      try {
         if ((this._x509CertKeyElements == null)
                 || (this._x509CertKeyElements.length == 0)) {
            boolean weCanResolve = this.engineCanResolve(element, BaseURI,
                                      storage);

            if (!weCanResolve || (this._x509CertKeyElements == null)
                    || (this._x509CertKeyElements.length == 0)) {
               return null;
            }
         }

         this._x509certObject =
            new XMLX509Certificate[this._x509CertKeyElements.length];

         // populate Object array
         for (int i = 0; i < this._x509CertKeyElements.length; i++) {
            this._x509certObject[i] =
               new XMLX509Certificate(this._x509CertKeyElements[i]
                  , BaseURI);
         }

         for (int i = 0; i < this._x509certObject.length; i++) {
            X509Certificate cert = this._x509certObject[i].getX509Certificate();

            if (cert != null) {
               return cert;
            }
         }

         return null;
      } catch (XMLSecurityException ex) {
         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);

         throw new KeyResolverException("generic.EmptyMessage", ex);
      }