author | lana |
Tue, 18 Mar 2014 17:49:48 -0700 | |
changeset 23377 | 2af1ddf102a4 |
parent 22418 | 1ee8fd0184d1 |
child 25264 | 040625ce9b72 |
permissions | -rw-r--r-- |
12458 | 1 |
/* |
22139
f4b2aa462b46
8029236: Update copyright year to match last edit in jdk8 jaxp repository for 2013
joehw
parents:
21467
diff
changeset
|
2 |
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
12458 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.org.apache.xalan.internal; |
|
27 |
||
17534 | 28 |
import com.sun.org.apache.xalan.internal.utils.SecuritySupport; |
12458 | 29 |
|
30 |
/** |
|
31 |
* Commonly used constants. |
|
32 |
* |
|
33 |
* @author Huizhe Wang, Oracle |
|
34 |
* |
|
35 |
* @version $Id: Constants.java,v 1.14 2011-06-07 04:39:40 joehw Exp $ |
|
36 |
*/ |
|
37 |
public final class XalanConstants { |
|
38 |
||
39 |
// |
|
40 |
// Constants |
|
41 |
// |
|
20968 | 42 |
//Xerces security manager |
43 |
public static final String SECURITY_MANAGER = |
|
44 |
"http://apache.org/xml/properties/security-manager"; |
|
45 |
||
46 |
// |
|
47 |
// Implementation limits: API properties |
|
48 |
// |
|
49 |
/** Oracle JAXP property prefix ("http://www.oracle.com/xml/jaxp/properties/"). */ |
|
50 |
public static final String ORACLE_JAXP_PROPERTY_PREFIX = |
|
51 |
"http://www.oracle.com/xml/jaxp/properties/"; |
|
52 |
/** |
|
53 |
* JDK entity expansion limit; Note that the existing system property |
|
54 |
* "entityExpansionLimit" with no prefix is still observed |
|
55 |
*/ |
|
56 |
public static final String JDK_ENTITY_EXPANSION_LIMIT = |
|
57 |
ORACLE_JAXP_PROPERTY_PREFIX + "entityExpansionLimit"; |
|
58 |
||
59 |
/** |
|
60 |
* JDK element attribute limit; Note that the existing system property |
|
61 |
* "elementAttributeLimit" with no prefix is still observed |
|
62 |
*/ |
|
63 |
public static final String JDK_ELEMENT_ATTRIBUTE_LIMIT = |
|
64 |
ORACLE_JAXP_PROPERTY_PREFIX + "elementAttributeLimit"; |
|
65 |
||
66 |
/** |
|
67 |
* JDK maxOccur limit; Note that the existing system property |
|
68 |
* "maxOccurLimit" with no prefix is still observed |
|
69 |
*/ |
|
70 |
public static final String JDK_MAX_OCCUR_LIMIT = |
|
71 |
ORACLE_JAXP_PROPERTY_PREFIX + "maxOccurLimit"; |
|
72 |
||
73 |
/** |
|
74 |
* JDK total entity size limit |
|
75 |
*/ |
|
76 |
public static final String JDK_TOTAL_ENTITY_SIZE_LIMIT = |
|
77 |
ORACLE_JAXP_PROPERTY_PREFIX + "totalEntitySizeLimit"; |
|
78 |
||
79 |
/** |
|
80 |
* JDK maximum general entity size limit |
|
81 |
*/ |
|
22418
1ee8fd0184d1
8028111: XML readers share the same entity expansion counter
joehw
parents:
22139
diff
changeset
|
82 |
public static final String JDK_GENERAL_ENTITY_SIZE_LIMIT = |
20968 | 83 |
ORACLE_JAXP_PROPERTY_PREFIX + "maxGeneralEntitySizeLimit"; |
84 |
/** |
|
85 |
* JDK maximum parameter entity size limit |
|
86 |
*/ |
|
87 |
public static final String JDK_PARAMETER_ENTITY_SIZE_LIMIT = |
|
88 |
ORACLE_JAXP_PROPERTY_PREFIX + "maxParameterEntitySizeLimit"; |
|
89 |
/** |
|
90 |
* JDK maximum XML name limit |
|
91 |
*/ |
|
92 |
public static final String JDK_XML_NAME_LIMIT = |
|
93 |
ORACLE_JAXP_PROPERTY_PREFIX + "maxXMLNameLimit"; |
|
94 |
/** |
|
95 |
* JDK property indicating whether the parser shall print out entity |
|
96 |
* count information |
|
97 |
* Value: a string "yes" means print, "no" or any other string means not. |
|
98 |
*/ |
|
99 |
public static final String JDK_ENTITY_COUNT_INFO = |
|
100 |
ORACLE_JAXP_PROPERTY_PREFIX + "getEntityCountInfo"; |
|
101 |
||
102 |
// |
|
103 |
// Implementation limits: corresponding System Properties of the above |
|
104 |
// API properties |
|
105 |
// |
|
106 |
/** |
|
107 |
* JDK entity expansion limit; Note that the existing system property |
|
108 |
* "entityExpansionLimit" with no prefix is still observed |
|
109 |
*/ |
|
110 |
public static final String SP_ENTITY_EXPANSION_LIMIT = "jdk.xml.entityExpansionLimit"; |
|
111 |
||
112 |
/** |
|
113 |
* JDK element attribute limit; Note that the existing system property |
|
114 |
* "elementAttributeLimit" with no prefix is still observed |
|
115 |
*/ |
|
116 |
public static final String SP_ELEMENT_ATTRIBUTE_LIMIT = "jdk.xml.elementAttributeLimit"; |
|
117 |
||
118 |
/** |
|
119 |
* JDK maxOccur limit; Note that the existing system property |
|
120 |
* "maxOccurLimit" with no prefix is still observed |
|
121 |
*/ |
|
122 |
public static final String SP_MAX_OCCUR_LIMIT = "jdk.xml.maxOccurLimit"; |
|
123 |
||
124 |
/** |
|
125 |
* JDK total entity size limit |
|
126 |
*/ |
|
127 |
public static final String SP_TOTAL_ENTITY_SIZE_LIMIT = "jdk.xml.totalEntitySizeLimit"; |
|
128 |
||
129 |
/** |
|
130 |
* JDK maximum general entity size limit |
|
131 |
*/ |
|
22418
1ee8fd0184d1
8028111: XML readers share the same entity expansion counter
joehw
parents:
22139
diff
changeset
|
132 |
public static final String SP_GENERAL_ENTITY_SIZE_LIMIT = "jdk.xml.maxGeneralEntitySizeLimit"; |
20968 | 133 |
/** |
134 |
* JDK maximum parameter entity size limit |
|
135 |
*/ |
|
136 |
public static final String SP_PARAMETER_ENTITY_SIZE_LIMIT = "jdk.xml.maxParameterEntitySizeLimit"; |
|
137 |
/** |
|
138 |
* JDK maximum XML name limit |
|
139 |
*/ |
|
140 |
public static final String SP_XML_NAME_LIMIT = "jdk.xml.maxXMLNameLimit"; |
|
141 |
||
142 |
//legacy System Properties |
|
143 |
public final static String ENTITY_EXPANSION_LIMIT = "entityExpansionLimit"; |
|
144 |
public static final String ELEMENT_ATTRIBUTE_LIMIT = "elementAttributeLimit" ; |
|
145 |
public final static String MAX_OCCUR_LIMIT = "maxOccurLimit"; |
|
146 |
||
147 |
/** |
|
148 |
* A string "yes" that can be used for properties such as getEntityCountInfo |
|
149 |
*/ |
|
150 |
public static final String JDK_YES = "yes"; |
|
151 |
||
12458 | 152 |
// Oracle Feature: |
17534 | 153 |
/** |
154 |
* <p>Use Service Mechanism</p> |
|
155 |
* |
|
156 |
* <ul> |
|
157 |
* <li> |
|
158 |
* {@code true} instruct an object to use service mechanism to |
|
159 |
* find a service implementation. This is the default behavior. |
|
12458 | 160 |
* </li> |
161 |
* <li> |
|
17534 | 162 |
* {@code false} instruct an object to skip service mechanism and |
163 |
* use the default implementation for that service. |
|
20968 | 164 |
* </li> |
165 |
* </ul> |
|
166 |
*/ |
|
12458 | 167 |
public static final String ORACLE_FEATURE_SERVICE_MECHANISM = "http://www.oracle.com/feature/use-service-mechanism"; |
168 |
||
17534 | 169 |
|
170 |
//System Properties corresponding to ACCESS_EXTERNAL_* properties |
|
171 |
public static final String SP_ACCESS_EXTERNAL_STYLESHEET = "javax.xml.accessExternalStylesheet"; |
|
172 |
public static final String SP_ACCESS_EXTERNAL_DTD = "javax.xml.accessExternalDTD"; |
|
173 |
||
174 |
//all access keyword |
|
175 |
public static final String ACCESS_EXTERNAL_ALL = "all"; |
|
176 |
||
177 |
/** |
|
178 |
* Default value when FEATURE_SECURE_PROCESSING (FSP) is set to true |
|
179 |
*/ |
|
180 |
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
|
181 |
|
17534 | 182 |
/** |
183 |
* FEATURE_SECURE_PROCESSING (FSP) is false by default |
|
184 |
*/ |
|
17991
4a8c5120a8d4
8015630: Remove default restriction settings of jaxp 1.5 properties in JDK8
joehw
parents:
17534
diff
changeset
|
185 |
public static final String EXTERNAL_ACCESS_DEFAULT = ACCESS_EXTERNAL_ALL; |
17534 | 186 |
|
18890
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
187 |
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
|
188 |
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
|
189 |
|
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
190 |
/** |
21467
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
191 |
* Feature enableExtensionFunctions |
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
192 |
*/ |
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
193 |
public static final String ORACLE_ENABLE_EXTENSION_FUNCTION = |
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
194 |
ORACLE_JAXP_PROPERTY_PREFIX + "enableExtensionFunctions"; |
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
195 |
public static final String SP_ORACLE_ENABLE_EXTENSION_FUNCTION = "javax.xml.enableExtensionFunctions"; |
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
196 |
|
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
197 |
/** |
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
198 |
* Values for a feature |
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
199 |
*/ |
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
200 |
public static final String FEATURE_TRUE = "true"; |
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
201 |
public static final String FEATURE_FALSE = "false"; |
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
202 |
|
ed77f0ff062c
8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents:
20968
diff
changeset
|
203 |
/** |
18890
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
204 |
* 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
|
205 |
*/ |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
206 |
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
|
207 |
|
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
208 |
/* |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
209 |
* 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
|
210 |
* parameter |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
211 |
* |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
212 |
* 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
|
213 |
* 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
|
214 |
* 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
|
215 |
* |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
216 |
* @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
|
217 |
* @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
|
218 |
* by the parameter |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
219 |
*/ |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
220 |
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
|
221 |
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
|
222 |
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
|
223 |
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
|
224 |
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
|
225 |
return true; |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
226 |
} |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
227 |
return false; |
25bdeca3173b
8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents:
17991
diff
changeset
|
228 |
} |
12458 | 229 |
} // class Constants |