Skip to content

Commit dde48ae

Browse files
Aleksei Voitylovgnu-andrew
authored andcommitted
8356294: Enhance Path Factories
Reviewed-by: abakhtin, fferrari, andrew Backport-of: 2c7f45612d11199a9d5eaa6d61a2893ec4afa687
1 parent 3273033 commit dde48ae

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ public void setFeature(String name, boolean value)
187187
if (value && _featureManager != null) {
188188
_featureManager.setFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION,
189189
JdkXmlFeatures.State.FSP, false);
190+
_xmlSecMgr.setSecureProcessing(value);
190191
}
191192

192193
// all done processing feature

jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package com.sun.org.apache.xpath.internal.jaxp;
2222

23+
import javax.xml.XMLConstants;
2324
import javax.xml.namespace.QName;
2425
import javax.xml.namespace.NamespaceContext;
2526
import javax.xml.xpath.XPathExpressionException;
@@ -180,6 +181,10 @@ private DocumentBuilder getParser() {
180181
// so we really have to create a fresh DocumentBuilder every time we need one
181182
// - KK
182183
DocumentBuilderFactory dbf = JdkXmlUtils.getDOMFactory(overrideDefaultParser);
184+
if (xmlSecMgr != null && xmlSecMgr.isSecureProcessingSet()) {
185+
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
186+
xmlSecMgr.isSecureProcessing());
187+
}
183188
return dbf.newDocumentBuilder();
184189
} catch (ParserConfigurationException e) {
185190
// this should never happen with a well-behaving JAXP implementation.

jaxp/src/jdk/xml/internal/XMLSecurityManager.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ public static enum Processor {
189189
*/
190190
boolean secureProcessing;
191191

192+
/**
193+
* Flag indicating the secure processing is set explicitly through factories'
194+
* setFeature method and then the setSecureProcessing method
195+
*/
196+
boolean secureProcessingSet;
197+
192198
/**
193199
* States that determine if properties are set explicitly
194200
*/
@@ -236,6 +242,7 @@ public XMLSecurityManager(boolean secureProcessing) {
236242
* Setting FEATURE_SECURE_PROCESSING explicitly
237243
*/
238244
public void setSecureProcessing(boolean secure) {
245+
secureProcessingSet = true;
239246
secureProcessing = secure;
240247
for (Limit limit : Limit.values()) {
241248
if (secure) {
@@ -254,6 +261,15 @@ public boolean isSecureProcessing() {
254261
return secureProcessing;
255262
}
256263

264+
/**
265+
* Returns the state indicating whether the Secure Processing is set explicitly,
266+
* via factories' setFeature and then this class' setSecureProcessing method.
267+
* @return the state indicating whether the Secure Processing is set explicitly
268+
*/
269+
public boolean isSecureProcessingSet() {
270+
return secureProcessingSet;
271+
}
272+
257273
/**
258274
* Set limit by property name and state
259275
* @param propertyName property name

0 commit comments

Comments
 (0)