com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager Java Examples
The following examples show how to use
com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager.
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: XMLSchemaFactory.java From JDKSourceCode1.8 with MIT License | 6 votes |
public XMLSchemaFactory() { fErrorHandlerWrapper = new ErrorHandlerWrapper(DraconianErrorHandler.getInstance()); fDOMEntityResolverWrapper = new DOMEntityResolverWrapper(); fXMLGrammarPoolWrapper = new XMLGrammarPoolWrapper(); fXMLSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, true); fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper); fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper); fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper); // Enable secure processing feature by default fSecurityManager = new XMLSecurityManager(true); fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); fSecurityPropertyMgr = new XMLSecurityPropertyManager(); fXMLSchemaLoader.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr); fXmlFeatures = new JdkXmlFeatures(fSecurityManager.isSecureProcessing()); fOverrideDefaultParser = fXmlFeatures.getFeature( JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER); fXMLSchemaLoader.setFeature(JdkXmlUtils.OVERRIDE_PARSER, fOverrideDefaultParser); }
Example #2
Source File: XMLSchemaFactory.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public XMLSchemaFactory() { fErrorHandlerWrapper = new ErrorHandlerWrapper(DraconianErrorHandler.getInstance()); fDOMEntityResolverWrapper = new DOMEntityResolverWrapper(); fXMLGrammarPoolWrapper = new XMLGrammarPoolWrapper(); fXMLSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, true); fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper); fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper); fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper); // Enable secure processing feature by default fSecurityManager = new XMLSecurityManager(true); fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); fSecurityPropertyMgr = new XMLSecurityPropertyManager(); fXMLSchemaLoader.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr); fXmlFeatures = new JdkXmlFeatures(fSecurityManager.isSecureProcessing()); fOverrideDefaultParser = fXmlFeatures.getFeature( JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER); fXMLSchemaLoader.setFeature(JdkXmlUtils.OVERRIDE_PARSER, fOverrideDefaultParser); }
Example #3
Source File: XMLSchemaFactory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public XMLSchemaFactory() { fErrorHandlerWrapper = new ErrorHandlerWrapper(DraconianErrorHandler.getInstance()); fDOMEntityResolverWrapper = new DOMEntityResolverWrapper(); fXMLGrammarPoolWrapper = new XMLGrammarPoolWrapper(); fXMLSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, true); fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper); fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper); fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper); // Enable secure processing feature by default fSecurityManager = new XMLSecurityManager(true); fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); fSecurityPropertyMgr = new XMLSecurityPropertyManager(); fXMLSchemaLoader.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr); fXmlFeatures = new JdkXmlFeatures(fSecurityManager.isSecureProcessing()); fOverrideDefaultParser = fXmlFeatures.getFeature( JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER); fXMLSchemaLoader.setFeature(JdkXmlUtils.OVERRIDE_PARSER, fOverrideDefaultParser); }
Example #4
Source File: XMLSchemaFactory.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
private XMLSchemaFactory(boolean useServicesMechanism) { fUseServicesMechanism = useServicesMechanism; fErrorHandlerWrapper = new ErrorHandlerWrapper(DraconianErrorHandler.getInstance()); fDOMEntityResolverWrapper = new DOMEntityResolverWrapper(); fXMLGrammarPoolWrapper = new XMLGrammarPoolWrapper(); fXMLSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, true); fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper); fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper); fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper); // Enable secure processing feature by default fSecurityManager = new XMLSecurityManager(true); fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); fSecurityPropertyMgr = new XMLSecurityPropertyManager(); fXMLSchemaLoader.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr); }
Example #5
Source File: XMLDocumentFragmentScannerImpl.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * 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 #6
Source File: PropertyManager.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * 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); }
Example #7
Source File: PropertyManager.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Initialize this object with the properties taken from passed PropertyManager object. */ public PropertyManager(PropertyManager propertyManager){ HashMap properties = propertyManager.getProperties(); supportedProps.putAll(properties); fSecurityManager = (XMLSecurityManager)getProperty(SECURITY_MANAGER); fSecurityPropertyMgr = (XMLSecurityPropertyManager)getProperty(XML_SECURITY_PROPERTY_MANAGER); }
Example #8
Source File: XMLEntityManager.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
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: PropertyManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example #10
Source File: PropertyManager.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Initialize this object with the properties taken from passed PropertyManager object. */ public PropertyManager(PropertyManager propertyManager){ HashMap properties = propertyManager.getProperties(); supportedProps.putAll(properties); fSecurityManager = (XMLSecurityManager)getProperty(SECURITY_MANAGER); fSecurityPropertyMgr = (XMLSecurityPropertyManager)getProperty(XML_SECURITY_PROPERTY_MANAGER); }
Example #11
Source File: PropertyManager.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example #12
Source File: XMLEntityManager.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 #13
Source File: XMLSchemaValidatorComponentManager.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Set the state of a feature. * * @param featureId The unique identifier (URI) of the feature. * @param state The requested state of the feature (true or false). * * @exception XMLConfigurationException If the requested feature is not known. */ public void setFeature(String featureId, boolean value) throws XMLConfigurationException { if (PARSER_SETTINGS.equals(featureId)) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } else if (value == false && (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId))) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } else if (USE_GRAMMAR_POOL_ONLY.equals(featureId) && value != fUseGrammarPoolOnly) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) { if (_isSecureMode && !value) { throw new XMLConfigurationException(Status.NOT_ALLOWED, XMLConstants.FEATURE_SECURE_PROCESSING); } fInitSecurityManager.setSecureProcessing(value); setProperty(SECURITY_MANAGER, fInitSecurityManager); if (value) { fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD, XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA, XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr); } return; } fConfigUpdated = true; fEntityManager.setFeature(featureId, value); fErrorReporter.setFeature(featureId, value); fSchemaValidator.setFeature(featureId, value); if (!fInitFeatures.containsKey(featureId)) { boolean current = super.getFeature(featureId); fInitFeatures.put(featureId, current ? Boolean.TRUE : Boolean.FALSE); } super.setFeature(featureId, value); }
Example #14
Source File: PropertyManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Initialize this object with the properties taken from passed PropertyManager object. */ public PropertyManager(PropertyManager propertyManager){ HashMap properties = propertyManager.getProperties(); supportedProps.putAll(properties); fSecurityManager = (XMLSecurityManager)getProperty(SECURITY_MANAGER); fSecurityPropertyMgr = (XMLSecurityPropertyManager)getProperty(XML_SECURITY_PROPERTY_MANAGER); }
Example #15
Source File: XMLEntityManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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 #16
Source File: XMLSchemaValidatorComponentManager.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Sets the state of a property. * * @param propertyId The unique identifier (URI) of the property. * @param value The requested state of the property. * * @exception XMLConfigurationException If the requested property is not known. */ public void setProperty(String propertyId, Object value) throws XMLConfigurationException { if ( ENTITY_MANAGER.equals(propertyId) || ERROR_REPORTER.equals(propertyId) || NAMESPACE_CONTEXT.equals(propertyId) || SCHEMA_VALIDATOR.equals(propertyId) || SYMBOL_TABLE.equals(propertyId) || VALIDATION_MANAGER.equals(propertyId) || XMLGRAMMAR_POOL.equals(propertyId)) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, propertyId); } fConfigUpdated = true; fEntityManager.setProperty(propertyId, value); fErrorReporter.setProperty(propertyId, value); fSchemaValidator.setProperty(propertyId, value); if (ENTITY_RESOLVER.equals(propertyId) || ERROR_HANDLER.equals(propertyId) || SECURITY_MANAGER.equals(propertyId)) { fComponents.put(propertyId, value); return; } else if (LOCALE.equals(propertyId)) { setLocale((Locale) value); fComponents.put(propertyId, value); return; } //check if the property is managed by security manager if (fInitSecurityManager == null || !fInitSecurityManager.setLimit(propertyId, XMLSecurityManager.State.APIPROPERTY, value)) { //check if the property is managed by security property manager if (fSecurityPropertyMgr == null || !fSecurityPropertyMgr.setValue(propertyId, XMLSecurityPropertyManager.State.APIPROPERTY, value)) { //fall back to the existing property manager if (!fInitProperties.containsKey(propertyId)) { fInitProperties.put(propertyId, super.getProperty(propertyId)); } super.setProperty(propertyId, value); } } }
Example #17
Source File: XMLSchemaValidatorComponentManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Set the state of a feature. * * @param featureId The unique identifier (URI) of the feature. * @param state The requested state of the feature (true or false). * * @exception XMLConfigurationException If the requested feature is not known. */ public void setFeature(String featureId, boolean value) throws XMLConfigurationException { if (PARSER_SETTINGS.equals(featureId)) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } else if (value == false && (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId))) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } else if (USE_GRAMMAR_POOL_ONLY.equals(featureId) && value != fUseGrammarPoolOnly) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) { if (_isSecureMode && !value) { throw new XMLConfigurationException(Status.NOT_ALLOWED, XMLConstants.FEATURE_SECURE_PROCESSING); } fInitSecurityManager.setSecureProcessing(value); setProperty(SECURITY_MANAGER, fInitSecurityManager); if (value && Constants.IS_JDK8_OR_ABOVE) { fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD, XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA, XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr); } return; } fConfigUpdated = true; fEntityManager.setFeature(featureId, value); fErrorReporter.setFeature(featureId, value); fSchemaValidator.setFeature(featureId, value); if (!fInitFeatures.containsKey(featureId)) { boolean current = super.getFeature(featureId); fInitFeatures.put(featureId, current ? Boolean.TRUE : Boolean.FALSE); } super.setFeature(featureId, value); }
Example #18
Source File: PropertyManager.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Initialize this object with the properties taken from passed PropertyManager object. */ public PropertyManager(PropertyManager propertyManager){ HashMap<String, Object> properties = propertyManager.getProperties(); supportedProps.putAll(properties); fSecurityManager = (XMLSecurityManager)getProperty(SECURITY_MANAGER); fSecurityPropertyMgr = (XMLSecurityPropertyManager)getProperty(XML_SECURITY_PROPERTY_MANAGER); }
Example #19
Source File: XMLDocumentFragmentScannerImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 #20
Source File: XMLSchemaLoader.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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 #21
Source File: XMLDocumentFragmentScannerImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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 #22
Source File: PropertyManager.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example #23
Source File: XMLEntityManager.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void reset(PropertyManager propertyManager){ //reset fEntityStorage fEntityStorage.reset(propertyManager); //reset XMLEntityReaderImpl fEntityScanner.reset(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); // initialize state //fStandalone = false; fEntities.clear(); fEntityStack.removeAllElements(); fCurrentEntity = null; fValidation = false; fExternalGeneralEntities = true; fExternalParameterEntities = true; fAllowJavaEncodings = true ; }
Example #24
Source File: XMLSchemaValidatorComponentManager.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Set the state of a feature. * * @param featureId The unique identifier (URI) of the feature. * @param state The requested state of the feature (true or false). * * @exception XMLConfigurationException If the requested feature is not known. */ public void setFeature(String featureId, boolean value) throws XMLConfigurationException { if (PARSER_SETTINGS.equals(featureId)) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } else if (value == false && (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId))) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } else if (USE_GRAMMAR_POOL_ONLY.equals(featureId) && value != fUseGrammarPoolOnly) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) { if (_isSecureMode && !value) { throw new XMLConfigurationException(Status.NOT_ALLOWED, XMLConstants.FEATURE_SECURE_PROCESSING); } fInitSecurityManager.setSecureProcessing(value); setProperty(SECURITY_MANAGER, fInitSecurityManager); if (value && Constants.IS_JDK8_OR_ABOVE) { fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD, XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA, XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr); } return; } fConfigUpdated = true; fEntityManager.setFeature(featureId, value); fErrorReporter.setFeature(featureId, value); fSchemaValidator.setFeature(featureId, value); if (!fInitFeatures.containsKey(featureId)) { boolean current = super.getFeature(featureId); fInitFeatures.put(featureId, current ? Boolean.TRUE : Boolean.FALSE); } super.setFeature(featureId, value); }
Example #25
Source File: XMLSchemaValidatorComponentManager.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Sets the state of a property. * * @param propertyId The unique identifier (URI) of the property. * @param value The requested state of the property. * * @exception XMLConfigurationException If the requested property is not known. */ public void setProperty(String propertyId, Object value) throws XMLConfigurationException { if ( ENTITY_MANAGER.equals(propertyId) || ERROR_REPORTER.equals(propertyId) || NAMESPACE_CONTEXT.equals(propertyId) || SCHEMA_VALIDATOR.equals(propertyId) || SYMBOL_TABLE.equals(propertyId) || VALIDATION_MANAGER.equals(propertyId) || XMLGRAMMAR_POOL.equals(propertyId)) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, propertyId); } fConfigUpdated = true; fEntityManager.setProperty(propertyId, value); fErrorReporter.setProperty(propertyId, value); fSchemaValidator.setProperty(propertyId, value); if (ENTITY_RESOLVER.equals(propertyId) || ERROR_HANDLER.equals(propertyId) || SECURITY_MANAGER.equals(propertyId)) { fComponents.put(propertyId, value); return; } else if (LOCALE.equals(propertyId)) { setLocale((Locale) value); fComponents.put(propertyId, value); return; } //check if the property is managed by security manager if (fInitSecurityManager == null || !fInitSecurityManager.setLimit(propertyId, XMLSecurityManager.State.APIPROPERTY, value)) { //check if the property is managed by security property manager if (fSecurityPropertyMgr == null || !fSecurityPropertyMgr.setValue(propertyId, XMLSecurityPropertyManager.State.APIPROPERTY, value)) { //fall back to the existing property manager if (!fInitProperties.containsKey(propertyId)) { fInitProperties.put(propertyId, super.getProperty(propertyId)); } super.setProperty(propertyId, value); } } }
Example #26
Source File: XMLSchemaValidatorComponentManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Set the state of a feature. * * @param featureId The unique identifier (URI) of the feature. * @param state The requested state of the feature (true or false). * * @exception XMLConfigurationException If the requested feature is not known. */ public void setFeature(String featureId, boolean value) throws XMLConfigurationException { if (PARSER_SETTINGS.equals(featureId)) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } else if (value == false && (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId))) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } else if (USE_GRAMMAR_POOL_ONLY.equals(featureId) && value != fUseGrammarPoolOnly) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) { if (_isSecureMode && !value) { throw new XMLConfigurationException(Status.NOT_ALLOWED, XMLConstants.FEATURE_SECURE_PROCESSING); } fInitSecurityManager.setSecureProcessing(value); setProperty(SECURITY_MANAGER, fInitSecurityManager); if (value && Constants.IS_JDK8_OR_ABOVE) { fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD, XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA, XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr); } return; } fConfigUpdated = true; fEntityManager.setFeature(featureId, value); fErrorReporter.setFeature(featureId, value); fSchemaValidator.setFeature(featureId, value); if (!fInitFeatures.containsKey(featureId)) { boolean current = super.getFeature(featureId); fInitFeatures.put(featureId, current ? Boolean.TRUE : Boolean.FALSE); } super.setFeature(featureId, value); }
Example #27
Source File: XMLSchemaLoader.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * 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 #28
Source File: XMLEntityManager.java From JDKSourceCode1.8 with MIT License | 5 votes |
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 #29
Source File: XMLDocumentFragmentScannerImpl.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * 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 #30
Source File: PropertyManager.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * 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); }