FileDocCategorySizeDatePackage
ResolverFragment.javaAPI DocJava SE 6 API5301Tue Jun 10 00:23:04 BST 2008com.sun.org.apache.xml.internal.security.utils.resolver.implementations

ResolverFragment

public class ResolverFragment extends ResourceResolverSpi
This resolver is used for resolving same-document URIs like URI="" of URI="#id".
author
$Author: dims $
see
The Reference processing model in the XML Signature spec
see
Same-Document URI-References in the XML Signature spec
see
Section 4.2 of RFC 2396

Fields Summary
static Logger
log
{@link java.util.logging} logging facility
Constructors Summary
Methods Summary
public booleanengineCanResolve(org.w3c.dom.Attr uri, java.lang.String BaseURI)
Method engineCanResolve

inheritDoc
param
uri
param
BaseURI


      if (uri == null) {
         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Quick fail for null uri");
         return false;
      }

      String uriNodeValue = uri.getNodeValue();

      if (uriNodeValue.equals("")
              || ((uriNodeValue.charAt(0)=='#")
                  &&!uriNodeValue.startsWith("#xpointer("))) {
         if (true)
         	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "State I can resolve reference: \"" + uriNodeValue + "\"");
         return true;
      }
      if (true)
      	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Do not seem to be able to resolve reference: \"" + uriNodeValue + "\"");
      return false;
   
public com.sun.org.apache.xml.internal.security.signature.XMLSignatureInputengineResolve(org.w3c.dom.Attr uri, java.lang.String BaseURI)
Method engineResolve Wird das gleiche Dokument referenziert? Wird ein anderes Dokument referenziert?

inheritDoc
param
uri
param
BaseURI


                        
         
        
   

      String uriNodeValue = uri.getNodeValue();
      Document doc = uri.getOwnerElement().getOwnerDocument();


      Node selectedElem = null;
      if (uriNodeValue.equals("")) {

         /*
          * Identifies the node-set (minus any comment nodes) of the XML
          * resource containing the signature
          */

         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "ResolverFragment with empty URI (means complete document)");
	 selectedElem = doc;
      } else {

         /*
          * URI="#chapter1"
          * Identifies a node-set containing the element with ID attribute
          * value 'chapter1' of the XML resource containing the signature.
          * XML Signature (and its applications) modify this node-set to
          * include the element plus all descendents including namespaces and
          * attributes -- but not comments.
          */
         String id = uriNodeValue.substring(1);

         // Element selectedElem = doc.getElementById(id);
         selectedElem = IdResolver.getElementById(doc, id);
         if (selectedElem==null) {
         	Object exArgs[] = { id };
            throw new ResourceResolverException(
               "signature.Verification.MissingID", exArgs, uri, BaseURI);
         }
         if (true)
         	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Try to catch an Element with ID " + id + " and Element was " + selectedElem);
      }

      XMLSignatureInput result = new XMLSignatureInput(selectedElem);
      result.setExcludeComments(true);

      //if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "We return a nodeset with " + resultSet.size() + " nodes");
      result.setMIMEType("text/xml");	  
	  result.setSourceURI((BaseURI != null) ? BaseURI.concat(uri.getNodeValue()) :
		  uri.getNodeValue());      
      return result;