jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
author mullan
Fri, 21 Nov 2014 15:23:36 -0500
changeset 27747 3a271dc8b758
parent 25859 3317bb8137f4
child 40551 05eba5515cbb
permissions -rw-r--r--
8046949: Generify the javax.xml.crypto API Reviewed-by: xuelei
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
     2
 * reserved comment block
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 */
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
     5
/**
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
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: 18240
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: 18240
diff changeset
     8
 * distributed with this work for additional information
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
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: 18240
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: 18240
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: 18240
diff changeset
    12
 * with the License. You may obtain a copy of the License at
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    13
 *
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    14
 * http://www.apache.org/licenses/LICENSE-2.0
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    15
 *
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
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: 18240
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: 18240
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: 18240
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: 18240
diff changeset
    20
 * specific language governing permissions and limitations
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    21
 * under the License.
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    22
 */
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    23
/*
27747
3a271dc8b758 8046949: Generify the javax.xml.crypto API
mullan
parents: 25859
diff changeset
    24
 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    25
 */
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    26
/*
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    27
 * $Id: ApacheTransform.java 1333869 2012-05-04 10:42:44Z coheigea $
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
package org.jcp.xml.dsig.internal.dom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.OutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.security.InvalidAlgorithmParameterException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.security.spec.AlgorithmParameterSpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import org.w3c.dom.Document;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import org.w3c.dom.Element;
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    37
import org.w3c.dom.Node;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import com.sun.org.apache.xml.internal.security.transforms.Transform;
18240
cda839ac048f 6741606: Integrate Apache Santuario
mullan
parents: 5506
diff changeset
    41
import com.sun.org.apache.xml.internal.security.transforms.Transforms;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import javax.xml.crypto.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import javax.xml.crypto.dom.DOMCryptoContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import javax.xml.crypto.dsig.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * This is a wrapper/glue class which invokes the Apache XML-Security
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * Transform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @author Sean Mullan
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * @author Erwin van der Koogh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
public abstract class ApacheTransform extends TransformService {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    57
    static {
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    58
        com.sun.org.apache.xml.internal.security.Init.init();
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    59
    }
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    60
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    61
    private static java.util.logging.Logger log =
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    62
        java.util.logging.Logger.getLogger("org.jcp.xml.dsig.internal.dom");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private Transform apacheTransform;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    protected Document ownerDoc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    protected Element transformElem;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    protected TransformParameterSpec params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public final AlgorithmParameterSpec getParameterSpec() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        return params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public void init(XMLStructure parent, XMLCryptoContext context)
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    73
        throws InvalidAlgorithmParameterException
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    74
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        if (context != null && !(context instanceof DOMCryptoContext)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            throw new ClassCastException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                ("context must be of type DOMCryptoContext");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        }
19204
440d320f9144 8022120: JCK test api/javax_xml/crypto/dsig/TransformService/index_ParamMethods fails
mullan
parents: 18780
diff changeset
    79
        if (parent == null) {
440d320f9144 8022120: JCK test api/javax_xml/crypto/dsig/TransformService/index_ParamMethods fails
mullan
parents: 18780
diff changeset
    80
            throw new NullPointerException();
440d320f9144 8022120: JCK test api/javax_xml/crypto/dsig/TransformService/index_ParamMethods fails
mullan
parents: 18780
diff changeset
    81
        }
440d320f9144 8022120: JCK test api/javax_xml/crypto/dsig/TransformService/index_ParamMethods fails
mullan
parents: 18780
diff changeset
    82
        if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    83
            throw new ClassCastException("parent must be of type DOMStructure");
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    84
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        transformElem = (Element)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            ((javax.xml.crypto.dom.DOMStructure) parent).getNode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        ownerDoc = DOMUtils.getOwnerDocument(transformElem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public void marshalParams(XMLStructure parent, XMLCryptoContext context)
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    91
        throws MarshalException
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
    92
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        if (context != null && !(context instanceof DOMCryptoContext)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            throw new ClassCastException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                ("context must be of type DOMCryptoContext");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
19204
440d320f9144 8022120: JCK test api/javax_xml/crypto/dsig/TransformService/index_ParamMethods fails
mullan
parents: 18780
diff changeset
    97
        if (parent == null) {
440d320f9144 8022120: JCK test api/javax_xml/crypto/dsig/TransformService/index_ParamMethods fails
mullan
parents: 18780
diff changeset
    98
            throw new NullPointerException();
440d320f9144 8022120: JCK test api/javax_xml/crypto/dsig/TransformService/index_ParamMethods fails
mullan
parents: 18780
diff changeset
    99
        }
440d320f9144 8022120: JCK test api/javax_xml/crypto/dsig/TransformService/index_ParamMethods fails
mullan
parents: 18780
diff changeset
   100
        if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   101
            throw new ClassCastException("parent must be of type DOMStructure");
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   102
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        transformElem = (Element)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            ((javax.xml.crypto.dom.DOMStructure) parent).getNode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        ownerDoc = DOMUtils.getOwnerDocument(transformElem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public Data transform(Data data, XMLCryptoContext xc)
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   109
        throws TransformException
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   110
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        if (data == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            throw new NullPointerException("data must not be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        }
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   114
        return transformIt(data, xc, (OutputStream)null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   118
        throws TransformException
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   119
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        if (data == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            throw new NullPointerException("data must not be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        if (os == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            throw new NullPointerException("output stream must not be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        return transformIt(data, xc, os);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    private Data transformIt(Data data, XMLCryptoContext xc, OutputStream os)
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   130
        throws TransformException
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   131
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (ownerDoc == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            throw new TransformException("transform must be marshalled");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        if (apacheTransform == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            try {
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   138
                apacheTransform =
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   139
                    new Transform(ownerDoc, getAlgorithm(), transformElem.getChildNodes());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                apacheTransform.setElement(transformElem, xc.getBaseURI());
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   141
                if (log.isLoggable(java.util.logging.Level.FINE)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   142
                    log.log(java.util.logging.Level.FINE, "Created transform for algorithm: " +
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   143
                            getAlgorithm());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            } catch (Exception ex) {
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   146
                throw new TransformException("Couldn't find Transform for: " +
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   147
                                             getAlgorithm(), ex);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
18240
cda839ac048f 6741606: Integrate Apache Santuario
mullan
parents: 5506
diff changeset
   151
        if (Utils.secureValidation(xc)) {
cda839ac048f 6741606: Integrate Apache Santuario
mullan
parents: 5506
diff changeset
   152
            String algorithm = getAlgorithm();
cda839ac048f 6741606: Integrate Apache Santuario
mullan
parents: 5506
diff changeset
   153
            if (Transforms.TRANSFORM_XSLT.equals(algorithm)) {
cda839ac048f 6741606: Integrate Apache Santuario
mullan
parents: 5506
diff changeset
   154
                throw new TransformException(
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   155
                    "Transform " + algorithm + " is forbidden when secure validation is enabled"
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   156
                );
18240
cda839ac048f 6741606: Integrate Apache Santuario
mullan
parents: 5506
diff changeset
   157
            }
cda839ac048f 6741606: Integrate Apache Santuario
mullan
parents: 5506
diff changeset
   158
        }
cda839ac048f 6741606: Integrate Apache Santuario
mullan
parents: 5506
diff changeset
   159
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        XMLSignatureInput in;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        if (data instanceof ApacheData) {
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   162
            if (log.isLoggable(java.util.logging.Level.FINE)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   163
                log.log(java.util.logging.Level.FINE, "ApacheData = true");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            }
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   165
            in = ((ApacheData)data).getXMLSignatureInput();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        } else if (data instanceof NodeSetData) {
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   167
            if (log.isLoggable(java.util.logging.Level.FINE)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   168
                log.log(java.util.logging.Level.FINE, "isNodeSet() = true");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            if (data instanceof DOMSubTreeData) {
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   171
                if (log.isLoggable(java.util.logging.Level.FINE)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   172
                    log.log(java.util.logging.Level.FINE, "DOMSubTreeData = true");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                }
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   174
                DOMSubTreeData subTree = (DOMSubTreeData)data;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                in = new XMLSignatureInput(subTree.getRoot());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                in.setExcludeComments(subTree.excludeComments());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            } else {
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   178
                Set<Node> nodeSet =
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   179
                    Utils.toNodeSet(((NodeSetData)data).iterator());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                in = new XMLSignatureInput(nodeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        } else {
18780
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   183
            if (log.isLoggable(java.util.logging.Level.FINE)) {
f47b920867e7 8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents: 18240
diff changeset
   184
                log.log(java.util.logging.Level.FINE, "isNodeSet() = false");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                in = new XMLSignatureInput
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                    (((OctetStreamData)data).getOctetStream());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            } catch (Exception ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                throw new TransformException(ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            if (os != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                in = apacheTransform.performTransform(in, os);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                if (!in.isNodeSet() && !in.isElement()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                in = apacheTransform.performTransform(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            if (in.isOctetStream()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                return new ApacheOctetStreamData(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                return new ApacheNodeSetData(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        } catch (Exception ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            throw new TransformException(ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public final boolean isFeatureSupported(String feature) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if (feature == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
}