Thu, 31 Oct 2013 16:31:44 -0700
Merge
1.1 --- a/src/com/sun/org/apache/xalan/internal/XalanConstants.java Thu Oct 31 12:36:18 2013 -0700 1.2 +++ b/src/com/sun/org/apache/xalan/internal/XalanConstants.java Thu Oct 31 16:31:44 2013 -0700 1.3 @@ -188,6 +188,19 @@ 1.4 ORACLE_JAXP_PROPERTY_PREFIX + "xmlSecurityPropertyManager"; 1.5 1.6 /** 1.7 + * Feature enableExtensionFunctions 1.8 + */ 1.9 + public static final String ORACLE_ENABLE_EXTENSION_FUNCTION = 1.10 + ORACLE_JAXP_PROPERTY_PREFIX + "enableExtensionFunctions"; 1.11 + public static final String SP_ORACLE_ENABLE_EXTENSION_FUNCTION = "javax.xml.enableExtensionFunctions"; 1.12 + 1.13 + /** 1.14 + * Values for a feature 1.15 + */ 1.16 + public static final String FEATURE_TRUE = "true"; 1.17 + public static final String FEATURE_FALSE = "false"; 1.18 + 1.19 + /** 1.20 * Check if we're in jdk8 or above 1.21 */ 1.22 public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8);
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/src/com/sun/org/apache/xalan/internal/utils/FeatureManager.java Thu Oct 31 16:31:44 2013 -0700 2.3 @@ -0,0 +1,124 @@ 2.4 +/* 2.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. Oracle designates this 2.11 + * particular file as subject to the "Classpath" exception as provided 2.12 + * by Oracle in the LICENSE file that accompanied this code. 2.13 + * 2.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.17 + * version 2 for more details (a copy is included in the LICENSE file that 2.18 + * accompanied this code). 2.19 + * 2.20 + * You should have received a copy of the GNU General Public License version 2.21 + * 2 along with this work; if not, write to the Free Software Foundation, 2.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.23 + * 2.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.25 + * or visit www.oracle.com if you need additional information or have any 2.26 + * questions. 2.27 + */ 2.28 + 2.29 +package com.sun.org.apache.xalan.internal.utils; 2.30 + 2.31 + 2.32 +import com.sun.org.apache.xalan.internal.XalanConstants; 2.33 + 2.34 +/** 2.35 + * This class manages security related properties 2.36 + * 2.37 + */ 2.38 +public final class FeatureManager extends FeaturePropertyBase { 2.39 + 2.40 + /** 2.41 + * States of the settings of a property, in the order: default value, value 2.42 + * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system 2.43 + * properties, and jaxp api properties 2.44 + */ 2.45 + public static enum State { 2.46 + //this order reflects the overriding order 2.47 + DEFAULT, FSP, JAXPDOTPROPERTIES, SYSTEMPROPERTY, APIPROPERTY 2.48 + } 2.49 + 2.50 + /** 2.51 + * Xalan Features 2.52 + */ 2.53 + public static enum Feature { 2.54 + ORACLE_ENABLE_EXTENSION_FUNCTION(XalanConstants.ORACLE_ENABLE_EXTENSION_FUNCTION, 2.55 + "true"); 2.56 + 2.57 + final String name; 2.58 + final String defaultValue; 2.59 + 2.60 + Feature(String name, String value) { 2.61 + this.name = name; 2.62 + this.defaultValue = value; 2.63 + } 2.64 + 2.65 + public boolean equalsName(String propertyName) { 2.66 + return (propertyName == null) ? false : name.equals(propertyName); 2.67 + } 2.68 + 2.69 + String defaultValue() { 2.70 + return defaultValue; 2.71 + } 2.72 + } 2.73 + 2.74 + /** 2.75 + * Default constructor. Establishes default values 2.76 + */ 2.77 + public FeatureManager() { 2.78 + values = new String[Feature.values().length]; 2.79 + for (Feature feature : Feature.values()) { 2.80 + values[feature.ordinal()] = feature.defaultValue(); 2.81 + } 2.82 + //read system properties or jaxp.properties 2.83 + readSystemProperties(); 2.84 + } 2.85 + 2.86 + 2.87 + /** 2.88 + * Check if the feature is enabled 2.89 + * @param feature name of the feature 2.90 + * @return true if enabled, false otherwise 2.91 + */ 2.92 + public boolean isFeatureEnabled(Feature feature) { 2.93 + return Boolean.parseBoolean(values[feature.ordinal()]); 2.94 + } 2.95 + 2.96 + /** 2.97 + * Check if the feature is enabled 2.98 + * @param propertyName name of the feature 2.99 + * @return true if enabled, false otherwise 2.100 + */ 2.101 + public boolean isFeatureEnabled(String propertyName) { 2.102 + return Boolean.parseBoolean(values[getIndex(propertyName)]); 2.103 + } 2.104 + 2.105 + /** 2.106 + * Get the index by property name 2.107 + * @param propertyName property name 2.108 + * @return the index of the property if found; return -1 if not 2.109 + */ 2.110 + public int getIndex(String propertyName){ 2.111 + for (Feature feature : Feature.values()) { 2.112 + if (feature.equalsName(propertyName)) { 2.113 + return feature.ordinal(); 2.114 + } 2.115 + } 2.116 + return -1; 2.117 + } 2.118 + 2.119 + /** 2.120 + * Read from system properties, or those in jaxp.properties 2.121 + */ 2.122 + private void readSystemProperties() { 2.123 + getSystemProperty(Feature.ORACLE_ENABLE_EXTENSION_FUNCTION, 2.124 + XalanConstants.SP_ORACLE_ENABLE_EXTENSION_FUNCTION); 2.125 + } 2.126 + 2.127 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/src/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java Thu Oct 31 16:31:44 2013 -0700 3.3 @@ -0,0 +1,215 @@ 3.4 +/* 3.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. Oracle designates this 3.11 + * particular file as subject to the "Classpath" exception as provided 3.12 + * by Oracle in the LICENSE file that accompanied this code. 3.13 + * 3.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.17 + * version 2 for more details (a copy is included in the LICENSE file that 3.18 + * accompanied this code). 3.19 + * 3.20 + * You should have received a copy of the GNU General Public License version 3.21 + * 2 along with this work; if not, write to the Free Software Foundation, 3.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.23 + * 3.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.25 + * or visit www.oracle.com if you need additional information or have any 3.26 + * questions. 3.27 + */ 3.28 + 3.29 +package com.sun.org.apache.xalan.internal.utils; 3.30 + 3.31 +import com.sun.org.apache.xalan.internal.XalanConstants; 3.32 + 3.33 +/** 3.34 + * This is the base class for features and properties 3.35 + * 3.36 + */ 3.37 +public abstract class FeaturePropertyBase { 3.38 + 3.39 + /** 3.40 + * States of the settings of a property, in the order: default value, value 3.41 + * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system 3.42 + * properties, and jaxp api properties 3.43 + */ 3.44 + public static enum State { 3.45 + //this order reflects the overriding order 3.46 + DEFAULT, FSP, JAXPDOTPROPERTIES, SYSTEMPROPERTY, APIPROPERTY 3.47 + } 3.48 + 3.49 + 3.50 + /** 3.51 + * Values of the properties as defined in enum Properties 3.52 + */ 3.53 + String[] values = null; 3.54 + /** 3.55 + * States of the settings for each property in Properties above 3.56 + */ 3.57 + State[] states = {State.DEFAULT, State.DEFAULT}; 3.58 + 3.59 + 3.60 + /** 3.61 + * Set the value for a specific property. 3.62 + * 3.63 + * @param property the property 3.64 + * @param state the state of the property 3.65 + * @param value the value of the property 3.66 + */ 3.67 + public void setValue(Enum property, State state, String value) { 3.68 + //only update if it shall override 3.69 + if (state.compareTo(states[property.ordinal()]) >= 0) { 3.70 + values[property.ordinal()] = value; 3.71 + states[property.ordinal()] = state; 3.72 + } 3.73 + } 3.74 + 3.75 + /** 3.76 + * Set the value of a property by its index 3.77 + * @param index the index of the property 3.78 + * @param state the state of the property 3.79 + * @param value the value of the property 3.80 + */ 3.81 + public void setValue(int index, State state, String value) { 3.82 + //only update if it shall override 3.83 + if (state.compareTo(states[index]) >= 0) { 3.84 + values[index] = value; 3.85 + states[index] = state; 3.86 + } 3.87 + } 3.88 + 3.89 + /** 3.90 + * Set value by property name and state 3.91 + * @param propertyName property name 3.92 + * @param state the state of the property 3.93 + * @param value the value of the property 3.94 + * @return true if the property is managed by the security property manager; 3.95 + * false if otherwise. 3.96 + */ 3.97 + public boolean setValue(String propertyName, State state, Object value) { 3.98 + int index = getIndex(propertyName); 3.99 + if (index > -1) { 3.100 + setValue(index, state, (String)value); 3.101 + return true; 3.102 + } 3.103 + return false; 3.104 + } 3.105 + 3.106 + /** 3.107 + * Set value by property name and state 3.108 + * @param propertyName property name 3.109 + * @param state the state of the property 3.110 + * @param value the value of the property 3.111 + * @return true if the property is managed by the security property manager; 3.112 + * false if otherwise. 3.113 + */ 3.114 + public boolean setValue(String propertyName, State state, boolean value) { 3.115 + int index = getIndex(propertyName); 3.116 + if (index > -1) { 3.117 + if (value) { 3.118 + setValue(index, state, XalanConstants.FEATURE_TRUE); 3.119 + } else { 3.120 + setValue(index, state, XalanConstants.FEATURE_FALSE); 3.121 + } 3.122 + return true; 3.123 + } 3.124 + return false; 3.125 + } 3.126 + 3.127 + /** 3.128 + * Return the value of the specified property 3.129 + * 3.130 + * @param property the property 3.131 + * @return the value of the property 3.132 + */ 3.133 + public String getValue(Enum property) { 3.134 + return values[property.ordinal()]; 3.135 + } 3.136 + 3.137 + /** 3.138 + * Return the value of the specified property 3.139 + * 3.140 + * @param property the property 3.141 + * @return the value of the property 3.142 + */ 3.143 + public String getValue(String property) { 3.144 + int index = getIndex(property); 3.145 + if (index > -1) { 3.146 + return getValueByIndex(index); 3.147 + } 3.148 + return null; 3.149 + } 3.150 + 3.151 + /** 3.152 + * Return the value of the specified property. 3.153 + * 3.154 + * @param propertyName the property name 3.155 + * @return the value of the property as a string. If a property is managed 3.156 + * by this manager, its value shall not be null. 3.157 + */ 3.158 + public String getValueAsString(String propertyName) { 3.159 + int index = getIndex(propertyName); 3.160 + if (index > -1) { 3.161 + return getValueByIndex(index); 3.162 + } 3.163 + 3.164 + return null; 3.165 + } 3.166 + 3.167 + /** 3.168 + * Return the value of a property by its ordinal 3.169 + * @param index the index of a property 3.170 + * @return value of a property 3.171 + */ 3.172 + public String getValueByIndex(int index) { 3.173 + return values[index]; 3.174 + } 3.175 + 3.176 + /** 3.177 + * Get the index by property name 3.178 + * @param propertyName property name 3.179 + * @return the index of the property if found; return -1 if not 3.180 + */ 3.181 + public abstract int getIndex(String propertyName); 3.182 + 3.183 + public <E extends Enum<E>> int getIndex(Class<E> property, String propertyName) { 3.184 + for (Enum<E> enumItem : property.getEnumConstants()) { 3.185 + if (enumItem.toString().equals(propertyName)) { 3.186 + //internally, ordinal is used as index 3.187 + return enumItem.ordinal(); 3.188 + } 3.189 + } 3.190 + return -1; 3.191 + }; 3.192 + 3.193 + 3.194 + /** 3.195 + * Read from system properties, or those in jaxp.properties 3.196 + * 3.197 + * @param property the property 3.198 + * @param systemProperty the name of the system property 3.199 + */ 3.200 + void getSystemProperty(Enum property, String systemProperty) { 3.201 + try { 3.202 + String value = SecuritySupport.getSystemProperty(systemProperty); 3.203 + if (value != null) { 3.204 + values[property.ordinal()] = value; 3.205 + states[property.ordinal()] = State.SYSTEMPROPERTY; 3.206 + return; 3.207 + } 3.208 + 3.209 + value = SecuritySupport.readJAXPProperty(systemProperty); 3.210 + if (value != null) { 3.211 + values[property.ordinal()] = value; 3.212 + states[property.ordinal()] = State.JAXPDOTPROPERTIES; 3.213 + } 3.214 + } catch (NumberFormatException e) { 3.215 + //invalid setting ignored 3.216 + } 3.217 + } 3.218 +}
4.1 --- a/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java Thu Oct 31 12:36:18 2013 -0700 4.2 +++ b/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java Thu Oct 31 16:31:44 2013 -0700 4.3 @@ -1,42 +1,28 @@ 4.4 /* 4.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 4.6 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 4.7 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 4.10 + * This code is free software; you can redistribute it and/or modify it 4.11 + * under the terms of the GNU General Public License version 2 only, as 4.12 + * published by the Free Software Foundation. Oracle designates this 4.13 + * particular file as subject to the "Classpath" exception as provided 4.14 + * by Oracle in the LICENSE file that accompanied this code. 4.15 * 4.16 - * The contents of this file are subject to the terms of either the GNU 4.17 - * General Public License Version 2 only ("GPL") or the Common Development 4.18 - * and Distribution License("CDDL") (collectively, the "License"). You 4.19 - * may not use this file except in compliance with the License. You can 4.20 - * obtain a copy of the License at 4.21 - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 4.22 - * or packager/legal/LICENSE.txt. See the License for the specific 4.23 - * language governing permissions and limitations under the License. 4.24 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.25 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.26 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.27 + * version 2 for more details (a copy is included in the LICENSE file that 4.28 + * accompanied this code). 4.29 * 4.30 - * When distributing the software, include this License Header Notice in each 4.31 - * file and include the License file at packager/legal/LICENSE.txt. 4.32 + * You should have received a copy of the GNU General Public License version 4.33 + * 2 along with this work; if not, write to the Free Software Foundation, 4.34 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.35 * 4.36 - * GPL Classpath Exception: 4.37 - * Oracle designates this particular file as subject to the "Classpath" 4.38 - * exception as provided by Oracle in the GPL Version 2 section of the License 4.39 - * file that accompanied this code. 4.40 - * 4.41 - * Modifications: 4.42 - * If applicable, add the following below the License Header, with the fields 4.43 - * enclosed by brackets [] replaced by your own identifying information: 4.44 - * "Portions Copyright [year] [name of copyright owner]" 4.45 - * 4.46 - * Contributor(s): 4.47 - * If you wish your version of this file to be governed by only the CDDL or 4.48 - * only the GPL Version 2, indicate your decision by adding "[Contributor] 4.49 - * elects to include this software in this distribution under the [CDDL or GPL 4.50 - * Version 2] license." If you don't indicate a single choice of license, a 4.51 - * recipient has the option to distribute your version of this file under 4.52 - * either the CDDL, the GPL Version 2 or to extend the choice of license to 4.53 - * its licensees as provided above. However, if you add GPL Version 2 code 4.54 - * and therefore, elected the GPL Version 2 license, then the option applies 4.55 - * only if the new code is made subject to such option by the copyright 4.56 - * holder. 4.57 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4.58 + * or visit www.oracle.com if you need additional information or have any 4.59 + * questions. 4.60 */ 4.61 + 4.62 package com.sun.org.apache.xalan.internal.utils; 4.63 4.64 import com.sun.org.apache.xalan.internal.XalanConstants;
5.1 --- a/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java Thu Oct 31 12:36:18 2013 -0700 5.2 +++ b/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java Thu Oct 31 16:31:44 2013 -0700 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -33,20 +33,10 @@ 5.11 * This class manages security related properties 5.12 * 5.13 */ 5.14 -public final class XMLSecurityPropertyManager { 5.15 +public final class XMLSecurityPropertyManager extends FeaturePropertyBase { 5.16 5.17 /** 5.18 - * States of the settings of a property, in the order: default value, value 5.19 - * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system 5.20 - * properties, and jaxp api properties 5.21 - */ 5.22 - public static enum State { 5.23 - //this order reflects the overriding order 5.24 - DEFAULT, FSP, JAXPDOTPROPERTIES, SYSTEMPROPERTY, APIPROPERTY 5.25 - } 5.26 - 5.27 - /** 5.28 - * Limits managed by the security manager 5.29 + * Properties managed by the security property manager 5.30 */ 5.31 public static enum Property { 5.32 ACCESS_EXTERNAL_DTD(XMLConstants.ACCESS_EXTERNAL_DTD, 5.33 @@ -73,15 +63,6 @@ 5.34 5.35 5.36 /** 5.37 - * Values of the properties as defined in enum Properties 5.38 - */ 5.39 - private final String[] values; 5.40 - /** 5.41 - * States of the settings for each property in Properties above 5.42 - */ 5.43 - private State[] states = {State.DEFAULT, State.DEFAULT}; 5.44 - 5.45 - /** 5.46 * Default constructor. Establishes default values 5.47 */ 5.48 public XMLSecurityPropertyManager() { 5.49 @@ -94,86 +75,6 @@ 5.50 } 5.51 5.52 /** 5.53 - * Set limit by property name and state 5.54 - * @param propertyName property name 5.55 - * @param state the state of the property 5.56 - * @param value the value of the property 5.57 - * @return true if the property is managed by the security property manager; 5.58 - * false if otherwise. 5.59 - */ 5.60 - public boolean setValue(String propertyName, State state, Object value) { 5.61 - int index = getIndex(propertyName); 5.62 - if (index > -1) { 5.63 - setValue(index, state, (String)value); 5.64 - return true; 5.65 - } 5.66 - return false; 5.67 - } 5.68 - 5.69 - /** 5.70 - * Set the value for a specific property. 5.71 - * 5.72 - * @param property the property 5.73 - * @param state the state of the property 5.74 - * @param value the value of the property 5.75 - */ 5.76 - public void setValue(Property property, State state, String value) { 5.77 - //only update if it shall override 5.78 - if (state.compareTo(states[property.ordinal()]) >= 0) { 5.79 - values[property.ordinal()] = value; 5.80 - states[property.ordinal()] = state; 5.81 - } 5.82 - } 5.83 - 5.84 - /** 5.85 - * Set the value of a property by its index 5.86 - * @param index the index of the property 5.87 - * @param state the state of the property 5.88 - * @param value the value of the property 5.89 - */ 5.90 - public void setValue(int index, State state, String value) { 5.91 - //only update if it shall override 5.92 - if (state.compareTo(states[index]) >= 0) { 5.93 - values[index] = value; 5.94 - states[index] = state; 5.95 - } 5.96 - } 5.97 - 5.98 - /** 5.99 - * Return the value of the specified property 5.100 - * 5.101 - * @param propertyName the property name 5.102 - * @return the value of the property as a string 5.103 - */ 5.104 - public String getValue(String propertyName) { 5.105 - int index = getIndex(propertyName); 5.106 - if (index > -1) { 5.107 - return getValueByIndex(index); 5.108 - } 5.109 - 5.110 - return null; 5.111 - } 5.112 - 5.113 - /** 5.114 - * Return the value of the specified property 5.115 - * 5.116 - * @param property the property 5.117 - * @return the value of the property 5.118 - */ 5.119 - public String getValue(Property property) { 5.120 - return values[property.ordinal()]; 5.121 - } 5.122 - 5.123 - /** 5.124 - * Return the value of a property by its ordinal 5.125 - * @param index the index of a property 5.126 - * @return value of a property 5.127 - */ 5.128 - public String getValueByIndex(int index) { 5.129 - return values[index]; 5.130 - } 5.131 - 5.132 - /** 5.133 * Get the index by property name 5.134 * @param propertyName property name 5.135 * @return the index of the property if found; return -1 if not 5.136 @@ -198,28 +99,4 @@ 5.137 XalanConstants.SP_ACCESS_EXTERNAL_STYLESHEET); 5.138 } 5.139 5.140 - /** 5.141 - * Read from system properties, or those in jaxp.properties 5.142 - * 5.143 - * @param property the property 5.144 - * @param systemProperty the name of the system property 5.145 - */ 5.146 - private void getSystemProperty(Property property, String systemProperty) { 5.147 - try { 5.148 - String value = SecuritySupport.getSystemProperty(systemProperty); 5.149 - if (value != null) { 5.150 - values[property.ordinal()] = value; 5.151 - states[property.ordinal()] = State.SYSTEMPROPERTY; 5.152 - return; 5.153 - } 5.154 - 5.155 - value = SecuritySupport.readJAXPProperty(systemProperty); 5.156 - if (value != null) { 5.157 - values[property.ordinal()] = value; 5.158 - states[property.ordinal()] = State.JAXPDOTPROPERTIES; 5.159 - } 5.160 - } catch (NumberFormatException e) { 5.161 - //invalid setting ignored 5.162 - } 5.163 - } 5.164 }
6.1 --- a/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Compile.java Thu Oct 31 12:36:18 2013 -0700 6.2 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Compile.java Thu Oct 31 16:31:44 2013 -0700 6.3 @@ -23,6 +23,7 @@ 6.4 6.5 package com.sun.org.apache.xalan.internal.xsltc.cmdline; 6.6 6.7 +import com.sun.org.apache.xalan.internal.utils.FeatureManager; 6.8 import java.io.File; 6.9 import java.net.URL; 6.10 import java.util.Vector; 6.11 @@ -77,7 +78,7 @@ 6.12 final GetOpt getopt = new GetOpt(args, "o:d:j:p:uxhsinv"); 6.13 if (args.length < 1) printUsage(); 6.14 6.15 - final XSLTC xsltc = new XSLTC(true); 6.16 + final XSLTC xsltc = new XSLTC(true, new FeatureManager()); 6.17 xsltc.init(); 6.18 6.19 int c;
7.1 --- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java Thu Oct 31 12:36:18 2013 -0700 7.2 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java Thu Oct 31 16:31:44 2013 -0700 7.3 @@ -42,6 +42,7 @@ 7.4 import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; 7.5 import com.sun.org.apache.bcel.internal.generic.NEW; 7.6 import com.sun.org.apache.bcel.internal.generic.PUSH; 7.7 +import com.sun.org.apache.xalan.internal.utils.FeatureManager; 7.8 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; 7.9 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; 7.10 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; 7.11 @@ -717,6 +718,8 @@ 7.12 final ConstantPoolGen cpg = classGen.getConstantPool(); 7.13 final InstructionList il = methodGen.getInstructionList(); 7.14 final boolean isSecureProcessing = classGen.getParser().getXSLTC().isSecureProcessing(); 7.15 + final boolean isExtensionFunctionEnabled = classGen.getParser().getXSLTC() 7.16 + .getFeature(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION); 7.17 int index; 7.18 7.19 // Translate calls to methods in the BasisLibrary 7.20 @@ -760,7 +763,7 @@ 7.21 il.append(new INVOKESTATIC(index)); 7.22 } 7.23 else if (_isExtConstructor) { 7.24 - if (isSecureProcessing) 7.25 + if (isSecureProcessing && !isExtensionFunctionEnabled) 7.26 translateUnallowedExtension(cpg, il); 7.27 7.28 final String clazz = 7.29 @@ -822,7 +825,7 @@ 7.30 } 7.31 // Invoke function calls that are handled in separate classes 7.32 else { 7.33 - if (isSecureProcessing) 7.34 + if (isSecureProcessing && !isExtensionFunctionEnabled) 7.35 translateUnallowedExtension(cpg, il); 7.36 7.37 final String clazz = _chosenMethod.getDeclaringClass().getName();
8.1 --- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java Thu Oct 31 12:36:18 2013 -0700 8.2 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java Thu Oct 31 16:31:44 2013 -0700 8.3 @@ -43,6 +43,8 @@ 8.4 8.5 import com.sun.org.apache.bcel.internal.classfile.JavaClass; 8.6 import com.sun.org.apache.xalan.internal.XalanConstants; 8.7 +import com.sun.org.apache.xalan.internal.utils.FeatureManager; 8.8 +import com.sun.org.apache.xalan.internal.utils.FeatureManager.Feature; 8.9 import com.sun.org.apache.xalan.internal.utils.SecuritySupport; 8.10 import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager; 8.11 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; 8.12 @@ -148,11 +150,14 @@ 8.13 8.14 private XMLSecurityManager _xmlSecurityManager; 8.15 8.16 + private final FeatureManager _featureManager; 8.17 + 8.18 /** 8.19 * XSLTC compiler constructor 8.20 */ 8.21 - public XSLTC(boolean useServicesMechanism) { 8.22 + public XSLTC(boolean useServicesMechanism, FeatureManager featureManager) { 8.23 _parser = new Parser(this, useServicesMechanism); 8.24 + _featureManager = featureManager; 8.25 } 8.26 8.27 /** 8.28 @@ -182,6 +187,15 @@ 8.29 _useServicesMechanism = flag; 8.30 } 8.31 8.32 + /** 8.33 + * Return the value of the specified feature 8.34 + * @param name name of the feature 8.35 + * @return true if the feature is enabled, false otherwise 8.36 + */ 8.37 + public boolean getFeature(Feature name) { 8.38 + return _featureManager.isFeatureEnabled(name); 8.39 + } 8.40 + 8.41 /** 8.42 * Return allowed protocols for accessing external stylesheet. 8.43 */
9.1 --- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2DOM.java Thu Oct 31 12:36:18 2013 -0700 9.2 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2DOM.java Thu Oct 31 16:31:44 2013 -0700 9.3 @@ -74,12 +74,12 @@ 9.4 DocumentBuilderFactory.newInstance(); 9.5 private boolean _internal = true; 9.6 9.7 - public SAX2DOM(boolean useServicesMachnism) throws ParserConfigurationException { 9.8 - _document = createDocument(useServicesMachnism); 9.9 + public SAX2DOM(boolean useServicesMechanism) throws ParserConfigurationException { 9.10 + _document = createDocument(useServicesMechanism); 9.11 _root = _document; 9.12 } 9.13 9.14 - public SAX2DOM(Node root, Node nextSibling, boolean useServicesMachnism) throws ParserConfigurationException { 9.15 + public SAX2DOM(Node root, Node nextSibling, boolean useServicesMechanism) throws ParserConfigurationException { 9.16 _root = root; 9.17 if (root instanceof Document) { 9.18 _document = (Document)root; 9.19 @@ -88,15 +88,15 @@ 9.20 _document = root.getOwnerDocument(); 9.21 } 9.22 else { 9.23 - _document = createDocument(useServicesMachnism); 9.24 + _document = createDocument(useServicesMechanism); 9.25 _root = _document; 9.26 } 9.27 9.28 _nextSibling = nextSibling; 9.29 } 9.30 9.31 - public SAX2DOM(Node root, boolean useServicesMachnism) throws ParserConfigurationException { 9.32 - this(root, null, useServicesMachnism); 9.33 + public SAX2DOM(Node root, boolean useServicesMechanism) throws ParserConfigurationException { 9.34 + this(root, null, useServicesMechanism); 9.35 } 9.36 9.37 public Node getDOM() { 9.38 @@ -308,18 +308,19 @@ 9.39 public void startDTD(String name, String publicId, String systemId) 9.40 throws SAXException {} 9.41 9.42 - private Document createDocument(boolean useServicesMachnism) throws ParserConfigurationException { 9.43 + private Document createDocument(boolean useServicesMechanism) throws ParserConfigurationException { 9.44 if (_factory == null) { 9.45 - if (useServicesMachnism) 9.46 + if (useServicesMechanism) { 9.47 _factory = DocumentBuilderFactory.newInstance(); 9.48 if (!(_factory instanceof com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl)) { 9.49 _internal = false; 9.50 } 9.51 - else 9.52 + } else { 9.53 _factory = DocumentBuilderFactory.newInstance( 9.54 "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", 9.55 SAX2DOM.class.getClassLoader() 9.56 ); 9.57 + } 9.58 } 9.59 Document doc; 9.60 if (_internal) {
10.1 --- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java Thu Oct 31 12:36:18 2013 -0700 10.2 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java Thu Oct 31 16:31:44 2013 -0700 10.3 @@ -95,7 +95,7 @@ 10.4 _tfactory = tfactory; 10.5 10.6 // Instantiate XSLTC and get reference to parser object 10.7 - XSLTC xsltc = new XSLTC(tfactory.useServicesMechnism()); 10.8 + XSLTC xsltc = new XSLTC(tfactory.useServicesMechnism(), tfactory.getFeatureManager()); 10.9 if (tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) 10.10 xsltc.setSecureProcessing(true); 10.11
11.1 --- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Thu Oct 31 12:36:18 2013 -0700 11.2 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Thu Oct 31 16:31:44 2013 -0700 11.3 @@ -25,12 +25,14 @@ 11.4 11.5 import com.sun.org.apache.xalan.internal.XalanConstants; 11.6 import com.sun.org.apache.xalan.internal.utils.FactoryImpl; 11.7 +import com.sun.org.apache.xalan.internal.utils.FeatureManager; 11.8 +import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase; 11.9 import com.sun.org.apache.xalan.internal.utils.ObjectFactory; 11.10 import com.sun.org.apache.xalan.internal.utils.SecuritySupport; 11.11 import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager; 11.12 import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager; 11.13 import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager.Property; 11.14 -import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager.State; 11.15 +import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase.State; 11.16 import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants; 11.17 import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader; 11.18 import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC; 11.19 @@ -227,6 +229,8 @@ 11.20 private XMLSecurityPropertyManager _xmlSecurityPropertyMgr; 11.21 private XMLSecurityManager _xmlSecurityManager; 11.22 11.23 + private final FeatureManager _featureManager; 11.24 + 11.25 /** 11.26 * javax.xml.transform.sax.TransformerFactory implementation. 11.27 */ 11.28 @@ -240,10 +244,13 @@ 11.29 11.30 private TransformerFactoryImpl(boolean useServicesMechanism) { 11.31 this._useServicesMechanism = useServicesMechanism; 11.32 + _featureManager = new FeatureManager(); 11.33 11.34 if (System.getSecurityManager() != null) { 11.35 _isSecureMode = true; 11.36 _isNotSecureProcessing = false; 11.37 + _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION, 11.38 + FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE); 11.39 } 11.40 11.41 _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager(); 11.42 @@ -504,6 +511,10 @@ 11.43 Property.ACCESS_EXTERNAL_STYLESHEET); 11.44 } 11.45 11.46 + if (value && _featureManager != null) { 11.47 + _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION, 11.48 + FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE); 11.49 + } 11.50 return; 11.51 } 11.52 else if (name.equals(XalanConstants.ORACLE_FEATURE_SERVICE_MECHANISM)) { 11.53 @@ -512,6 +523,11 @@ 11.54 _useServicesMechanism = value; 11.55 } 11.56 else { 11.57 + if (_featureManager != null && 11.58 + _featureManager.setValue(name, State.APIPROPERTY, value)) { 11.59 + return; 11.60 + } 11.61 + 11.62 // unknown feature 11.63 ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNSUPPORTED_FEATURE, name); 11.64 throw new TransformerConfigurationException(err.toString()); 11.65 @@ -561,6 +577,13 @@ 11.66 return !_isNotSecureProcessing; 11.67 } 11.68 11.69 + /** Check to see if the property is managed by the security manager **/ 11.70 + String propertyValue = (_featureManager != null) ? 11.71 + _featureManager.getValueAsString(name) : null; 11.72 + if (propertyValue != null) { 11.73 + return Boolean.parseBoolean(propertyValue); 11.74 + } 11.75 + 11.76 // Feature not supported 11.77 return false; 11.78 } 11.79 @@ -571,6 +594,13 @@ 11.80 return _useServicesMechanism; 11.81 } 11.82 11.83 + /** 11.84 + * @return the feature manager 11.85 + */ 11.86 + public FeatureManager getFeatureManager() { 11.87 + return _featureManager; 11.88 + } 11.89 + 11.90 /** 11.91 * javax.xml.transform.sax.TransformerFactory implementation. 11.92 * Get the object that is used by default during the transformation to 11.93 @@ -857,7 +887,7 @@ 11.94 } 11.95 11.96 // Create and initialize a stylesheet compiler 11.97 - final XSLTC xsltc = new XSLTC(_useServicesMechanism); 11.98 + final XSLTC xsltc = new XSLTC(_useServicesMechanism, _featureManager); 11.99 if (_debug) xsltc.setDebug(true); 11.100 if (_enableInlining) 11.101 xsltc.setTemplateInlining(true);
12.1 --- a/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Thu Oct 31 12:36:18 2013 -0700 12.2 +++ b/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Thu Oct 31 16:31:44 2013 -0700 12.3 @@ -569,32 +569,13 @@ 12.4 12.5 // xerces features 12.6 fReportCdataEvent = componentManager.getFeature(Constants.STAX_REPORT_CDATA_EVENT, true); 12.7 - 12.8 fSecurityManager = (XMLSecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER, null); 12.9 - fLimitAnalyzer = fSecurityManager.getLimitAnalyzer(); 12.10 - 12.11 - fElementAttributeLimit = (fSecurityManager != null)? 12.12 - fSecurityManager.getLimit(XMLSecurityManager.Limit.ELEMENT_ATTRIBUTE_LIMIT):0; 12.13 - 12.14 fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS, false); 12.15 12.16 Object resolver = componentManager.getProperty(ENTITY_RESOLVER, null); 12.17 fExternalSubsetResolver = (resolver instanceof ExternalSubsetResolver) ? 12.18 (ExternalSubsetResolver) resolver : null; 12.19 12.20 - // initialize vars 12.21 - fMarkupDepth = 0; 12.22 - fCurrentElement = null; 12.23 - fElementStack.clear(); 12.24 - fHasExternalDTD = false; 12.25 - fStandaloneSet = false; 12.26 - fStandalone = false; 12.27 - fInScanContent = false; 12.28 - //skipping algorithm 12.29 - fShouldSkip = false; 12.30 - fAdd = false; 12.31 - fSkip = false; 12.32 - 12.33 //attribute 12.34 fReadingAttributes = false; 12.35 //xxx: external entities are supported in Xerces 12.36 @@ -606,9 +587,6 @@ 12.37 // setup Driver 12.38 setScannerState(SCANNER_STATE_CONTENT); 12.39 setDriver(fContentDriver); 12.40 - fEntityStore = fEntityManager.getEntityStore(); 12.41 - 12.42 - dtdGrammarUtil = null; 12.43 12.44 // JAXP 1.5 features and properties 12.45 XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager) 12.46 @@ -617,6 +595,7 @@ 12.47 12.48 fStrictURI = componentManager.getFeature(STANDARD_URI_CONFORMANT, false); 12.49 12.50 + resetCommon(); 12.51 //fEntityManager.test(); 12.52 } // reset(XMLComponentManager) 12.53 12.54 @@ -630,17 +609,7 @@ 12.55 fNamespaces = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue(); 12.56 fNotifyBuiltInRefs = false ; 12.57 12.58 - // initialize vars 12.59 - fMarkupDepth = 0; 12.60 - fCurrentElement = null; 12.61 - fShouldSkip = false; 12.62 - fAdd = false; 12.63 - fSkip = false; 12.64 - fElementStack.clear(); 12.65 //fElementStack2.clear(); 12.66 - fHasExternalDTD = false; 12.67 - fStandaloneSet = false; 12.68 - fStandalone = false; 12.69 //fReplaceEntityReferences = true; 12.70 //fSupportExternalEntities = true; 12.71 Boolean bo = (Boolean)propertyManager.getProperty(XMLInputFactoryImpl.IS_REPLACING_ENTITY_REFERENCES); 12.72 @@ -661,20 +630,43 @@ 12.73 //we dont need to do this -- nb. 12.74 //setScannerState(SCANNER_STATE_CONTENT); 12.75 //setDriver(fContentDriver); 12.76 - fEntityStore = fEntityManager.getEntityStore(); 12.77 //fEntityManager.test(); 12.78 12.79 - dtdGrammarUtil = null; 12.80 - 12.81 // JAXP 1.5 features and properties 12.82 XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager) 12.83 propertyManager.getProperty(XML_SECURITY_PROPERTY_MANAGER); 12.84 fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD); 12.85 12.86 fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(Constants.SECURITY_MANAGER); 12.87 - fLimitAnalyzer = fSecurityManager.getLimitAnalyzer(); 12.88 + resetCommon(); 12.89 } // reset(XMLComponentManager) 12.90 12.91 + void resetCommon() { 12.92 + // initialize vars 12.93 + fMarkupDepth = 0; 12.94 + fCurrentElement = null; 12.95 + fElementStack.clear(); 12.96 + fHasExternalDTD = false; 12.97 + fStandaloneSet = false; 12.98 + fStandalone = false; 12.99 + fInScanContent = false; 12.100 + //skipping algorithm 12.101 + fShouldSkip = false; 12.102 + fAdd = false; 12.103 + fSkip = false; 12.104 + 12.105 + fEntityStore = fEntityManager.getEntityStore(); 12.106 + dtdGrammarUtil = null; 12.107 + 12.108 + if (fSecurityManager != null) { 12.109 + fLimitAnalyzer = fSecurityManager.getLimitAnalyzer(); 12.110 + fElementAttributeLimit = fSecurityManager.getLimit(XMLSecurityManager.Limit.ELEMENT_ATTRIBUTE_LIMIT); 12.111 + } else { 12.112 + fLimitAnalyzer = null; 12.113 + fElementAttributeLimit = 0; 12.114 + } 12.115 + } 12.116 + 12.117 /** 12.118 * Returns a list of feature identifiers that are recognized by 12.119 * this component. This method may return null if no features 12.120 @@ -1328,7 +1320,7 @@ 12.121 fAttributes.getLength() > fElementAttributeLimit){ 12.122 fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, 12.123 "ElementAttributeLimit", 12.124 - new Object[]{rawname, new Integer(fAttributes.getLength()) }, 12.125 + new Object[]{rawname, fElementAttributeLimit }, 12.126 XMLErrorReporter.SEVERITY_FATAL_ERROR ); 12.127 } 12.128
13.1 --- a/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java Thu Oct 31 12:36:18 2013 -0700 13.2 +++ b/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java Thu Oct 31 16:31:44 2013 -0700 13.3 @@ -256,7 +256,7 @@ 13.4 fAttributes.getLength() > fElementAttributeLimit){ 13.5 fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, 13.6 "ElementAttributeLimit", 13.7 - new Object[]{rawname, new Integer(fAttributes.getLength()) }, 13.8 + new Object[]{rawname, fElementAttributeLimit }, 13.9 XMLErrorReporter.SEVERITY_FATAL_ERROR ); 13.10 } 13.11
14.1 --- a/src/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java Thu Oct 31 12:36:18 2013 -0700 14.2 +++ b/src/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java Thu Oct 31 16:31:44 2013 -0700 14.3 @@ -211,7 +211,7 @@ 14.4 if (i > 0) { 14.5 return uri.substring(i+1, uri.length()); 14.6 } 14.7 - return ""; 14.8 + return uri; 14.9 } 14.10 14.11 /**
15.1 --- a/src/com/sun/org/apache/xpath/internal/jaxp/JAXPExtensionsProvider.java Thu Oct 31 12:36:18 2013 -0700 15.2 +++ b/src/com/sun/org/apache/xpath/internal/jaxp/JAXPExtensionsProvider.java Thu Oct 31 16:31:44 2013 -0700 15.3 @@ -33,6 +33,7 @@ 15.4 import com.sun.org.apache.xpath.internal.objects.XNodeSet; 15.5 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; 15.6 import com.sun.org.apache.xalan.internal.res.XSLMessages; 15.7 +import com.sun.org.apache.xalan.internal.utils.FeatureManager; 15.8 15.9 import com.sun.org.apache.xpath.internal.functions.FuncExtFunction; 15.10 import java.util.Vector; 15.11 @@ -54,9 +55,12 @@ 15.12 } 15.13 15.14 public JAXPExtensionsProvider(XPathFunctionResolver resolver, 15.15 - boolean featureSecureProcessing ) { 15.16 + boolean featureSecureProcessing, FeatureManager featureManager ) { 15.17 this.resolver = resolver; 15.18 - this.extensionInvocationDisabled = featureSecureProcessing; 15.19 + if (featureSecureProcessing && 15.20 + !featureManager.isFeatureEnabled(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION)) { 15.21 + this.extensionInvocationDisabled = true; 15.22 + } 15.23 } 15.24 15.25 /**
16.1 --- a/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java Thu Oct 31 12:36:18 2013 -0700 16.2 +++ b/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java Thu Oct 31 16:31:44 2013 -0700 16.3 @@ -30,6 +30,7 @@ 16.4 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; 16.5 import com.sun.org.apache.xalan.internal.res.XSLMessages; 16.6 import com.sun.org.apache.xalan.internal.utils.FactoryImpl; 16.7 +import com.sun.org.apache.xalan.internal.utils.FeatureManager; 16.8 16.9 import javax.xml.namespace.NamespaceContext; 16.10 import javax.xml.namespace.QName; 16.11 @@ -67,33 +68,36 @@ 16.12 private boolean featureSecureProcessing = false; 16.13 16.14 private boolean useServicesMechanism = true; 16.15 + 16.16 + private final FeatureManager featureManager; 16.17 + 16.18 /** Protected constructor to prevent direct instantiation; use compile() 16.19 * from the context. 16.20 */ 16.21 - protected XPathExpressionImpl() { }; 16.22 + protected XPathExpressionImpl() { 16.23 + this(null, null, null, null, 16.24 + false, true, new FeatureManager()); 16.25 + }; 16.26 16.27 protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath, 16.28 JAXPPrefixResolver prefixResolver, 16.29 XPathFunctionResolver functionResolver, 16.30 XPathVariableResolver variableResolver ) { 16.31 - this.xpath = xpath; 16.32 - this.prefixResolver = prefixResolver; 16.33 - this.functionResolver = functionResolver; 16.34 - this.variableResolver = variableResolver; 16.35 - this.featureSecureProcessing = false; 16.36 + this(xpath, prefixResolver, functionResolver, variableResolver, 16.37 + false, true, new FeatureManager()); 16.38 }; 16.39 16.40 protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath, 16.41 - JAXPPrefixResolver prefixResolver, 16.42 - XPathFunctionResolver functionResolver, 16.43 - XPathVariableResolver variableResolver, 16.44 - boolean featureSecureProcessing, boolean useServicesMechanism ) { 16.45 + JAXPPrefixResolver prefixResolver,XPathFunctionResolver functionResolver, 16.46 + XPathVariableResolver variableResolver, boolean featureSecureProcessing, 16.47 + boolean useServicesMechanism, FeatureManager featureManager ) { 16.48 this.xpath = xpath; 16.49 this.prefixResolver = prefixResolver; 16.50 this.functionResolver = functionResolver; 16.51 this.variableResolver = variableResolver; 16.52 this.featureSecureProcessing = featureSecureProcessing; 16.53 this.useServicesMechanism = useServicesMechanism; 16.54 + this.featureManager = featureManager; 16.55 }; 16.56 16.57 public void setXPath (com.sun.org.apache.xpath.internal.XPath xpath ) { 16.58 @@ -111,7 +115,7 @@ 16.59 com.sun.org.apache.xpath.internal.XPathContext xpathSupport = null; 16.60 if ( functionResolver != null ) { 16.61 JAXPExtensionsProvider jep = new JAXPExtensionsProvider( 16.62 - functionResolver, featureSecureProcessing ); 16.63 + functionResolver, featureSecureProcessing, featureManager ); 16.64 xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext( jep ); 16.65 } else { 16.66 xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext();
17.1 --- a/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java Thu Oct 31 12:36:18 2013 -0700 17.2 +++ b/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java Thu Oct 31 16:31:44 2013 -0700 17.3 @@ -24,6 +24,8 @@ 17.4 import com.sun.org.apache.xalan.internal.XalanConstants; 17.5 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; 17.6 import com.sun.org.apache.xalan.internal.res.XSLMessages; 17.7 +import com.sun.org.apache.xalan.internal.utils.FeatureManager; 17.8 +import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase; 17.9 17.10 import javax.xml.XMLConstants; 17.11 import javax.xml.xpath.XPathFactory; 17.12 @@ -68,6 +70,8 @@ 17.13 17.14 private boolean _useServicesMechanism = true; 17.15 17.16 + private final FeatureManager _featureManager; 17.17 + 17.18 public XPathFactoryImpl() { 17.19 this(true); 17.20 } 17.21 @@ -77,9 +81,12 @@ 17.22 } 17.23 17.24 public XPathFactoryImpl(boolean useServicesMechanism) { 17.25 + _featureManager = new FeatureManager(); 17.26 if (System.getSecurityManager() != null) { 17.27 _isSecureMode = true; 17.28 _isNotSecureProcessing = false; 17.29 + _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION, 17.30 + FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE); 17.31 } 17.32 this._useServicesMechanism = useServicesMechanism; 17.33 } 17.34 @@ -131,7 +138,8 @@ 17.35 public javax.xml.xpath.XPath newXPath() { 17.36 return new com.sun.org.apache.xpath.internal.jaxp.XPathImpl( 17.37 xPathVariableResolver, xPathFunctionResolver, 17.38 - !_isNotSecureProcessing, _useServicesMechanism ); 17.39 + !_isNotSecureProcessing, _useServicesMechanism, 17.40 + _featureManager ); 17.41 } 17.42 17.43 /** 17.44 @@ -181,6 +189,10 @@ 17.45 } 17.46 17.47 _isNotSecureProcessing = !value; 17.48 + if (value && _featureManager != null) { 17.49 + _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION, 17.50 + FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE); 17.51 + } 17.52 17.53 // all done processing feature 17.54 return; 17.55 @@ -192,6 +204,11 @@ 17.56 return; 17.57 } 17.58 17.59 + if (_featureManager != null && 17.60 + _featureManager.setValue(name, FeaturePropertyBase.State.APIPROPERTY, value)) { 17.61 + return; 17.62 + } 17.63 + 17.64 // unknown feature 17.65 String fmsg = XSLMessages.createXPATHMessage( 17.66 XPATHErrorResources.ER_FEATURE_UNKNOWN, 17.67 @@ -240,6 +257,14 @@ 17.68 if (name.equals(XalanConstants.ORACLE_FEATURE_SERVICE_MECHANISM)) { 17.69 return _useServicesMechanism; 17.70 } 17.71 + 17.72 + /** Check to see if the property is managed by the security manager **/ 17.73 + String propertyValue = (_featureManager != null) ? 17.74 + _featureManager.getValueAsString(name) : null; 17.75 + if (propertyValue != null) { 17.76 + return _featureManager.isFeatureEnabled(name); 17.77 + } 17.78 + 17.79 // unknown feature 17.80 String fmsg = XSLMessages.createXPATHMessage( 17.81 XPATHErrorResources.ER_GETTING_UNKNOWN_FEATURE,
18.1 --- a/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java Thu Oct 31 12:36:18 2013 -0700 18.2 +++ b/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java Thu Oct 31 16:31:44 2013 -0700 18.3 @@ -35,6 +35,7 @@ 18.4 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; 18.5 import com.sun.org.apache.xalan.internal.res.XSLMessages; 18.6 import com.sun.org.apache.xalan.internal.utils.FactoryImpl; 18.7 +import com.sun.org.apache.xalan.internal.utils.FeatureManager; 18.8 18.9 import org.w3c.dom.Node; 18.10 import org.w3c.dom.Document; 18.11 @@ -70,18 +71,20 @@ 18.12 // extensions function need to throw XPathFunctionException 18.13 private boolean featureSecureProcessing = false; 18.14 private boolean useServiceMechanism = true; 18.15 + private final FeatureManager featureManager; 18.16 18.17 XPathImpl( XPathVariableResolver vr, XPathFunctionResolver fr ) { 18.18 - this.origVariableResolver = this.variableResolver = vr; 18.19 - this.origFunctionResolver = this.functionResolver = fr; 18.20 + this(vr, fr, false, true, new FeatureManager()); 18.21 } 18.22 18.23 XPathImpl( XPathVariableResolver vr, XPathFunctionResolver fr, 18.24 - boolean featureSecureProcessing, boolean useServiceMechanism ) { 18.25 + boolean featureSecureProcessing, boolean useServiceMechanism, 18.26 + FeatureManager featureManager) { 18.27 this.origVariableResolver = this.variableResolver = vr; 18.28 this.origFunctionResolver = this.functionResolver = fr; 18.29 this.featureSecureProcessing = featureSecureProcessing; 18.30 this.useServiceMechanism = useServiceMechanism; 18.31 + this.featureManager = featureManager; 18.32 } 18.33 18.34 /** 18.35 @@ -190,7 +193,7 @@ 18.36 com.sun.org.apache.xpath.internal.XPathContext xpathSupport = null; 18.37 if ( functionResolver != null ) { 18.38 JAXPExtensionsProvider jep = new JAXPExtensionsProvider( 18.39 - functionResolver, featureSecureProcessing ); 18.40 + functionResolver, featureSecureProcessing, featureManager ); 18.41 xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext( jep ); 18.42 } else { 18.43 xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext(); 18.44 @@ -391,7 +394,7 @@ 18.45 // Can have errorListener 18.46 XPathExpressionImpl ximpl = new XPathExpressionImpl (xpath, 18.47 prefixResolver, functionResolver, variableResolver, 18.48 - featureSecureProcessing, useServiceMechanism ); 18.49 + featureSecureProcessing, useServiceMechanism, featureManager ); 18.50 return ximpl; 18.51 } catch ( javax.xml.transform.TransformerException te ) { 18.52 throw new XPathExpressionException ( te ) ;