mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 03:54:33 +02:00
8132091: Clean up JAXP code that has dependency on Java version string
Reviewed-by: lancea
This commit is contained in:
parent
7ce24de93e
commit
60e4fa0770
7 changed files with 16 additions and 71 deletions
|
@ -221,27 +221,4 @@ public final class XalanConstants {
|
||||||
public static final String FEATURE_TRUE = "true";
|
public static final String FEATURE_TRUE = "true";
|
||||||
public static final String FEATURE_FALSE = "false";
|
public static final String FEATURE_FALSE = "false";
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if we're in jdk8 or above
|
|
||||||
*/
|
|
||||||
public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check the major version of the current JDK against that specified
|
|
||||||
* in the parameter
|
|
||||||
*
|
|
||||||
* In JDK9 the java version string was changed to comply with JEP-223
|
|
||||||
* so this method was modified to handle that new format as well
|
|
||||||
*
|
|
||||||
* @param compareTo a JDK major version to be compared to
|
|
||||||
* @return true if the current major version is the same or above
|
|
||||||
* that represented by the parameter
|
|
||||||
*/
|
|
||||||
public static boolean isJavaVersionAtLeast(int compareTo) {
|
|
||||||
String javaVersion = SecuritySupport.getSystemProperty("java.version");
|
|
||||||
javaVersion = (javaVersion.matches("[1-9][0-9]*(\\.(0|[1-9][0-9]*))*\\-.*")) ?
|
|
||||||
javaVersion.split("-|\\.")[0] :
|
|
||||||
javaVersion.split("\\.", 3)[1];
|
|
||||||
return Integer.parseInt(javaVersion) >= compareTo;
|
|
||||||
}
|
|
||||||
} // class Constants
|
} // class Constants
|
||||||
|
|
|
@ -524,7 +524,7 @@ public class TransformerFactoryImpl
|
||||||
_xmlSecurityManager.setSecureProcessing(value);
|
_xmlSecurityManager.setSecureProcessing(value);
|
||||||
|
|
||||||
// set external access restriction when FSP is explicitly set
|
// set external access restriction when FSP is explicitly set
|
||||||
if (value && XalanConstants.IS_JDK8_OR_ABOVE) {
|
if (value) {
|
||||||
_xmlSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_DTD,
|
_xmlSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_DTD,
|
||||||
State.FSP, XalanConstants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
State.FSP, XalanConstants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
||||||
_xmlSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_STYLESHEET,
|
_xmlSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_STYLESHEET,
|
||||||
|
@ -539,7 +539,6 @@ public class TransformerFactoryImpl
|
||||||
_featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION,
|
_featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION,
|
||||||
FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE);
|
FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if (name.equals(XalanConstants.ORACLE_FEATURE_SERVICE_MECHANISM)) {
|
else if (name.equals(XalanConstants.ORACLE_FEATURE_SERVICE_MECHANISM)) {
|
||||||
//in secure mode, let _useServicesMechanism be determined by the constructor
|
//in secure mode, let _useServicesMechanism be determined by the constructor
|
||||||
|
|
|
@ -203,11 +203,6 @@ public final class Constants {
|
||||||
*/
|
*/
|
||||||
public static final String EXTERNAL_ACCESS_DEFAULT = ACCESS_EXTERNAL_ALL;
|
public static final String EXTERNAL_ACCESS_DEFAULT = ACCESS_EXTERNAL_ALL;
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if we're in jdk8 or above
|
|
||||||
*/
|
|
||||||
public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Implementation limits: corresponding System Properties of the above
|
// Implementation limits: corresponding System Properties of the above
|
||||||
// API properties
|
// API properties
|
||||||
|
@ -856,25 +851,6 @@ public final class Constants {
|
||||||
? new ArrayEnumeration(fgXercesProperties) : fgEmptyEnumeration;
|
? new ArrayEnumeration(fgXercesProperties) : fgEmptyEnumeration;
|
||||||
} // getXercesProperties():Enumeration
|
} // getXercesProperties():Enumeration
|
||||||
|
|
||||||
/*
|
|
||||||
* Check the major version of the current JDK against that specified
|
|
||||||
* in the parameter
|
|
||||||
*
|
|
||||||
* In JDK9 the java version string was changed to comply with JEP-223
|
|
||||||
* so this method was modified to handle that new format as well
|
|
||||||
*
|
|
||||||
* @param compareTo a JDK major version to be compared to
|
|
||||||
* @return true if the current major version is the same or above
|
|
||||||
* that represented by the parameter
|
|
||||||
*/
|
|
||||||
public static boolean isJavaVersionAtLeast(int compareTo) {
|
|
||||||
String javaVersion = SecuritySupport.getSystemProperty("java.version");
|
|
||||||
javaVersion = (javaVersion.matches("[1-9][0-9]*(\\.(0|[1-9][0-9]*))*\\-.*")) ?
|
|
||||||
javaVersion.split("-|\\.")[0] :
|
|
||||||
javaVersion.split("\\.", 3)[1];
|
|
||||||
return Integer.parseInt(javaVersion) >= compareTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Classes
|
// Classes
|
||||||
//
|
//
|
||||||
|
|
|
@ -184,13 +184,11 @@ public class DocumentBuilderImpl extends DocumentBuilder
|
||||||
*/
|
*/
|
||||||
if (features != null) {
|
if (features != null) {
|
||||||
Boolean temp = features.get(XMLConstants.FEATURE_SECURE_PROCESSING);
|
Boolean temp = features.get(XMLConstants.FEATURE_SECURE_PROCESSING);
|
||||||
if (temp != null) {
|
if (temp != null && temp) {
|
||||||
if (temp && Constants.IS_JDK8_OR_ABOVE) {
|
fSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_DTD,
|
||||||
fSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_DTD,
|
State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
||||||
State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
fSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_SCHEMA,
|
||||||
fSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_SCHEMA,
|
State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
||||||
State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,14 +164,11 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
|
||||||
if (features != null) {
|
if (features != null) {
|
||||||
|
|
||||||
Boolean temp = features.get(XMLConstants.FEATURE_SECURE_PROCESSING);
|
Boolean temp = features.get(XMLConstants.FEATURE_SECURE_PROCESSING);
|
||||||
if (temp != null) {
|
if (temp != null && temp) {
|
||||||
if (temp && Constants.IS_JDK8_OR_ABOVE) {
|
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
|
||||||
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
|
XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
||||||
XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
|
||||||
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
|
XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
||||||
XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -427,12 +427,10 @@ public final class XMLSchemaFactory extends SchemaFactory {
|
||||||
|
|
||||||
fSecurityManager.setSecureProcessing(value);
|
fSecurityManager.setSecureProcessing(value);
|
||||||
if (value) {
|
if (value) {
|
||||||
if (Constants.IS_JDK8_OR_ABOVE) {
|
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
|
||||||
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
|
XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
||||||
XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
|
||||||
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
|
XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
||||||
XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
|
fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
|
||||||
|
|
|
@ -364,7 +364,7 @@ final class XMLSchemaValidatorComponentManager extends ParserConfigurationSettin
|
||||||
fInitSecurityManager.setSecureProcessing(value);
|
fInitSecurityManager.setSecureProcessing(value);
|
||||||
setProperty(SECURITY_MANAGER, fInitSecurityManager);
|
setProperty(SECURITY_MANAGER, fInitSecurityManager);
|
||||||
|
|
||||||
if (value && Constants.IS_JDK8_OR_ABOVE) {
|
if (value) {
|
||||||
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
|
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
|
||||||
XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
|
||||||
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
|
fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue