FileDocCategorySizeDatePackage
C14nHelper.javaAPI DocJava SE 6 API4542Tue Jun 10 00:23:00 BST 2008com.sun.org.apache.xml.internal.security.c14n.helper

C14nHelper

public class C14nHelper extends Object
Temporary swapped static functions from the normalizer Section
author
Christian Geuer-Pollmann

Fields Summary
Constructors Summary
private C14nHelper()
Constructor C14nHelper


      // don't allow instantiation
   
Methods Summary
public static voidassertNotRelativeNS(org.w3c.dom.Attr attr)
This method throws an exception if the Attribute value contains a relative URI.

param
attr
throws
CanonicalizationException


      if (attr == null) {
         return;
      }

      String nodeAttrName = attr.getNodeName();
      boolean definesDefaultNS = nodeAttrName.equals("xmlns");
      boolean definesNonDefaultNS = nodeAttrName.startsWith("xmlns:");

      if (definesDefaultNS || definesNonDefaultNS) {
         if (namespaceIsRelative(attr)) {
            String parentName = attr.getOwnerElement().getTagName();
            String attrValue = attr.getValue();
            Object exArgs[] = { parentName, nodeAttrName, attrValue };

            throw new CanonicalizationException(
               "c14n.Canonicalizer.RelativeNamespace", exArgs);
         }
      }
   
public static voidcheckForRelativeNamespace(org.w3c.dom.Element ctxNode)
This method throws a CanonicalizationException if the supplied Element contains any relative namespaces.

param
ctxNode
throws
CanonicalizationException
see
C14nHelper#assertNotRelativeNS(Attr)


      if (ctxNode != null) {
         NamedNodeMap attributes = ctxNode.getAttributes();

         for (int i = 0; i < attributes.getLength(); i++) {
            C14nHelper.assertNotRelativeNS((Attr) attributes.item(i));
         }
      } else {
         throw new CanonicalizationException(
            "Called checkForRelativeNamespace() on null");
      }
   
public static voidcheckTraversability(org.w3c.dom.Document document)
This method throws a CanonicalizationException if the supplied Document is not able to be traversed using a TreeWalker.

param
document
throws
CanonicalizationException


      if (!document.isSupported("Traversal", "2.0")) {
         Object exArgs[] = {
            document.getImplementation().getClass().getName() };

         throw new CanonicalizationException(
            "c14n.Canonicalizer.TraversalNotSupported", exArgs);
      }
   
public static booleannamespaceIsAbsolute(org.w3c.dom.Attr namespace)
Method namespaceIsAbsolute

param
namespace
return
true if the given namespace is absolute.

      return namespaceIsAbsolute(namespace.getValue());
   
public static booleannamespaceIsAbsolute(java.lang.String namespaceValue)
Method namespaceIsAbsolute

param
namespaceValue
return
true if the given namespace is absolute.


      // assume empty namespaces are absolute
      if (namespaceValue.length() == 0) {
         return true;
      }
      return namespaceValue.indexOf(':")>0;
   
public static booleannamespaceIsRelative(org.w3c.dom.Attr namespace)
Method namespaceIsRelative

param
namespace
return
true if the given namespace is relative.

      return !namespaceIsAbsolute(namespace);
   
public static booleannamespaceIsRelative(java.lang.String namespaceValue)
Method namespaceIsRelative

param
namespaceValue
return
true if the given namespace is relative.

      return !namespaceIsAbsolute(namespaceValue);