jaxp/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java
author joehw
Thu, 01 Sep 2016 17:03:41 -0700
changeset 40755 26f6264ee481
parent 39907 db51759e3695
child 44802 89a545213cad
permissions -rw-r--r--
8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present Reviewed-by: aefimov, lancea, dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
     1
/*
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
     4
 *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    10
 *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    15
 * accompanied this code).
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    16
 *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    20
 *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    23
 * questions.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    24
 */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    25
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    26
package jdk.xml.internal;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    27
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    28
import javax.xml.XMLConstants;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    29
import static jdk.xml.internal.JdkXmlUtils.SP_USE_CATALOG;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    30
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    31
/**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    32
 * This class manages JDK's XML Features. Previously added features and properties
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    33
 * may be gradually moved to this class.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    34
 */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    35
public class JdkXmlFeatures {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    36
    public static final String ORACLE_JAXP_PROPERTY_PREFIX =
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    37
        "http://www.oracle.com/xml/jaxp/properties/";
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    38
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    39
     * Feature enableExtensionFunctions
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    40
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    41
    public static final String ORACLE_ENABLE_EXTENSION_FUNCTION =
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    42
            ORACLE_JAXP_PROPERTY_PREFIX + "enableExtensionFunctions";
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    43
    public static final String SP_ENABLE_EXTENSION_FUNCTION =
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    44
            "javax.xml.enableExtensionFunctions";
40755
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
    45
    // This is the correct name by the spec
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
    46
    public static final String SP_ENABLE_EXTENSION_FUNCTION_SPEC =
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
    47
            "jdk.xml.enableExtensionFunctions";
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    48
    public static final String CATALOG_FEATURES = "javax.xml.catalog.catalogFeatures";
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    49
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    50
    public final static String PROPERTY_USE_CATALOG = XMLConstants.USE_CATALOG;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    51
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    52
    public static enum XmlFeature {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    53
        /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    54
         * Feature enableExtensionFunctions
40755
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
    55
         * FSP: extension function is enforced by FSP. When FSP is on, extension
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    56
         * function is disabled.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    57
         */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    58
        ENABLE_EXTENSION_FUNCTION(ORACLE_ENABLE_EXTENSION_FUNCTION,
40755
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
    59
                SP_ENABLE_EXTENSION_FUNCTION_SPEC, true, false, true, true),
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    60
        /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    61
         * The {@link javax.xml.XMLConstants.USE_CATALOG} feature.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    62
         * FSP: USE_CATALOG is not enforced by FSP.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    63
         */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    64
        USE_CATALOG(PROPERTY_USE_CATALOG, SP_USE_CATALOG, true, false, true, false);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    65
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    66
        private final String name;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    67
        private final String nameSP;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    68
        private final boolean valueDefault;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    69
        private final boolean valueEnforced;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    70
        private final boolean hasSystem;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    71
        private final boolean enforced;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    72
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    73
        /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    74
         * Constructs an XmlFeature instance.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    75
         * @param name the name of the feature
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    76
         * @param nameSP the name of the System Property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    77
         * @param value the value of the feature
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    78
         * @param hasSystem a flag to indicate whether the feature is supported
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    79
         * @param enforced a flag indicating whether the feature is
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    80
         * FSP (Feature_Secure_Processing) enforced
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    81
         * with a System property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    82
         */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    83
        XmlFeature(String name, String nameSP, boolean value, boolean valueEnforced, boolean hasSystem, boolean enforced) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    84
            this.name = name;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    85
            this.nameSP = nameSP;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    86
            this.valueDefault = value;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    87
            this.valueEnforced = valueEnforced;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    88
            this.hasSystem = hasSystem;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    89
            this.enforced = enforced;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    90
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    91
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    92
        /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    93
         * Checks whether the specified property is equal to the current property.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    94
         * @param propertyName the name of a property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    95
         * @return true if the specified property is the current property, false
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    96
         * otherwise
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    97
         */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    98
        boolean equalsPropertyName(String propertyName) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
    99
            return name.equals(propertyName);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   100
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   101
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   102
        /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   103
         * Returns the name of the property.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   104
         *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   105
         * @return the name of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   106
         */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   107
        public String apiProperty() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   108
            return name;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   109
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   110
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   111
        /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   112
         * Returns the name of the corresponding System Property.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   113
         *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   114
         * @return the name of the System Property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   115
         */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   116
        String systemProperty() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   117
            return nameSP;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   118
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   119
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   120
        /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   121
         * Returns the default value of the property.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   122
         * @return the default value of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   123
         */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   124
        public boolean defaultValue() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   125
            return valueDefault;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   126
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   127
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   128
        /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   129
         * Returns the FSP-enforced value.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   130
         * @return the FSP-enforced value
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   131
         */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   132
        public boolean enforcedValue() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   133
            return valueEnforced;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   134
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   135
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   136
        /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   137
         * Checks whether System property is supported for the feature.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   138
         * @return true it is supported, false otherwise
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   139
         */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   140
        boolean hasSystemProperty() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   141
            return hasSystem;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   142
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   143
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   144
        /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   145
         * Checks whether the property is enforced by FSP
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   146
         * @return true it is, false otherwise
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   147
         */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   148
        boolean enforced() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   149
            return enforced;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   150
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   151
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   152
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   153
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   154
    /**
40755
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   155
     * Maps old property names with the new ones. This map is used to keep track of
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   156
     * name changes so that old or incorrect names continue to be supported for compatibility.
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   157
     */
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   158
    public static enum NameMap {
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   159
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   160
        ENABLE_EXTENSION_FUNCTION(SP_ENABLE_EXTENSION_FUNCTION_SPEC, SP_ENABLE_EXTENSION_FUNCTION);
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   161
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   162
        final String newName;
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   163
        final String oldName;
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   164
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   165
        NameMap(String newName, String oldName) {
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   166
            this.newName = newName;
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   167
            this.oldName = oldName;
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   168
        }
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   169
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   170
        String getOldName(String newName) {
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   171
            if (newName.equals(this.newName)) {
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   172
                return oldName;
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   173
            }
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   174
            return null;
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   175
        }
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   176
    }
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   177
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   178
    /**
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   179
     * States of the settings of a property, in the order: default value, value
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   180
     * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   181
     * properties, and jaxp api properties
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   182
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   183
    public static enum State {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   184
        //this order reflects the overriding order
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   185
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   186
        DEFAULT("default"), FSP("FEATURE_SECURE_PROCESSING"),
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   187
        JAXPDOTPROPERTIES("jaxp.properties"), SYSTEMPROPERTY("system property"),
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   188
        APIPROPERTY("property");
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   189
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   190
        final String literal;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   191
        State(String literal) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   192
            this.literal = literal;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   193
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   194
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   195
        String literal() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   196
            return literal;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   197
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   198
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   199
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   200
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   201
     * Values of the features
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   202
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   203
    private boolean[] featureValues;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   204
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   205
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   206
     * States of the settings for each property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   207
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   208
    private State[] states;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   209
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   210
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   211
     * Flag indicating if secure processing is set
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   212
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   213
    boolean secureProcessing;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   214
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   215
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   216
     * Instantiate JdkXmlFeatures and initialize the fields
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   217
     * @param secureProcessing
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   218
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   219
    public JdkXmlFeatures(boolean secureProcessing) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   220
        featureValues = new boolean[XmlFeature.values().length];
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   221
        states = new State[XmlFeature.values().length];
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   222
        this.secureProcessing = secureProcessing;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   223
        for (XmlFeature f : XmlFeature.values()) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   224
            if (secureProcessing && f.enforced()) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   225
                featureValues[f.ordinal()] = f.enforcedValue();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   226
                states[f.ordinal()] = State.FSP;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   227
            } else {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   228
                featureValues[f.ordinal()] = f.defaultValue();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   229
                states[f.ordinal()] = State.DEFAULT;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   230
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   231
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   232
        //read system properties or jaxp.properties
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   233
        readSystemProperties();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   234
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   235
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   236
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   237
     * Updates the JdkXmlFeatures instance by reading the system properties again.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   238
     * This will become necessary in case the system properties are set after
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   239
     * the instance has been created.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   240
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   241
    public void update() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   242
        readSystemProperties();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   243
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   244
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   245
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   246
     * Set feature by property name and state
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   247
     * @param propertyName property name
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   248
     * @param state the state of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   249
     * @param value the value of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   250
     * @return true if the property is managed by the JdkXmlFeatures instance;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   251
     *         false otherwise.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   252
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   253
    public boolean setFeature(String propertyName, State state, Object value) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   254
        int index = getIndex(propertyName);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   255
        if (index > -1) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   256
            setFeature(index, state, value);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   257
            return true;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   258
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   259
        return false;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   260
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   261
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   262
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   263
     * Set the value for a specific feature.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   264
     *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   265
     * @param feature the feature
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   266
     * @param state the state of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   267
     * @param value the value of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   268
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   269
    public void setFeature(XmlFeature feature, State state, boolean value) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   270
        setFeature(feature.ordinal(), state, value);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   271
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   272
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   273
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   274
     * Return the value of the specified property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   275
     *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   276
     * @param feature the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   277
     * @return the value of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   278
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   279
    public boolean getFeature(XmlFeature feature) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   280
        return featureValues[feature.ordinal()];
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   281
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   282
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   283
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   284
     * Return the value of a feature by its index (the Feature's ordinal)
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   285
     * @param index the index of a feature
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   286
     * @return value of a feature
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   287
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   288
    public boolean getFeature(int index) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   289
        return featureValues[index];
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   290
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   291
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   292
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   293
     * Set the value of a property by its index
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   294
     *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   295
     * @param index the index of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   296
     * @param state the state of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   297
     * @param value the value of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   298
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   299
    public void setFeature(int index, State state, Object value) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   300
        boolean temp;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   301
        if (Boolean.class.isAssignableFrom(value.getClass())) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   302
            temp = (Boolean)value;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   303
        } else {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   304
            temp = Boolean.parseBoolean((String) value);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   305
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   306
        setFeature(index, state, temp);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   307
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   308
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   309
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   310
     * Set the value of a property by its index
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   311
     *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   312
     * @param index the index of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   313
     * @param state the state of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   314
     * @param value the value of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   315
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   316
    public void setFeature(int index, State state, boolean value) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   317
        //only update if it shall override
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   318
        if (state.compareTo(states[index]) >= 0) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   319
            featureValues[index] = value;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   320
            states[index] = state;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   321
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   322
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   323
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   324
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   325
     * Get the index by property name
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   326
     *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   327
     * @param propertyName property name
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   328
     * @return the index of the property if found; return -1 if not
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   329
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   330
    public int getIndex(String propertyName) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   331
        for (XmlFeature feature : XmlFeature.values()) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   332
            if (feature.equalsPropertyName(propertyName)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   333
                //internally, ordinal is used as index
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   334
                return feature.ordinal();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   335
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   336
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   337
        return -1;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   338
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   339
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   340
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   341
     * Read from system properties, or those in jaxp.properties
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   342
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   343
    private void readSystemProperties() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   344
        for (XmlFeature feature : XmlFeature.values()) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   345
            getSystemProperty(feature, feature.systemProperty());
40755
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   346
            if (!getSystemProperty(feature, feature.systemProperty())) {
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   347
                //if system property is not found, try the older form if any
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   348
                for (NameMap nameMap : NameMap.values()) {
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   349
                    String oldName = nameMap.getOldName(feature.systemProperty());
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   350
                    if (oldName != null) {
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   351
                        getSystemProperty(feature, oldName);
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   352
                    }
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   353
                }
26f6264ee481 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present
joehw
parents: 39907
diff changeset
   354
            }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   355
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   356
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   357
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   358
    /**
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   359
     * Read from system properties, or those in jaxp.properties
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   360
     *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   361
     * @param property the type of the property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   362
     * @param sysPropertyName the name of system property
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   363
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   364
    private boolean getSystemProperty(XmlFeature feature, String sysPropertyName) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   365
        try {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   366
            String value = SecuritySupport.getSystemProperty(sysPropertyName);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   367
            if (value != null && !value.equals("")) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   368
                setFeature(feature, State.SYSTEMPROPERTY, Boolean.parseBoolean(value));
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   369
                return true;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   370
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   371
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   372
            value = SecuritySupport.readJAXPProperty(sysPropertyName);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   373
            if (value != null && !value.equals("")) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   374
                setFeature(feature, State.JAXPDOTPROPERTIES, Boolean.parseBoolean(value));
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   375
                return true;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   376
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   377
        } catch (NumberFormatException e) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   378
            //invalid setting
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   379
            throw new NumberFormatException("Invalid setting for system property: " + feature.systemProperty());
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   380
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   381
        return false;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   382
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   383
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents:
diff changeset
   384
}