com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager

Here are the examples of the java api class com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager taken from open source projects.

1. PropertyManager#initConfigurableReaderProperties()

Project: openjdk
Source File: PropertyManager.java
View license
/**
     * Important point:
     * 1. We are not exposing Xerces namespace property. Application should configure namespace through
     * Stax specific property.
     *
     */
private void initConfigurableReaderProperties() {
    //spec default values
    supportedProps.put(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
    supportedProps.put(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
    supportedProps.put(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE);
    supportedProps.put(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.TRUE);
    supportedProps.put(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
    supportedProps.put(XMLInputFactory.SUPPORT_DTD, Boolean.TRUE);
    supportedProps.put(XMLInputFactory.REPORTER, null);
    supportedProps.put(XMLInputFactory.RESOLVER, null);
    supportedProps.put(XMLInputFactory.ALLOCATOR, null);
    supportedProps.put(STAX_NOTATIONS, null);
    //zephyr (implementation) specific properties which can be set by the application.
    //interning is always done
    supportedProps.put(Constants.SAX_FEATURE_PREFIX + Constants.STRING_INTERNING_FEATURE, new Boolean(true));
    //recognizing java encoding names by default
    supportedProps.put(Constants.XERCES_FEATURE_PREFIX + Constants.ALLOW_JAVA_ENCODINGS_FEATURE, new Boolean(true));
    //in stax mode, namespace declarations are not added as attributes
    supportedProps.put(Constants.ADD_NAMESPACE_DECL_AS_ATTRIBUTE, Boolean.FALSE);
    supportedProps.put(Constants.READER_IN_DEFINED_STATE, new Boolean(true));
    supportedProps.put(Constants.REUSE_INSTANCE, new Boolean(true));
    supportedProps.put(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.STAX_REPORT_CDATA_EVENT, new Boolean(false));
    supportedProps.put(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.IGNORE_EXTERNAL_DTD, Boolean.FALSE);
    supportedProps.put(Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE, new Boolean(false));
    supportedProps.put(Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ENTITYDEF_FEATURE, new Boolean(false));
    supportedProps.put(Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_UNDECLARED_ELEMDEF_FEATURE, new Boolean(false));
    fSecurityManager = new XMLSecurityManager(true);
    supportedProps.put(SECURITY_MANAGER, fSecurityManager);
    fSecurityPropertyMgr = new XMLSecurityPropertyManager();
    supportedProps.put(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
}

2. XMLDocumentFragmentScannerImpl#reset()

View license
//
// XMLComponent methods
//
/**
     * 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();
}

3. XMLDocumentFragmentScannerImpl#reset()

View license
// reset(XMLComponentManager)
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();
}

4. XMLEntityManager#reset()

Project: openjdk
Source File: XMLEntityManager.java
View license
// endEntity()
//
// XMLComponent methods
//
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;
}

5. XMLEntityManager#reset()

Project: openjdk
Source File: XMLEntityManager.java
View license
/**
     * 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 {
    boolean parser_settings = componentManager.getFeature(PARSER_SETTINGS, true);
    if (!parser_settings) {
        // parser settings have not been changed
        reset();
        if (fEntityScanner != null) {
            fEntityScanner.reset(componentManager);
        }
        if (fEntityStorage != null) {
            fEntityStorage.reset(componentManager);
        }
        return;
    }
    // sax features
    fValidation = componentManager.getFeature(VALIDATION, false);
    fExternalGeneralEntities = componentManager.getFeature(EXTERNAL_GENERAL_ENTITIES, true);
    fExternalParameterEntities = componentManager.getFeature(EXTERNAL_PARAMETER_ENTITIES, true);
    // xerces features
    fAllowJavaEncodings = componentManager.getFeature(ALLOW_JAVA_ENCODINGS, false);
    fWarnDuplicateEntityDef = componentManager.getFeature(WARN_ON_DUPLICATE_ENTITYDEF, false);
    fStrictURI = componentManager.getFeature(STANDARD_URI_CONFORMANT, false);
    fLoadExternalDTD = componentManager.getFeature(LOAD_EXTERNAL_DTD, true);
    // xerces properties
    fSymbolTable = (SymbolTable) componentManager.getProperty(SYMBOL_TABLE);
    fErrorReporter = (XMLErrorReporter) componentManager.getProperty(ERROR_REPORTER);
    fEntityResolver = (XMLEntityResolver) componentManager.getProperty(ENTITY_RESOLVER, null);
    fStaxEntityResolver = (StaxEntityResolverWrapper) componentManager.getProperty(STAX_ENTITY_RESOLVER, null);
    fValidationManager = (ValidationManager) componentManager.getProperty(VALIDATION_MANAGER, null);
    fSecurityManager = (XMLSecurityManager) componentManager.getProperty(SECURITY_MANAGER, null);
    entityExpansionIndex = fSecurityManager.getIndex(Constants.JDK_ENTITY_EXPANSION_LIMIT);
    //StAX Property
    fSupportDTD = true;
    fReplaceEntityReferences = true;
    fSupportExternalEntities = true;
    // JAXP 1.5 feature
    XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager) componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER, null);
    if (spm == null) {
        spm = new XMLSecurityPropertyManager();
    }
    fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
    //reset general state
    reset();
    fEntityScanner.reset(componentManager);
    fEntityStorage.reset(componentManager);
}

6. XMLSchemaLoader#reset()

Project: openjdk
Source File: XMLSchemaLoader.java
View license
/* (non-Javadoc)
     * @see com.sun.org.apache.xerces.internal.xni.parser.XMLComponent#reset(com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager)
     */
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
    XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager) componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
    if (spm == null) {
        spm = new XMLSecurityPropertyManager();
        setProperty(XML_SECURITY_PROPERTY_MANAGER, spm);
    }
    XMLSecurityManager sm = (XMLSecurityManager) componentManager.getProperty(SECURITY_MANAGER);
    if (sm == null)
        setProperty(SECURITY_MANAGER, new XMLSecurityManager(true));
    faccessExternalSchema = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
    fGrammarBucket.reset();
    fSubGroupHandler.reset();
    boolean parser_settings = true;
    // thrown.
    if (componentManager != fLoaderConfig) {
        parser_settings = componentManager.getFeature(PARSER_SETTINGS, true);
    }
    if (!parser_settings || !fSettingsChanged) {
        // need to reprocess JAXP schema sources
        fJAXPProcessed = false;
        // reinitialize grammar bucket
        initGrammarBucket();
        if (fDeclPool != null) {
            fDeclPool.reset();
        }
        return;
    }
    //pass the component manager to the factory..
    fNodeFactory.reset(componentManager);
    // get registered entity manager to be able to resolve JAXP schema-source property:
    // Note: in case XMLSchemaValidator has created the loader,
    // the entity manager property is null
    fEntityManager = (XMLEntityManager) componentManager.getProperty(ENTITY_MANAGER);
    // get the error reporter
    fErrorReporter = (XMLErrorReporter) componentManager.getProperty(ERROR_REPORTER);
    // Determine schema dv factory to use
    SchemaDVFactory dvFactory = null;
    dvFactory = fSchemaHandler.getDVFactory();
    if (dvFactory == null) {
        dvFactory = SchemaDVFactory.getInstance();
        fSchemaHandler.setDVFactory(dvFactory);
    }
    // get schema location properties
    try {
        fExternalSchemas = (String) componentManager.getProperty(SCHEMA_LOCATION);
        fExternalNoNSSchema = (String) componentManager.getProperty(SCHEMA_NONS_LOCATION);
    } catch (XMLConfigurationException e) {
        fExternalSchemas = null;
        fExternalNoNSSchema = null;
    }
    // get JAXP sources if available
    fJAXPSource = componentManager.getProperty(JAXP_SCHEMA_SOURCE, null);
    fJAXPProcessed = false;
    // clear grammars, and put the one for schema namespace there
    fGrammarPool = (XMLGrammarPool) componentManager.getProperty(XMLGRAMMAR_POOL, null);
    initGrammarBucket();
    boolean psvi = componentManager.getFeature(AUGMENT_PSVI, false);
    // it can be safely used.
    if (!psvi && fGrammarPool == null && false) {
        if (fDeclPool != null) {
            fDeclPool.reset();
        } else {
            fDeclPool = new XSDeclarationPool();
        }
        fCMBuilder.setDeclPool(fDeclPool);
        fSchemaHandler.setDeclPool(fDeclPool);
        if (dvFactory instanceof SchemaDVFactoryImpl) {
            fDeclPool.setDVFactory((SchemaDVFactoryImpl) dvFactory);
            ((SchemaDVFactoryImpl) dvFactory).setDeclPool(fDeclPool);
        }
    } else {
        fCMBuilder.setDeclPool(null);
        fSchemaHandler.setDeclPool(null);
        if (dvFactory instanceof SchemaDVFactoryImpl) {
            ((SchemaDVFactoryImpl) dvFactory).setDeclPool(null);
        }
    }
    // get continue-after-fatal-error feature
    try {
        boolean fatalError = componentManager.getFeature(CONTINUE_AFTER_FATAL_ERROR, false);
        if (!fatalError) {
            fErrorReporter.setFeature(CONTINUE_AFTER_FATAL_ERROR, fatalError);
        }
    } catch (XMLConfigurationException e) {
    }
    // set full validation to false
    fIsCheckedFully = componentManager.getFeature(SCHEMA_FULL_CHECKING, false);
    // get generate-synthetic-annotations feature
    fSchemaHandler.setGenerateSyntheticAnnotations(componentManager.getFeature(GENERATE_SYNTHETIC_ANNOTATIONS, false));
    fSchemaHandler.reset(componentManager);
}