jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java
author joehw
Tue, 09 Jul 2013 16:34:52 -0700
changeset 18890 25bdeca3173b
parent 17991 4a8c5120a8d4
child 20968 dde41f8b7b96
permissions -rw-r--r--
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown Summary: jaxp 1.5 feature update Reviewed-by: alanb, dfuchs, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     1
/*
14864
ede328b35431 8004982: JDK8 source with GPL header errors
katleman
parents: 12458
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     4
 *
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    10
 *
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    15
 * accompanied this code).
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    16
 *
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    20
 *
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    23
 * questions.
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    24
 */
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    25
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    26
package com.sun.org.apache.xalan.internal;
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    27
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    28
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    29
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    30
/**
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    31
 * Commonly used constants.
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    32
 *
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    33
 * @author Huizhe Wang, Oracle
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    34
 *
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    35
 * @version $Id: Constants.java,v 1.14 2011-06-07 04:39:40 joehw Exp $
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    36
 */
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    37
public final class XalanConstants {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    38
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    39
    //
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    40
    // Constants
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    41
    //
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    42
    // Oracle Feature:
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    43
    /**
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    44
     * <p>Use Service Mechanism</p>
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    45
     *
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    46
     * <ul>
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    47
     *   <li>
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    48
         * {@code true} instruct an object to use service mechanism to
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    49
         * find a service implementation. This is the default behavior.
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    50
         *   </li>
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    51
         *   <li>
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    52
         * {@code false} instruct an object to skip service mechanism and
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    53
         * use the default implementation for that service.
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    54
     *   </li>
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    55
     * </ul>
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    56
    */
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    57
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    58
    public static final String ORACLE_FEATURE_SERVICE_MECHANISM = "http://www.oracle.com/feature/use-service-mechanism";
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    59
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    60
    /** Oracle JAXP property prefix ("http://www.oracle.com/xml/jaxp/properties/"). */
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    61
    public static final String ORACLE_JAXP_PROPERTY_PREFIX =
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    62
        "http://www.oracle.com/xml/jaxp/properties/";
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    63
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    64
    //System Properties corresponding to ACCESS_EXTERNAL_* properties
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    65
    public static final String SP_ACCESS_EXTERNAL_STYLESHEET = "javax.xml.accessExternalStylesheet";
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    66
    public static final String SP_ACCESS_EXTERNAL_DTD = "javax.xml.accessExternalDTD";
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    67
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    68
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    69
    //all access keyword
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    70
    public static final String ACCESS_EXTERNAL_ALL = "all";
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    71
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    72
    /**
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    73
     * Default value when FEATURE_SECURE_PROCESSING (FSP) is set to true
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    74
     */
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    75
    public static final String EXTERNAL_ACCESS_DEFAULT_FSP = "";
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    76
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    77
    /**
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    78
     * FEATURE_SECURE_PROCESSING (FSP) is false by default
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    79
     */
17991
4a8c5120a8d4 8015630: Remove default restriction settings of jaxp 1.5 properties in JDK8
joehw
parents: 17534
diff changeset
    80
    public static final String EXTERNAL_ACCESS_DEFAULT = ACCESS_EXTERNAL_ALL;
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 14864
diff changeset
    81
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    82
    public static final String XML_SECURITY_PROPERTY_MANAGER =
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    83
            ORACLE_JAXP_PROPERTY_PREFIX + "xmlSecurityPropertyManager";
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    84
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    85
    /**
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    86
     * Check if we're in jdk8 or above
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    87
     */
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    88
    public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8);
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    89
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    90
    /*
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    91
     * Check the version of the current JDK against that specified in the
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    92
     * parameter
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    93
     *
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    94
     * There is a proposal to change the java version string to:
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    95
     * MAJOR.MINOR.FU.CPU.PSU-BUILDNUMBER_BUGIDNUMBER_OPTIONAL
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    96
     * This method would work with both the current format and that proposed
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    97
     *
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    98
     * @param compareTo a JDK version to be compared to
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
    99
     * @return true if the current version is the same or above that represented
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
   100
     * by the parameter
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
   101
     */
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
   102
    public static boolean isJavaVersionAtLeast(int compareTo) {
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
   103
        String javaVersion = SecuritySupport.getSystemProperty("java.version");
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
   104
        String versions[] = javaVersion.split("\\.", 3);
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
   105
        if (Integer.parseInt(versions[0]) >= compareTo ||
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
   106
            Integer.parseInt(versions[1]) >= compareTo) {
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
   107
            return true;
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
   108
        }
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
   109
        return false;
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17991
diff changeset
   110
    }
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
   111
} // class Constants