com.sun.org.apache.xalan.internal.utils.XMLSecurityManager Java Examples

The following examples show how to use com.sun.org.apache.xalan.internal.utils.XMLSecurityManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransformerFactoryImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * javax.xml.transform.sax.TransformerFactory implementation.
 */
public TransformerFactoryImpl() {



    if (System.getSecurityManager() != null) {
        _isSecureMode = true;
        _isNotSecureProcessing = false;
    }

    _xmlFeatures = new JdkXmlFeatures(!_isNotSecureProcessing);
    _overrideDefaultParser = _xmlFeatures.getFeature(
            JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER);
    _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
    _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_DTD);
    _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_STYLESHEET);

    //Parser's security manager
    _xmlSecurityManager = new XMLSecurityManager(true);
    //Unmodifiable hash map with loaded external extension functions
    _xsltcExtensionFunctions = null;
}
 
Example #2
Source File: Parser.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Parses a stylesheet and builds the internal abstract syntax tree
 * @param input A SAX2 InputSource can be passed to a SAX reader
 * @return The root of the abstract syntax tree
 */
public SyntaxTreeNode parse(InputSource input) {
    final XMLReader reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser,
            _xsltc.isSecureProcessing());

    JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, XMLConstants.ACCESS_EXTERNAL_DTD,
            _xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD), true);

    String lastProperty = "";
    try {
        XMLSecurityManager securityManager =
                (XMLSecurityManager) _xsltc.getProperty(XalanConstants.SECURITY_MANAGER);
        for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
            lastProperty = limit.apiProperty();
            reader.setProperty(lastProperty, securityManager.getLimitValueAsString(limit));
        }
        if (securityManager.printEntityCountInfo()) {
            lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO;
            reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES);
        }
    } catch (SAXException se) {
        XMLSecurityManager.printWarning(reader.getClass().getName(), lastProperty, se);
    }

    return (parse(reader, input));
}
 
Example #3
Source File: TransformerFactoryImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private TransformerFactoryImpl(boolean useServicesMechanism) {
    this._useServicesMechanism = useServicesMechanism;
    _featureManager = new FeatureManager();

    if (System.getSecurityManager() != null) {
        _isSecureMode = true;
        _isNotSecureProcessing = false;
        _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION,
                FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE);
    }

    _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
    _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_DTD);
    _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_STYLESHEET);

    //Parser's security manager
    _xmlSecurityManager = new XMLSecurityManager(true);
}
 
Example #4
Source File: TransformerFactoryImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * javax.xml.transform.sax.TransformerFactory implementation.
 */
public TransformerFactoryImpl() {



    if (System.getSecurityManager() != null) {
        _isSecureMode = true;
        _isNotSecureProcessing = false;
    }

    _xmlFeatures = new JdkXmlFeatures(!_isNotSecureProcessing);
    _overrideDefaultParser = _xmlFeatures.getFeature(
            JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER);
    _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
    _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_DTD);
    _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_STYLESHEET);

    //Parser's security manager
    _xmlSecurityManager = new XMLSecurityManager(true);
    //Unmodifiable hash map with loaded external extension functions
    _xsltcExtensionFunctions = null;
}
 
Example #5
Source File: TransformerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected TransformerImpl(Translet translet, Properties outputProperties,
    int indentNumber, TransformerFactoryImpl tfactory)
{
    _translet = (AbstractTranslet) translet;
    _properties = createOutputProperties(outputProperties);
    _propertiesClone = (Properties) _properties.clone();
    _indentNumber = indentNumber;
    _tfactory = tfactory;
    _overrideDefaultParser = _tfactory.overrideDefaultParser();
    _accessExternalDTD = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD);
    _securityManager = (XMLSecurityManager)_tfactory.getAttribute(XalanConstants.SECURITY_MANAGER);
    _readerManager = XMLReaderManager.getInstance(_overrideDefaultParser);
    _readerManager.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
    _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
    _readerManager.setProperty(XalanConstants.SECURITY_MANAGER, _securityManager);
    //_isIncremental = tfactory._incremental;
}
 
Example #6
Source File: XSLTC.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set allowed protocols for accessing external stylesheet.
 */
public void setProperty(String name, Object value) {
    if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) {
        _accessExternalStylesheet = (String)value;
    }
    else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) {
        _accessExternalDTD = (String)value;
    } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
        _xmlSecurityManager = (XMLSecurityManager)value;
    } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
        _extensionClassLoader = (ClassLoader) value;
        /* Clear the external extension functions HashMap if extension class
           loader was changed */
        _externalExtensionFunctions.clear();
    }
}
 
Example #7
Source File: Parser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a stylesheet and builds the internal abstract syntax tree
 * @param input A SAX2 InputSource can be passed to a SAX reader
 * @return The root of the abstract syntax tree
 */
public SyntaxTreeNode parse(InputSource input) {
    final XMLReader reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser,
            _xsltc.isSecureProcessing());

    JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, XMLConstants.ACCESS_EXTERNAL_DTD,
            _xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD), true);

    String lastProperty = "";
    try {
        XMLSecurityManager securityManager =
                (XMLSecurityManager) _xsltc.getProperty(XalanConstants.SECURITY_MANAGER);
        for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
            lastProperty = limit.apiProperty();
            reader.setProperty(lastProperty, securityManager.getLimitValueAsString(limit));
        }
        if (securityManager.printEntityCountInfo()) {
            lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO;
            reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES);
        }
    } catch (SAXException se) {
        XMLSecurityManager.printWarning(reader.getClass().getName(), lastProperty, se);
    }

    return (parse(reader, input));
}
 
Example #8
Source File: XSLTC.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set allowed protocols for accessing external stylesheet.
 */
public void setProperty(String name, Object value) {
    if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) {
        _accessExternalStylesheet = (String)value;
    }
    else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) {
        _accessExternalDTD = (String)value;
    } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
        _xmlSecurityManager = (XMLSecurityManager)value;
    } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
        _extensionClassLoader = (ClassLoader) value;
        /* Clear the external extension functions HashMap if extension class
           loader was changed */
        _externalExtensionFunctions.clear();
    }
}
 
Example #9
Source File: TransformerImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected TransformerImpl(Translet translet, Properties outputProperties,
    int indentNumber, TransformerFactoryImpl tfactory)
{
    _translet = (AbstractTranslet) translet;
    _properties = createOutputProperties(outputProperties);
    _propertiesClone = (Properties) _properties.clone();
    _indentNumber = indentNumber;
    _tfactory = tfactory;
    _useServicesMechanism = _tfactory.useServicesMechnism();
    _accessExternalStylesheet = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET);
    _accessExternalDTD = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD);
    _securityManager = (XMLSecurityManager)_tfactory.getAttribute(XalanConstants.SECURITY_MANAGER);
    _readerManager = XMLReaderManager.getInstance(_useServicesMechanism);
    _readerManager.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
    _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
    _readerManager.setProperty(XalanConstants.SECURITY_MANAGER, _securityManager);
    //_isIncremental = tfactory._incremental;
}
 
Example #10
Source File: TransformerImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected TransformerImpl(Translet translet, Properties outputProperties,
    int indentNumber, TransformerFactoryImpl tfactory)
{
    _translet = (AbstractTranslet) translet;
    _properties = createOutputProperties(outputProperties);
    _propertiesClone = (Properties) _properties.clone();
    _indentNumber = indentNumber;
    _tfactory = tfactory;
    _useServicesMechanism = _tfactory.useServicesMechnism();
    _accessExternalStylesheet = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET);
    _accessExternalDTD = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD);
    _securityManager = (XMLSecurityManager)_tfactory.getAttribute(XalanConstants.SECURITY_MANAGER);
    _readerManager = XMLReaderManager.getInstance(_useServicesMechanism);
    _readerManager.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
    _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
    _readerManager.setProperty(XalanConstants.SECURITY_MANAGER, _securityManager);
    //_isIncremental = tfactory._incremental;
}
 
Example #11
Source File: TransformerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected TransformerImpl(Translet translet, Properties outputProperties,
    int indentNumber, TransformerFactoryImpl tfactory)
{
    _translet = (AbstractTranslet) translet;
    _properties = createOutputProperties(outputProperties);
    _propertiesClone = (Properties) _properties.clone();
    _indentNumber = indentNumber;
    _tfactory = tfactory;
    _overrideDefaultParser = _tfactory.overrideDefaultParser();
    _accessExternalDTD = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD);
    _securityManager = (XMLSecurityManager)_tfactory.getAttribute(XalanConstants.SECURITY_MANAGER);
    _readerManager = XMLReaderManager.getInstance(_overrideDefaultParser);
    _readerManager.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
    _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
    _readerManager.setProperty(XalanConstants.SECURITY_MANAGER, _securityManager);
    //_isIncremental = tfactory._incremental;
}
 
Example #12
Source File: XSLTC.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set allowed protocols for accessing external stylesheet.
 */
public void setProperty(String name, Object value) {
    if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) {
        _accessExternalStylesheet = (String)value;
    }
    else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) {
        _accessExternalDTD = (String)value;
    } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
        _xmlSecurityManager = (XMLSecurityManager)value;
    } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
        _extensionClassLoader = (ClassLoader) value;
        /* Clear the external extension functions HashMap if extension class
           loader was changed */
        _externalExtensionFunctions.clear();
    }
}
 
Example #13
Source File: Parser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a stylesheet and builds the internal abstract syntax tree
 * @param input A SAX2 InputSource can be passed to a SAX reader
 * @return The root of the abstract syntax tree
 */
public SyntaxTreeNode parse(InputSource input) {
    final XMLReader reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser,
            _xsltc.isSecureProcessing());

    JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, XMLConstants.ACCESS_EXTERNAL_DTD,
            _xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD), true);

    String lastProperty = "";
    try {
        XMLSecurityManager securityManager =
                (XMLSecurityManager) _xsltc.getProperty(XalanConstants.SECURITY_MANAGER);
        for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
            lastProperty = limit.apiProperty();
            reader.setProperty(lastProperty, securityManager.getLimitValueAsString(limit));
        }
        if (securityManager.printEntityCountInfo()) {
            lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO;
            reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES);
        }
    } catch (SAXException se) {
        XMLSecurityManager.printWarning(reader.getClass().getName(), lastProperty, se);
    }

    return (parse(reader, input));
}
 
Example #14
Source File: TransformerFactoryImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private TransformerFactoryImpl(boolean useServicesMechanism) {
    this._useServicesMechanism = useServicesMechanism;
    _featureManager = new FeatureManager();

    if (System.getSecurityManager() != null) {
        _isSecureMode = true;
        _isNotSecureProcessing = false;
        _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION,
                FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE);
    }

    _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
    _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_DTD);
    _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_STYLESHEET);

    //Parser's security manager
    _xmlSecurityManager = new XMLSecurityManager(true);
    //Unmodifiable hash map with loaded external extension functions
    _xsltcExtensionFunctions = null;
}
 
Example #15
Source File: XSLTC.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set allowed protocols for accessing external stylesheet.
 * @param name the name of the property
 * @param value the value of the property
 */
public void setProperty(String name, Object value) {
    if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) {
        _accessExternalStylesheet = (String)value;
    }
    else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) {
        _accessExternalDTD = (String)value;
    } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
        _xmlSecurityManager = (XMLSecurityManager)value;
    } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
        _extensionClassLoader = (ClassLoader) value;
        /* Clear the external extension functions HashMap if extension class
           loader was changed */
        _externalExtensionFunctions.clear();
    } else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) {
        _catalogFeatures = (CatalogFeatures)value;
    } else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) {
        _cdataChunkSize = Integer.parseInt((String)value);
    }
}
 
Example #16
Source File: TransformerFactoryImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * javax.xml.transform.sax.TransformerFactory implementation.
 */
public TransformerFactoryImpl() {

    if (System.getSecurityManager() != null) {
        _isSecureMode = true;
        _isNotSecureProcessing = false;
    }

    _xmlFeatures = new JdkXmlFeatures(!_isNotSecureProcessing);
    _overrideDefaultParser = _xmlFeatures.getFeature(
            JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER);
    _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
    _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_DTD);
    _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_STYLESHEET);

    //Parser's security manager
    _xmlSecurityManager = new XMLSecurityManager(true);
    //Unmodifiable hash map with loaded external extension functions
    _xsltcExtensionFunctions = null;
}
 
Example #17
Source File: XSLTC.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Set allowed protocols for accessing external stylesheet.
 * @param name the name of the property
 * @param value the value of the property
 */
public void setProperty(String name, Object value) {
    if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) {
        _accessExternalStylesheet = (String)value;
    }
    else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) {
        _accessExternalDTD = (String)value;
    } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
        _xmlSecurityManager = (XMLSecurityManager)value;
    } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
        _extensionClassLoader = (ClassLoader) value;
        /* Clear the external extension functions HashMap if extension class
           loader was changed */
        _externalExtensionFunctions.clear();
    } else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) {
        _catalogFeatures = (CatalogFeatures)value;
    } else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) {
        _cdataChunkSize = Integer.parseInt((String)value);
    }
}
 
Example #18
Source File: TransformerFactoryImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private TransformerFactoryImpl(boolean useServicesMechanism) {
    this._useServicesMechanism = useServicesMechanism;

    if (System.getSecurityManager() != null) {
        _isSecureMode = true;
        _isNotSecureProcessing = false;
    }

    _xmlFeatures = new JdkXmlFeatures(!_isNotSecureProcessing);
    _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
    _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_DTD);
    _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_STYLESHEET);

    //Parser's security manager
    _xmlSecurityManager = new XMLSecurityManager(true);
    //Unmodifiable hash map with loaded external extension functions
    _xsltcExtensionFunctions = null;
}
 
Example #19
Source File: Parser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a stylesheet and builds the internal abstract syntax tree
 * @param input A SAX2 InputSource can be passed to a SAX reader
 * @return The root of the abstract syntax tree
 */
public SyntaxTreeNode parse(InputSource input) {
    final XMLReader reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser,
            _xsltc.isSecureProcessing());

    JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, XMLConstants.ACCESS_EXTERNAL_DTD,
            _xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD), true);

    String lastProperty = "";
    try {
        XMLSecurityManager securityManager =
                (XMLSecurityManager) _xsltc.getProperty(XalanConstants.SECURITY_MANAGER);
        for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
            lastProperty = limit.apiProperty();
            reader.setProperty(lastProperty, securityManager.getLimitValueAsString(limit));
        }
        if (securityManager.printEntityCountInfo()) {
            lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO;
            reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES);
        }
    } catch (SAXException se) {
        XMLSecurityManager.printWarning(reader.getClass().getName(), lastProperty, se);
    }

    return (parse(reader, input));
}
 
Example #20
Source File: TransformerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
protected TransformerImpl(Translet translet, Properties outputProperties,
    int indentNumber, TransformerFactoryImpl tfactory)
{
    _translet = (AbstractTranslet) translet;
    _properties = createOutputProperties(outputProperties);
    _propertiesClone = (Properties) _properties.clone();
    _indentNumber = indentNumber;
    _tfactory = tfactory;
    _useServicesMechanism = _tfactory.useServicesMechnism();
    _accessExternalStylesheet = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET);
    _accessExternalDTD = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD);
    _securityManager = (XMLSecurityManager)_tfactory.getAttribute(XalanConstants.SECURITY_MANAGER);
    _readerManager = XMLReaderManager.getInstance(_useServicesMechanism);
    _readerManager.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
    _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
    _readerManager.setProperty(XalanConstants.SECURITY_MANAGER, _securityManager);
    //_isIncremental = tfactory._incremental;
}
 
Example #21
Source File: XSLTC.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Set allowed protocols for accessing external stylesheet.
 */
public void setProperty(String name, Object value) {
    if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) {
        _accessExternalStylesheet = (String)value;
    }
    else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) {
        _accessExternalDTD = (String)value;
    } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
        _xmlSecurityManager = (XMLSecurityManager)value;
    } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
        _extensionClassLoader = (ClassLoader) value;
        /* Clear the external extension functions HashMap if extension class
           loader was changed */
        _externalExtensionFunctions.clear();
    }
}
 
Example #22
Source File: TransformerFactoryImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private TransformerFactoryImpl(boolean useServicesMechanism) {
    this._useServicesMechanism = useServicesMechanism;
    _featureManager = new FeatureManager();

    if (System.getSecurityManager() != null) {
        _isSecureMode = true;
        _isNotSecureProcessing = false;
        _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION,
                FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE);
    }

    _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
    _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_DTD);
    _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_STYLESHEET);

    //Parser's security manager
    _xmlSecurityManager = new XMLSecurityManager(true);
    //Unmodifiable hash map with loaded external extension functions
    _xsltcExtensionFunctions = null;
}
 
Example #23
Source File: TransformerImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected TransformerImpl(Translet translet, Properties outputProperties,
    int indentNumber, TransformerFactoryImpl tfactory)
{
    _translet = (AbstractTranslet) translet;
    _properties = createOutputProperties(outputProperties);
    _propertiesClone = (Properties) _properties.clone();
    _indentNumber = indentNumber;
    _tfactory = tfactory;
    _useServicesMechanism = _tfactory.useServicesMechnism();
    _accessExternalStylesheet = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET);
    _accessExternalDTD = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD);
    _securityManager = (XMLSecurityManager)_tfactory.getAttribute(XalanConstants.SECURITY_MANAGER);
    _readerManager = XMLReaderManager.getInstance(_useServicesMechanism);
    _readerManager.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
    _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
    _readerManager.setProperty(XalanConstants.SECURITY_MANAGER, _securityManager);
    //_isIncremental = tfactory._incremental;
}
 
Example #24
Source File: TransformerFactoryImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * javax.xml.transform.sax.TransformerFactory implementation.
 */
public TransformerFactoryImpl() {



    if (System.getSecurityManager() != null) {
        _isSecureMode = true;
        _isNotSecureProcessing = false;
    }

    _xmlFeatures = new JdkXmlFeatures(!_isNotSecureProcessing);
    _overrideDefaultParser = _xmlFeatures.getFeature(
            JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER);
    _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
    _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_DTD);
    _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_STYLESHEET);

    //Parser's security manager
    _xmlSecurityManager = new XMLSecurityManager(true);
    //Unmodifiable hash map with loaded external extension functions
    _xsltcExtensionFunctions = null;
}
 
Example #25
Source File: TransformerImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected TransformerImpl(Translet translet, Properties outputProperties,
    int indentNumber, TransformerFactoryImpl tfactory)
{
    _translet = (AbstractTranslet) translet;
    _properties = createOutputProperties(outputProperties);
    _propertiesClone = (Properties) _properties.clone();
    _indentNumber = indentNumber;
    _tfactory = tfactory;
    _overrideDefaultParser = _tfactory.overrideDefaultParser();
    _accessExternalDTD = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD);
    _securityManager = (XMLSecurityManager)_tfactory.getAttribute(XalanConstants.SECURITY_MANAGER);
    _readerManager = XMLReaderManager.getInstance(_overrideDefaultParser);
    _readerManager.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
    _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
    _readerManager.setProperty(XalanConstants.SECURITY_MANAGER, _securityManager);
    //_isIncremental = tfactory._incremental;
}
 
Example #26
Source File: XSLTC.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set allowed protocols for accessing external stylesheet.
 */
public void setProperty(String name, Object value) {
    if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) {
        _accessExternalStylesheet = (String)value;
    }
    else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) {
        _accessExternalDTD = (String)value;
    } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
        _xmlSecurityManager = (XMLSecurityManager)value;
    } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
        _extensionClassLoader = (ClassLoader) value;
        /* Clear the external extension functions HashMap if extension class
           loader was changed */
        _externalExtensionFunctions.clear();
    }
}
 
Example #27
Source File: XSLTC.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Set allowed protocols for accessing external stylesheet.
 */
public void setProperty(String name, Object value) {
    if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) {
        _accessExternalStylesheet = (String)value;
    }
    else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) {
        _accessExternalDTD = (String)value;
    } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
        _xmlSecurityManager = (XMLSecurityManager)value;
    } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
        _extensionClassLoader = (ClassLoader) value;
        /* Clear the external extension functions HashMap if extension class
           loader was changed */
        _externalExtensionFunctions.clear();
    }
}
 
Example #28
Source File: TransformerFactoryImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private TransformerFactoryImpl(boolean useServicesMechanism) {
    this._useServicesMechanism = useServicesMechanism;
    _featureManager = new FeatureManager();

    if (System.getSecurityManager() != null) {
        _isSecureMode = true;
        _isNotSecureProcessing = false;
        _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION,
                FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE);
    }

    _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
    _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_DTD);
    _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_STYLESHEET);

    //Parser's security manager
    _xmlSecurityManager = new XMLSecurityManager(true);
}
 
Example #29
Source File: TransformerFactoryImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private TransformerFactoryImpl(boolean useServicesMechanism) {
    this._useServicesMechanism = useServicesMechanism;
    _featureManager = new FeatureManager();

    if (System.getSecurityManager() != null) {
        _isSecureMode = true;
        _isNotSecureProcessing = false;
        _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION,
                FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE);
    }

    _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
    _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_DTD);
    _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
            Property.ACCESS_EXTERNAL_STYLESHEET);

    //Parser's security manager
    _xmlSecurityManager = new XMLSecurityManager(true);
    //Unmodifiable hash map with loaded external extension functions
    _xsltcExtensionFunctions = null;
}
 
Example #30
Source File: TransformerImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected TransformerImpl(Translet translet, Properties outputProperties,
    int indentNumber, TransformerFactoryImpl tfactory)
{
    _translet = (AbstractTranslet) translet;
    _properties = createOutputProperties(outputProperties);
    _propertiesClone = (Properties) _properties.clone();
    _indentNumber = indentNumber;
    _tfactory = tfactory;
    _useServicesMechanism = _tfactory.useServicesMechnism();
    _accessExternalStylesheet = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET);
    _accessExternalDTD = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD);
    _securityManager = (XMLSecurityManager)_tfactory.getAttribute(XalanConstants.SECURITY_MANAGER);
    _readerManager = XMLReaderManager.getInstance(_useServicesMechanism);
    _readerManager.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
    _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
    _readerManager.setProperty(XalanConstants.SECURITY_MANAGER, _securityManager);
    //_isIncremental = tfactory._incremental;
}