jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java
author xuelei
Sat, 12 Oct 2013 20:46:35 -0700
changeset 22325 f22d936a0ff5
parent 18780 f47b920867e7
permissions -rw-r--r--
8025026: Enhance canonicalization Summary: Don't use cached null xmlns definition. Also reviewed by Alexander Fomin <alexander.fomin@oracle.com> Reviewed-by: mullan, hawtin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 */
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
     5
/**
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
     7
 * or more contributor license agreements. See the NOTICE file
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
     8
 * distributed with this work for additional information
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
     9
 * regarding copyright ownership. The ASF licenses this file
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    10
 * to you under the Apache License, Version 2.0 (the
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    11
 * "License"); you may not use this file except in compliance
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    12
 * with the License. You may obtain a copy of the License at
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * http://www.apache.org/licenses/LICENSE-2.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    16
 * Unless required by applicable law or agreed to in writing,
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    17
 * software distributed under the License is distributed on an
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    18
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    19
 * KIND, either express or implied. See the License for the
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    20
 * specific language governing permissions and limitations
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    21
 * under the License.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
package com.sun.org.apache.xml.internal.security.c14n.implementations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    25
import java.io.IOException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.SortedSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.TreeSet;
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    30
import javax.xml.parsers.ParserConfigurationException;
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    31
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import com.sun.org.apache.xml.internal.security.c14n.helper.C14nHelper;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import com.sun.org.apache.xml.internal.security.transforms.params.InclusiveNamespaces;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import com.sun.org.apache.xml.internal.security.utils.Constants;
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    37
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import org.w3c.dom.Attr;
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    39
import org.w3c.dom.Document;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import org.w3c.dom.Element;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import org.w3c.dom.NamedNodeMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import org.w3c.dom.Node;
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    43
import org.xml.sax.SAXException;
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    44
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * Implements &quot; <A
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * HREF="http://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/">Exclusive XML
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * Canonicalization, Version 1.0 </A>&quot; <BR />
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * Credits: During restructuring of the Canonicalizer framework, Ren??
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * Kollmorgen from Software AG submitted an implementation of ExclC14n which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * fitted into the old architecture and which based heavily on my old (and slow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * implementation of "Canonical XML". A big "thank you" to Ren?? for this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <BR />
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <i>THIS </i> implementation is a complete rewrite of the algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @author Christian Geuer-Pollmann <geuerp@apache.org>
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    57
 * @version $Revision: 1147448 $
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @see <a href="http://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/ Exclusive#">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *          XML Canonicalization, Version 1.0</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    62
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    63
    private static final String XML_LANG_URI = Constants.XML_LANG_SPACE_SpecNS;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    64
    private static final String XMLNS_URI = Constants.NamespaceSpecNS;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    65
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
      * This Set contains the names (Strings like "xmlns" or "xmlns:foo") of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
      * the inclusive namespaces.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
      */
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    70
    private SortedSet<String> inclusiveNSSet;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    71
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    72
    private final SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    73
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    74
    /**
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    75
     * Constructor Canonicalizer20010315Excl
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    76
     *
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    77
     * @param includeComments
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    78
     */
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    79
    public Canonicalizer20010315Excl(boolean includeComments) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    80
        super(includeComments);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    81
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    83
    /**
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    84
     * Method engineCanonicalizeSubTree
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    85
     * @inheritDoc
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    86
     * @param rootNode
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    87
     *
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    88
     * @throws CanonicalizationException
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    89
     */
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    90
    public byte[] engineCanonicalizeSubTree(Node rootNode)
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    91
        throws CanonicalizationException {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    92
        return engineCanonicalizeSubTree(rootNode, "", null);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    93
    }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    94
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    95
    /**
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    96
     * Method engineCanonicalizeSubTree
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    97
     *  @inheritDoc
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    98
     * @param rootNode
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
    99
     * @param inclusiveNamespaces
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   100
     *
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   101
     * @throws CanonicalizationException
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   102
     */
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   103
    public byte[] engineCanonicalizeSubTree(
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   104
        Node rootNode, String inclusiveNamespaces
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   105
    ) throws CanonicalizationException {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   106
        return engineCanonicalizeSubTree(rootNode, inclusiveNamespaces, null);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   107
    }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   108
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   109
    /**
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   110
     * Method engineCanonicalizeSubTree
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   111
     * @param rootNode
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param inclusiveNamespaces
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param excl A element to exclude from the c14n process.
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   114
     * @return the rootNode c14n.
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   115
     * @throws CanonicalizationException
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   116
     */
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   117
    public byte[] engineCanonicalizeSubTree(
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   118
        Node rootNode, String inclusiveNamespaces, Node excl
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   119
    ) throws CanonicalizationException{
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   120
        inclusiveNSSet = InclusiveNamespaces.prefixStr2Set(inclusiveNamespaces);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   121
        return super.engineCanonicalizeSubTree(rootNode, excl);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   122
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   124
    /**
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   125
     *
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   126
     * @param rootNode
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   127
     * @param inclusiveNamespaces
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   128
     * @return the rootNode c14n.
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   129
     * @throws CanonicalizationException
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   130
     */
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   131
    public byte[] engineCanonicalize(
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   132
        XMLSignatureInput rootNode, String inclusiveNamespaces
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   133
    ) throws CanonicalizationException {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   134
        inclusiveNSSet = InclusiveNamespaces.prefixStr2Set(inclusiveNamespaces);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   135
        return super.engineCanonicalize(rootNode);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   136
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   138
    /**
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   139
     * Method engineCanonicalizeXPathNodeSet
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   140
     * @inheritDoc
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   141
     * @param xpathNodeSet
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   142
     * @param inclusiveNamespaces
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   143
     * @throws CanonicalizationException
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   144
     */
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   145
    public byte[] engineCanonicalizeXPathNodeSet(
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   146
        Set<Node> xpathNodeSet, String inclusiveNamespaces
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   147
    ) throws CanonicalizationException {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   148
        inclusiveNSSet = InclusiveNamespaces.prefixStr2Set(inclusiveNamespaces);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   149
        return super.engineCanonicalizeXPathNodeSet(xpathNodeSet);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   150
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   152
    @Override
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   153
    protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   154
        throws CanonicalizationException {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   155
        // result will contain the attrs which have to be output
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   156
        final SortedSet<Attr> result = this.result;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   157
        result.clear();
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   158
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   159
        // The prefix visibly utilized (in the attribute or in the name) in
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   160
        // the element
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   161
        SortedSet<String> visiblyUtilized = new TreeSet<String>();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   162
        if (inclusiveNSSet != null && !inclusiveNSSet.isEmpty()) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   163
            visiblyUtilized.addAll(inclusiveNSSet);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   166
        if (element.hasAttributes()) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   167
            NamedNodeMap attrs = element.getAttributes();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   168
            int attrsLength = attrs.getLength();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   169
            for (int i = 0; i < attrsLength; i++) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   170
                Attr attribute = (Attr) attrs.item(i);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   171
                String NName = attribute.getLocalName();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   172
                String NNodeValue = attribute.getNodeValue();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   174
                if (!XMLNS_URI.equals(attribute.getNamespaceURI())) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   175
                    // Not a namespace definition.
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   176
                    // The Element is output element, add the prefix (if used) to
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   177
                    // visiblyUtilized
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   178
                    String prefix = attribute.getPrefix();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   179
                    if (prefix != null && !(prefix.equals(XML) || prefix.equals(XMLNS))) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   180
                        visiblyUtilized.add(prefix);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   181
                    }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   182
                    // Add to the result.
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   183
                    result.add(attribute);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   184
                } else if (!(XML.equals(NName) && XML_LANG_URI.equals(NNodeValue))
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   185
                    && ns.addMapping(NName, NNodeValue, attribute)
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   186
                    && C14nHelper.namespaceIsRelative(NNodeValue)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   187
                    // The default mapping for xml must not be output.
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   188
                    // New definition check if it is relative.
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   189
                    Object exArgs[] = {element.getTagName(), NName, attribute.getNodeValue()};
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   190
                    throw new CanonicalizationException(
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   191
                        "c14n.Canonicalizer.RelativeNamespace", exArgs
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   192
                    );
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   193
                }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   194
            }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   195
        }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   196
        String prefix = null;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   197
        if (element.getNamespaceURI() != null
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   198
            && !(element.getPrefix() == null || element.getPrefix().length() == 0)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   199
            prefix = element.getPrefix();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   200
        } else {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   201
            prefix = XMLNS;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   202
        }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   203
        visiblyUtilized.add(prefix);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   205
        for (String s : visiblyUtilized) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   206
            Attr key = ns.getMapping(s);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   207
            if (key != null) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   208
                result.add(key);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   209
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   212
        return result.iterator();
10694
cf59e2badd14 7088502: Security libraries don't build with javac -Werror
mullan
parents: 1337
diff changeset
   213
    }
cf59e2badd14 7088502: Security libraries don't build with javac -Werror
mullan
parents: 1337
diff changeset
   214
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   215
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @inheritDoc
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   217
     * @param element
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   218
     * @throws CanonicalizationException
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   219
     */
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   220
    @Override
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   221
    protected final Iterator<Attr> handleAttributes(Element element, NameSpaceSymbTable ns)
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   222
        throws CanonicalizationException {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   223
        // result will contain the attrs which have to be output
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   224
        final SortedSet<Attr> result = this.result;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   225
        result.clear();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   226
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   227
        // The prefix visibly utilized (in the attribute or in the name) in
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   228
        // the element
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   229
        Set<String> visiblyUtilized = null;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   230
        // It's the output selected.
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   231
        boolean isOutputElement = isVisibleDO(element, ns.getLevel()) == 1;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   232
        if (isOutputElement) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   233
            visiblyUtilized = new TreeSet<String>();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   234
            if (inclusiveNSSet != null && !inclusiveNSSet.isEmpty()) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   235
                visiblyUtilized.addAll(inclusiveNSSet);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   236
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   239
        if (element.hasAttributes()) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   240
            NamedNodeMap attrs = element.getAttributes();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   241
            int attrsLength = attrs.getLength();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   242
            for (int i = 0; i < attrsLength; i++) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   243
                Attr attribute = (Attr) attrs.item(i);
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   244
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   245
                String NName = attribute.getLocalName();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   246
                String NNodeValue = attribute.getNodeValue();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   248
                if (!XMLNS_URI.equals(attribute.getNamespaceURI())) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   249
                    if (isVisible(attribute) && isOutputElement) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   250
                        // The Element is output element, add the prefix (if used)
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   251
                        // to visibyUtilized
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   252
                        String prefix = attribute.getPrefix();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   253
                        if (prefix != null && !(prefix.equals(XML) || prefix.equals(XMLNS))) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   254
                            visiblyUtilized.add(prefix);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                        }
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   256
                        // Add to the result.
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   257
                        result.add(attribute);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   258
                    }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   259
                } else if (isOutputElement && !isVisible(attribute) && !XMLNS.equals(NName)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   260
                    ns.removeMappingIfNotRender(NName);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   261
                } else {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   262
                    if (!isOutputElement && isVisible(attribute)
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   263
                        && inclusiveNSSet.contains(NName)
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   264
                        && !ns.removeMappingIfRender(NName)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   265
                        Node n = ns.addMappingAndRender(NName, NNodeValue, attribute);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   266
                        if (n != null) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   267
                            result.add((Attr)n);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   268
                            if (C14nHelper.namespaceIsRelative(attribute)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   269
                                Object exArgs[] = { element.getTagName(), NName, attribute.getNodeValue() };
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   270
                                throw new CanonicalizationException(
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   271
                                    "c14n.Canonicalizer.RelativeNamespace", exArgs
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   272
                                );
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   273
                            }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   274
                        }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   275
                    }
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   276
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   277
                    if (ns.addMapping(NName, NNodeValue, attribute)
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   278
                        && C14nHelper.namespaceIsRelative(NNodeValue)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   279
                        // New definition check if it is relative
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   280
                        Object exArgs[] = { element.getTagName(), NName, attribute.getNodeValue() };
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   281
                        throw new CanonicalizationException(
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   282
                            "c14n.Canonicalizer.RelativeNamespace", exArgs
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   283
                        );
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   284
                    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            }
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   287
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   289
        if (isOutputElement) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   290
            // The element is visible, handle the xmlns definition
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   291
            Attr xmlns = element.getAttributeNodeNS(XMLNS_URI, XMLNS);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   292
            if (xmlns != null && !isVisible(xmlns)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   293
                // There is a definition but the xmlns is not selected by the
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   294
                // xpath. then xmlns=""
22325
f22d936a0ff5 8025026: Enhance canonicalization
xuelei
parents: 18780
diff changeset
   295
                ns.addMapping(XMLNS, "", getNullNode(xmlns.getOwnerDocument()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   298
            String prefix = null;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   299
            if (element.getNamespaceURI() != null
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   300
                && !(element.getPrefix() == null || element.getPrefix().length() == 0)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   301
                prefix = element.getPrefix();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   302
            } else {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   303
                prefix = XMLNS;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   304
            }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   305
            visiblyUtilized.add(prefix);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   306
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   307
            for (String s : visiblyUtilized) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   308
                Attr key = ns.getMapping(s);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   309
                if (key != null) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   310
                    result.add(key);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                }
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   312
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        }
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   314
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   315
        return result.iterator();
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   316
    }
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   317
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   318
    protected void circumventBugIfNeeded(XMLSignatureInput input)
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   319
        throws CanonicalizationException, ParserConfigurationException,
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   320
               IOException, SAXException {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   321
        if (!input.isNeedsToBeExpanded() || inclusiveNSSet.isEmpty() || inclusiveNSSet.isEmpty()) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   322
            return;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   323
        }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   324
        Document doc = null;
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   325
        if (input.getSubNode() != null) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   326
            doc = XMLUtils.getOwnerDocument(input.getSubNode());
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   327
        } else {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   328
            doc = XMLUtils.getOwnerDocument(input.getNodeSet());
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   329
        }
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   330
        XMLUtils.circumventBug2650(doc);
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 10694
diff changeset
   331
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
}