Java Code Examples for com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager#getValue()

The following examples show how to use com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager#getValue() . 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: XMLDocumentFragmentScannerImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {

    super.setProperty(propertyId, value);

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
        if (suffixLength == Constants.ENTITY_MANAGER_PROPERTY.length() &&
                propertyId.endsWith(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
            return;
        }
        if (suffixLength == Constants.ENTITY_RESOLVER_PROPERTY.length() &&
                propertyId.endsWith(Constants.ENTITY_RESOLVER_PROPERTY)) {
            fExternalSubsetResolver = (value instanceof ExternalSubsetResolver) ?
                (ExternalSubsetResolver) value : null;
            return;
        }
    }


            // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
        if (property.equals(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
        }
        return;
    }

    //JAXP 1.5 properties
    if (propertyId.equals(XML_SECURITY_PROPERTY_MANAGER))
    {
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)value;
        fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
    }

}
 
Example 2
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {

    super.setProperty(propertyId, value);

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
        if (suffixLength == Constants.ENTITY_MANAGER_PROPERTY.length() &&
                propertyId.endsWith(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
            return;
        }
        if (suffixLength == Constants.ENTITY_RESOLVER_PROPERTY.length() &&
                propertyId.endsWith(Constants.ENTITY_RESOLVER_PROPERTY)) {
            fExternalSubsetResolver = (value instanceof ExternalSubsetResolver) ?
                (ExternalSubsetResolver) value : null;
            return;
        }
    }


            // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
        if (property.equals(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
        }
        return;
    }

    //JAXP 1.5 properties
    if (propertyId.equals(XML_SECURITY_PROPERTY_MANAGER))
    {
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)value;
        fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
    }

}
 
Example 3
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void reset(PropertyManager propertyManager){

        super.reset(propertyManager);

        // other settings
        // fDocumentSystemId = null;
        fNamespaces = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue();
        fNotifyBuiltInRefs = false ;

        //fElementStack2.clear();
        //fReplaceEntityReferences = true;
        //fSupportExternalEntities = true;
        Boolean bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES);
        fReplaceEntityReferences = bo.booleanValue();
        bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES);
        fSupportExternalEntities = bo.booleanValue();
        Boolean cdata = (Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.STAX_REPORT_CDATA_EVENT) ;
        if(cdata != null)
            fReportCdataEvent = cdata.booleanValue() ;
        Boolean coalesce = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_COALESCING) ;
        if(coalesce != null)
            fIsCoalesce = coalesce.booleanValue();
        fReportCdataEvent = fIsCoalesce ? false : (fReportCdataEvent && true) ;
        //if fIsCoalesce is set to true, set the value of fReplaceEntityReferences to true,
        //if fIsCoalesce is set to false, take the value of fReplaceEntityReferences as set by application
        fReplaceEntityReferences = fIsCoalesce ? true : fReplaceEntityReferences;
        // setup Driver
        //we dont need to do this -- nb.
        //setScannerState(SCANNER_STATE_CONTENT);
        //setDriver(fContentDriver);
        //fEntityManager.test();

         // JAXP 1.5 features and properties
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)
                propertyManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
        fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);

        fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(Constants.SECURITY_MANAGER);
        resetCommon();
    }
 
Example 4
Source File: XMLSchemaLoader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the state of a property.
 *
 * @param propertyId The property identifier.
 * @param state     The state of the property.
 *
 * @throws XMLConfigurationException Thrown when a property is not
 *                  recognized or cannot be set.
 */
public void setProperty(String propertyId,
        Object state) throws XMLConfigurationException {
    fSettingsChanged = true;
    fLoaderConfig.setProperty(propertyId, state);
    if (propertyId.equals(JAXP_SCHEMA_SOURCE)) {
        fJAXPSource = state;
        fJAXPProcessed = false;
    }
    else if (propertyId.equals(XMLGRAMMAR_POOL)) {
        fGrammarPool = (XMLGrammarPool)state;
    }
    else if (propertyId.equals(SCHEMA_LOCATION)) {
        fExternalSchemas = (String)state;
    }
    else if (propertyId.equals(SCHEMA_NONS_LOCATION)) {
        fExternalNoNSSchema = (String) state;
    }
    else if (propertyId.equals(LOCALE)) {
        setLocale((Locale) state);
    }
    else if (propertyId.equals(ENTITY_RESOLVER)) {
        fEntityManager.setProperty(ENTITY_RESOLVER, state);
    }
    else if (propertyId.equals(ERROR_REPORTER)) {
        fErrorReporter = (XMLErrorReporter)state;
        if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
            fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
        }
    }
    else if (propertyId.equals(XML_SECURITY_PROPERTY_MANAGER)) {
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)state;
        faccessExternalSchema = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
    }
}
 
Example 5
Source File: XMLSchemaLoader.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the state of a property.
 *
 * @param propertyId The property identifier.
 * @param state     The state of the property.
 *
 * @throws XMLConfigurationException Thrown when a property is not
 *                  recognized or cannot be set.
 */
public void setProperty(String propertyId,
        Object state) throws XMLConfigurationException {
    fSettingsChanged = true;
    fLoaderConfig.setProperty(propertyId, state);
    if (propertyId.equals(JAXP_SCHEMA_SOURCE)) {
        fJAXPSource = state;
        fJAXPProcessed = false;
    }
    else if (propertyId.equals(XMLGRAMMAR_POOL)) {
        fGrammarPool = (XMLGrammarPool)state;
    }
    else if (propertyId.equals(SCHEMA_LOCATION)) {
        fExternalSchemas = (String)state;
    }
    else if (propertyId.equals(SCHEMA_NONS_LOCATION)) {
        fExternalNoNSSchema = (String) state;
    }
    else if (propertyId.equals(LOCALE)) {
        setLocale((Locale) state);
    }
    else if (propertyId.equals(ENTITY_RESOLVER)) {
        fEntityManager.setProperty(ENTITY_RESOLVER, state);
    }
    else if (propertyId.equals(ERROR_REPORTER)) {
        fErrorReporter = (XMLErrorReporter)state;
        if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
            fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
        }
    }
    else if (propertyId.equals(XML_SECURITY_PROPERTY_MANAGER)) {
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)state;
        faccessExternalSchema = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
    }
}
 
Example 6
Source File: XMLDocumentFragmentScannerImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void reset(PropertyManager propertyManager){

        super.reset(propertyManager);

        // other settings
        // fDocumentSystemId = null;
        fNamespaces = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue();
        fNotifyBuiltInRefs = false ;

        //fElementStack2.clear();
        //fReplaceEntityReferences = true;
        //fSupportExternalEntities = true;
        Boolean bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES);
        fReplaceEntityReferences = bo.booleanValue();
        bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES);
        fSupportExternalEntities = bo.booleanValue();
        Boolean cdata = (Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.STAX_REPORT_CDATA_EVENT) ;
        if(cdata != null)
            fReportCdataEvent = cdata.booleanValue() ;
        Boolean coalesce = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_COALESCING) ;
        if(coalesce != null)
            fIsCoalesce = coalesce.booleanValue();
        fReportCdataEvent = fIsCoalesce ? false : (fReportCdataEvent && true) ;
        //if fIsCoalesce is set to true, set the value of fReplaceEntityReferences to true,
        //if fIsCoalesce is set to false, take the value of fReplaceEntityReferences as set by application
        fReplaceEntityReferences = fIsCoalesce ? true : fReplaceEntityReferences;
        // setup Driver
        //we dont need to do this -- nb.
        //setScannerState(SCANNER_STATE_CONTENT);
        //setDriver(fContentDriver);
        //fEntityManager.test();

         // JAXP 1.5 features and properties
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)
                propertyManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
        fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);

        fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(Constants.SECURITY_MANAGER);
        resetCommon();
    }
 
Example 7
Source File: XMLDocumentFragmentScannerImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {

    super.setProperty(propertyId, value);

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
        if (suffixLength == Constants.ENTITY_MANAGER_PROPERTY.length() &&
                propertyId.endsWith(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
            return;
        }
        if (suffixLength == Constants.ENTITY_RESOLVER_PROPERTY.length() &&
                propertyId.endsWith(Constants.ENTITY_RESOLVER_PROPERTY)) {
            fExternalSubsetResolver = (value instanceof ExternalSubsetResolver) ?
                (ExternalSubsetResolver) value : null;
            return;
        }
    }


            // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
        if (property.equals(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
        }
        return;
    }

    //JAXP 1.5 properties
    if (propertyId.equals(XML_SECURITY_PROPERTY_MANAGER))
    {
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)value;
        fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
    }

}
 
Example 8
Source File: XMLEntityManager.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void reset(PropertyManager propertyManager){
    // xerces properties
    fSymbolTable = (SymbolTable)propertyManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY);
    fErrorReporter = (XMLErrorReporter)propertyManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY);
    try {
        fStaxEntityResolver = (StaxEntityResolverWrapper)propertyManager.getProperty(STAX_ENTITY_RESOLVER);
    } catch (XMLConfigurationException e) {
        fStaxEntityResolver = null;
    }

    fSupportDTD = ((Boolean)propertyManager.getProperty(XMLInputFactory.SUPPORT_DTD)).booleanValue();
    fReplaceEntityReferences = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES)).booleanValue();
    fSupportExternalEntities = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES)).booleanValue();

    // Zephyr feature ignore-external-dtd is the opposite of Xerces' load-external-dtd
    fLoadExternalDTD = !((Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.IGNORE_EXTERNAL_DTD)).booleanValue();

    // JAXP 1.5 feature
    XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager) propertyManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
    fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);

    fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(SECURITY_MANAGER);

    fLimitAnalyzer = new XMLLimitAnalyzer();
    //reset fEntityStorage
    fEntityStorage.reset(propertyManager);
    //reset XMLEntityReaderImpl
    fEntityScanner.reset(propertyManager);

    // initialize state
    //fStandalone = false;
    fEntities.clear();
    fEntityStack.removeAllElements();
    fCurrentEntity = null;
    fValidation = false;
    fExternalGeneralEntities = true;
    fExternalParameterEntities = true;
    fAllowJavaEncodings = true ;
}
 
Example 9
Source File: XMLEntityManager.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void reset(PropertyManager propertyManager){
    // xerces properties
    fSymbolTable = (SymbolTable)propertyManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY);
    fErrorReporter = (XMLErrorReporter)propertyManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY);
    try {
        fStaxEntityResolver = (StaxEntityResolverWrapper)propertyManager.getProperty(STAX_ENTITY_RESOLVER);
    } catch (XMLConfigurationException e) {
        fStaxEntityResolver = null;
    }

    fSupportDTD = ((Boolean)propertyManager.getProperty(XMLInputFactory.SUPPORT_DTD)).booleanValue();
    fReplaceEntityReferences = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES)).booleanValue();
    fSupportExternalEntities = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES)).booleanValue();

    // Zephyr feature ignore-external-dtd is the opposite of Xerces' load-external-dtd
    fLoadExternalDTD = !((Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.IGNORE_EXTERNAL_DTD)).booleanValue();

    // JAXP 1.5 feature
    XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager) propertyManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
    fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);

    fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(SECURITY_MANAGER);

    fLimitAnalyzer = new XMLLimitAnalyzer();
    //reset fEntityStorage
    fEntityStorage.reset(propertyManager);
    //reset XMLEntityReaderImpl
    fEntityScanner.reset(propertyManager);

    // initialize state
    //fStandalone = false;
    fEntities.clear();
    fEntityStack.removeAllElements();
    fCurrentEntity = null;
    fValidation = false;
    fExternalGeneralEntities = true;
    fExternalParameterEntities = true;
    fAllowJavaEncodings = true ;
}
 
Example 10
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void reset(PropertyManager propertyManager){

        super.reset(propertyManager);

        // other settings
        // fDocumentSystemId = null;
        fNamespaces = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue();
        fNotifyBuiltInRefs = false ;

        //fElementStack2.clear();
        //fReplaceEntityReferences = true;
        //fSupportExternalEntities = true;
        Boolean bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES);
        fReplaceEntityReferences = bo.booleanValue();
        bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES);
        fSupportExternalEntities = bo.booleanValue();
        Boolean cdata = (Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.STAX_REPORT_CDATA_EVENT) ;
        if(cdata != null)
            fReportCdataEvent = cdata.booleanValue() ;
        Boolean coalesce = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_COALESCING) ;
        if(coalesce != null)
            fIsCoalesce = coalesce.booleanValue();
        fReportCdataEvent = fIsCoalesce ? false : (fReportCdataEvent && true) ;
        //if fIsCoalesce is set to true, set the value of fReplaceEntityReferences to true,
        //if fIsCoalesce is set to false, take the value of fReplaceEntityReferences as set by application
        fReplaceEntityReferences = fIsCoalesce ? true : fReplaceEntityReferences;
        // setup Driver
        //we dont need to do this -- nb.
        //setScannerState(SCANNER_STATE_CONTENT);
        //setDriver(fContentDriver);
        //fEntityManager.test();

         // JAXP 1.5 features and properties
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)
                propertyManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
        fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);

        fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(Constants.SECURITY_MANAGER);
        resetCommon();
    }
 
Example 11
Source File: XMLDocumentFragmentScannerImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {

    super.setProperty(propertyId, value);

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
        if (suffixLength == Constants.ENTITY_MANAGER_PROPERTY.length() &&
                propertyId.endsWith(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
            return;
        }
        if (suffixLength == Constants.ENTITY_RESOLVER_PROPERTY.length() &&
                propertyId.endsWith(Constants.ENTITY_RESOLVER_PROPERTY)) {
            fExternalSubsetResolver = (value instanceof ExternalSubsetResolver) ?
                (ExternalSubsetResolver) value : null;
            return;
        }
    }


            // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
        if (property.equals(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
        }
        return;
    }

    //JAXP 1.5 properties
    if (propertyId.equals(XML_SECURITY_PROPERTY_MANAGER))
    {
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)value;
        fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
    }

}
 
Example 12
Source File: XMLDocumentFragmentScannerImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void reset(PropertyManager propertyManager){

        super.reset(propertyManager);

        // other settings
        // fDocumentSystemId = null;
        fNamespaces = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue();
        fNotifyBuiltInRefs = false ;

        //fElementStack2.clear();
        //fReplaceEntityReferences = true;
        //fSupportExternalEntities = true;
        Boolean bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES);
        fReplaceEntityReferences = bo.booleanValue();
        bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES);
        fSupportExternalEntities = bo.booleanValue();
        Boolean cdata = (Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.STAX_REPORT_CDATA_EVENT) ;
        if(cdata != null)
            fReportCdataEvent = cdata.booleanValue() ;
        Boolean coalesce = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_COALESCING) ;
        if(coalesce != null)
            fIsCoalesce = coalesce.booleanValue();
        fReportCdataEvent = fIsCoalesce ? false : (fReportCdataEvent && true) ;
        //if fIsCoalesce is set to true, set the value of fReplaceEntityReferences to true,
        //if fIsCoalesce is set to false, take the value of fReplaceEntityReferences as set by application
        fReplaceEntityReferences = fIsCoalesce ? true : fReplaceEntityReferences;
        // setup Driver
        //we dont need to do this -- nb.
        //setScannerState(SCANNER_STATE_CONTENT);
        //setDriver(fContentDriver);
        //fEntityManager.test();

         // JAXP 1.5 features and properties
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)
                propertyManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
        fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);

        fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(Constants.SECURITY_MANAGER);
        resetCommon();
    }
 
Example 13
Source File: XMLDocumentFragmentScannerImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {

    super.setProperty(propertyId, value);

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
        if (suffixLength == Constants.ENTITY_MANAGER_PROPERTY.length() &&
                propertyId.endsWith(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
            return;
        }
        if (suffixLength == Constants.ENTITY_RESOLVER_PROPERTY.length() &&
                propertyId.endsWith(Constants.ENTITY_RESOLVER_PROPERTY)) {
            fExternalSubsetResolver = (value instanceof ExternalSubsetResolver) ?
                (ExternalSubsetResolver) value : null;
            return;
        }
    }


            // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
        if (property.equals(Constants.ENTITY_MANAGER_PROPERTY)) {
            fEntityManager = (XMLEntityManager)value;
        }
        return;
    }

    //JAXP 1.5 properties
    if (propertyId.equals(XML_SECURITY_PROPERTY_MANAGER))
    {
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)value;
        fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
    }

}
 
Example 14
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Resets the component. The component can query the component manager
 * about any features and properties that affect the operation of the
 * component.
 *
 * @param componentManager The component manager.
 *
 * @throws SAXException Thrown by component on initialization error.
 *                      For example, if a feature or property is
 *                      required for the operation of the component, the
 *                      component manager may throw a
 *                      SAXNotRecognizedException or a
 *                      SAXNotSupportedException.
 */

public void reset(XMLComponentManager componentManager)
throws XMLConfigurationException {

    super.reset(componentManager);

    // other settings
    // fDocumentSystemId = null;

    // sax features
    //fAttributes.setNamespaces(fNamespaces);

    // xerces features
    fReportCdataEvent = componentManager.getFeature(Constants.STAX_REPORT_CDATA_EVENT, true);
    fSecurityManager = (XMLSecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER, null);
    fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS, false);

    Object resolver = componentManager.getProperty(ENTITY_RESOLVER, null);
    fExternalSubsetResolver = (resolver instanceof ExternalSubsetResolver) ?
            (ExternalSubsetResolver) resolver : null;

    //attribute
    fReadingAttributes = false;
    //xxx: external entities are supported in Xerces
    // it would be good to define feature for this case
    fSupportExternalEntities = true;
    fReplaceEntityReferences = true;
    fIsCoalesce = false;

    // setup Driver
    setScannerState(SCANNER_STATE_CONTENT);
    setDriver(fContentDriver);

    // JAXP 1.5 features and properties
    XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)
            componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER, null);
    fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);

    fStrictURI = componentManager.getFeature(STANDARD_URI_CONFORMANT, false);
    fChunkSize = JdkXmlUtils.getValue(componentManager.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE),
            JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);

    resetCommon();
    //fEntityManager.test();
}
 
Example 15
Source File: XMLEntityManager.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value){
    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();

        if (suffixLength == Constants.SYMBOL_TABLE_PROPERTY.length() &&
            propertyId.endsWith(Constants.SYMBOL_TABLE_PROPERTY)) {
            fSymbolTable = (SymbolTable)value;
            return;
        }
        if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() &&
            propertyId.endsWith(Constants.ERROR_REPORTER_PROPERTY)) {
            fErrorReporter = (XMLErrorReporter)value;
            return;
        }
        if (suffixLength == Constants.ENTITY_RESOLVER_PROPERTY.length() &&
            propertyId.endsWith(Constants.ENTITY_RESOLVER_PROPERTY)) {
            fEntityResolver = (XMLEntityResolver)value;
            return;
        }
        if (suffixLength == Constants.BUFFER_SIZE_PROPERTY.length() &&
            propertyId.endsWith(Constants.BUFFER_SIZE_PROPERTY)) {
            Integer bufferSize = (Integer)value;
            if (bufferSize != null &&
                bufferSize.intValue() > DEFAULT_XMLDECL_BUFFER_SIZE) {
                fBufferSize = bufferSize.intValue();
                fEntityScanner.setBufferSize(fBufferSize);
                fBufferPool.setExternalBufferSize(fBufferSize);
            }
        }
        if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
            propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
            fSecurityManager = (XMLSecurityManager)value;
        }
    }

    //JAXP 1.5 properties
    if (propertyId.equals(XML_SECURITY_PROPERTY_MANAGER))
    {
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)value;
        fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
    }
}
 
Example 16
Source File: XMLDocumentFragmentScannerImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Resets the component. The component can query the component manager
 * about any features and properties that affect the operation of the
 * component.
 *
 * @param componentManager The component manager.
 *
 * @throws SAXException Thrown by component on initialization error.
 *                      For example, if a feature or property is
 *                      required for the operation of the component, the
 *                      component manager may throw a
 *                      SAXNotRecognizedException or a
 *                      SAXNotSupportedException.
 */

public void reset(XMLComponentManager componentManager)
throws XMLConfigurationException {

    super.reset(componentManager);

    // other settings
    // fDocumentSystemId = null;

    // sax features
    //fAttributes.setNamespaces(fNamespaces);

    // xerces features
    fReportCdataEvent = componentManager.getFeature(Constants.STAX_REPORT_CDATA_EVENT, true);
    fSecurityManager = (XMLSecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER, null);
    fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS, false);

    fCreateEntityRefNodes = componentManager.getFeature(CREATE_ENTITY_REF_NODES, fCreateEntityRefNodes);

    Object resolver = componentManager.getProperty(ENTITY_RESOLVER, null);
    fExternalSubsetResolver = (resolver instanceof ExternalSubsetResolver) ?
            (ExternalSubsetResolver) resolver : null;

    //attribute
    fReadingAttributes = false;
    //xxx: external entities are supported in Xerces
    // it would be good to define feature for this case
    fSupportExternalEntities = true;
    fReplaceEntityReferences = true;
    fIsCoalesce = false;

    // setup Driver
    setScannerState(SCANNER_STATE_CONTENT);
    setDriver(fContentDriver);

    // JAXP 1.5 features and properties
    XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)
            componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER, null);
    fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);

    fStrictURI = componentManager.getFeature(STANDARD_URI_CONFORMANT, false);
    fChunkSize = JdkXmlUtils.getValue(componentManager.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE),
            JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);

    resetCommon();
    //fEntityManager.test();
}
 
Example 17
Source File: XMLDocumentFragmentScannerImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Resets the component. The component can query the component manager
 * about any features and properties that affect the operation of the
 * component.
 *
 * @param componentManager The component manager.
 *
 * @throws SAXException Thrown by component on initialization error.
 *                      For example, if a feature or property is
 *                      required for the operation of the component, the
 *                      component manager may throw a
 *                      SAXNotRecognizedException or a
 *                      SAXNotSupportedException.
 */

public void reset(XMLComponentManager componentManager)
throws XMLConfigurationException {

    super.reset(componentManager);

    // other settings
    // fDocumentSystemId = null;

    // sax features
    //fAttributes.setNamespaces(fNamespaces);

    // xerces features
    fReportCdataEvent = componentManager.getFeature(Constants.STAX_REPORT_CDATA_EVENT, true);
    fSecurityManager = (XMLSecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER, null);
    fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS, false);

    Object resolver = componentManager.getProperty(ENTITY_RESOLVER, null);
    fExternalSubsetResolver = (resolver instanceof ExternalSubsetResolver) ?
            (ExternalSubsetResolver) resolver : null;

    //attribute
    fReadingAttributes = false;
    //xxx: external entities are supported in Xerces
    // it would be good to define feature for this case
    fSupportExternalEntities = true;
    fReplaceEntityReferences = true;
    fIsCoalesce = false;

    // setup Driver
    setScannerState(SCANNER_STATE_CONTENT);
    setDriver(fContentDriver);

    // JAXP 1.5 features and properties
    XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)
            componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER, null);
    fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);

    fStrictURI = componentManager.getFeature(STANDARD_URI_CONFORMANT, false);

    resetCommon();
    //fEntityManager.test();
}
 
Example 18
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Resets the component. The component can query the component manager
 * about any features and properties that affect the operation of the
 * component.
 *
 * @param componentManager The component manager.
 *
 * @throws SAXException Thrown by component on initialization error.
 *                      For example, if a feature or property is
 *                      required for the operation of the component, the
 *                      component manager may throw a
 *                      SAXNotRecognizedException or a
 *                      SAXNotSupportedException.
 */

public void reset(XMLComponentManager componentManager)
throws XMLConfigurationException {

    super.reset(componentManager);

    // other settings
    // fDocumentSystemId = null;

    // sax features
    //fAttributes.setNamespaces(fNamespaces);

    // xerces features
    fReportCdataEvent = componentManager.getFeature(Constants.STAX_REPORT_CDATA_EVENT, true);
    fSecurityManager = (XMLSecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER, null);
    fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS, false);

    Object resolver = componentManager.getProperty(ENTITY_RESOLVER, null);
    fExternalSubsetResolver = (resolver instanceof ExternalSubsetResolver) ?
            (ExternalSubsetResolver) resolver : null;

    //attribute
    fReadingAttributes = false;
    //xxx: external entities are supported in Xerces
    // it would be good to define feature for this case
    fSupportExternalEntities = true;
    fReplaceEntityReferences = true;
    fIsCoalesce = false;

    // setup Driver
    setScannerState(SCANNER_STATE_CONTENT);
    setDriver(fContentDriver);

    // JAXP 1.5 features and properties
    XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)
            componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER, null);
    fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);

    fStrictURI = componentManager.getFeature(STANDARD_URI_CONFORMANT, false);

    resetCommon();
    //fEntityManager.test();
}
 
Example 19
Source File: XMLEntityManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value){
    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();

        if (suffixLength == Constants.SYMBOL_TABLE_PROPERTY.length() &&
            propertyId.endsWith(Constants.SYMBOL_TABLE_PROPERTY)) {
            fSymbolTable = (SymbolTable)value;
            return;
        }
        if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() &&
            propertyId.endsWith(Constants.ERROR_REPORTER_PROPERTY)) {
            fErrorReporter = (XMLErrorReporter)value;
            return;
        }
        if (suffixLength == Constants.ENTITY_RESOLVER_PROPERTY.length() &&
            propertyId.endsWith(Constants.ENTITY_RESOLVER_PROPERTY)) {
            fEntityResolver = (XMLEntityResolver)value;
            return;
        }
        if (suffixLength == Constants.BUFFER_SIZE_PROPERTY.length() &&
            propertyId.endsWith(Constants.BUFFER_SIZE_PROPERTY)) {
            Integer bufferSize = (Integer)value;
            if (bufferSize != null &&
                bufferSize.intValue() > DEFAULT_XMLDECL_BUFFER_SIZE) {
                fBufferSize = bufferSize.intValue();
                fEntityScanner.setBufferSize(fBufferSize);
                fBufferPool.setExternalBufferSize(fBufferSize);
            }
        }
        if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
            propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
            fSecurityManager = (XMLSecurityManager)value;
        }
    }

    //JAXP 1.5 properties
    if (propertyId.equals(XML_SECURITY_PROPERTY_MANAGER))
    {
        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)value;
        fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
    }
}
 
Example 20
Source File: XMLDocumentFragmentScannerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Resets the component. The component can query the component manager
 * about any features and properties that affect the operation of the
 * component.
 *
 * @param componentManager The component manager.
 *
 * @throws SAXException Thrown by component on initialization error.
 *                      For example, if a feature or property is
 *                      required for the operation of the component, the
 *                      component manager may throw a
 *                      SAXNotRecognizedException or a
 *                      SAXNotSupportedException.
 */

public void reset(XMLComponentManager componentManager)
throws XMLConfigurationException {

    super.reset(componentManager);

    // other settings
    // fDocumentSystemId = null;

    // sax features
    //fAttributes.setNamespaces(fNamespaces);

    // xerces features
    fReportCdataEvent = componentManager.getFeature(Constants.STAX_REPORT_CDATA_EVENT, true);
    fSecurityManager = (XMLSecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER, null);
    fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS, false);

    Object resolver = componentManager.getProperty(ENTITY_RESOLVER, null);
    fExternalSubsetResolver = (resolver instanceof ExternalSubsetResolver) ?
            (ExternalSubsetResolver) resolver : null;

    //attribute
    fReadingAttributes = false;
    //xxx: external entities are supported in Xerces
    // it would be good to define feature for this case
    fSupportExternalEntities = true;
    fReplaceEntityReferences = true;
    fIsCoalesce = false;

    // setup Driver
    setScannerState(SCANNER_STATE_CONTENT);
    setDriver(fContentDriver);

    // JAXP 1.5 features and properties
    XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)
            componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER, null);
    fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);

    fStrictURI = componentManager.getFeature(STANDARD_URI_CONFORMANT, false);

    resetCommon();
    //fEntityManager.test();
}