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

Here are the examples of the java api class com.sun.org.apache.xerces.internal.utils.XMLSecurityManager 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. 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);
}