src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java

Print this page




  28 import javax.xml.stream.XMLEventReader;
  29 import javax.xml.transform.Source;
  30 import javax.xml.transform.dom.DOMSource;
  31 import javax.xml.transform.sax.SAXSource;
  32 import javax.xml.transform.stax.StAXSource;
  33 import javax.xml.transform.stream.StreamSource;
  34 import javax.xml.validation.Schema;
  35 import javax.xml.validation.SchemaFactory;
  36 
  37 import com.sun.org.apache.xerces.internal.impl.Constants;
  38 import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader;
  39 import com.sun.org.apache.xerces.internal.util.DOMEntityResolverWrapper;
  40 import com.sun.org.apache.xerces.internal.util.DOMInputSource;
  41 import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
  42 import com.sun.org.apache.xerces.internal.util.SAXInputSource;
  43 import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
  44 import com.sun.org.apache.xerces.internal.util.SecurityManager;
  45 import com.sun.org.apache.xerces.internal.util.StAXInputSource;
  46 import com.sun.org.apache.xerces.internal.util.Status;
  47 import com.sun.org.apache.xerces.internal.util.XMLGrammarPoolImpl;
  48 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
  49 import com.sun.org.apache.xerces.internal.xni.XNIException;
  50 import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
  51 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
  52 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
  53 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
  54 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
  55 import org.w3c.dom.Node;
  56 import org.w3c.dom.ls.LSResourceResolver;
  57 import org.xml.sax.ErrorHandler;
  58 import org.xml.sax.InputSource;
  59 import org.xml.sax.SAXException;
  60 import org.xml.sax.SAXNotRecognizedException;
  61 import org.xml.sax.SAXNotSupportedException;
  62 import org.xml.sax.SAXParseException;
  63 
  64 /**
  65  * {@link SchemaFactory} for XML Schema.
  66  *
  67  * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
  68  * @version $Id: XMLSchemaFactory.java,v 1.11 2010-11-01 04:40:08 joehw Exp $
  69  */
  70 public final class XMLSchemaFactory extends SchemaFactory {
  71 
  72     // property identifiers
  73 
  74     /** Feature identifier: schema full checking. */
  75     private static final String SCHEMA_FULL_CHECKING =
  76         Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
  77 
  78     /** Property identifier: grammar pool. */
  79     private static final String XMLGRAMMAR_POOL =
  80         Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
  81 
  82     /** Property identifier: SecurityManager. */
  83     private static final String SECURITY_MANAGER =
  84         Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
  85 
  86     /** property identifier: access external dtd. */
  87     public static final String ACCESS_EXTERNAL_DTD = XMLConstants.ACCESS_EXTERNAL_DTD;

  88 
  89     /** Property identifier: access to external schema  */
  90     public static final String ACCESS_EXTERNAL_SCHEMA = XMLConstants.ACCESS_EXTERNAL_SCHEMA;
  91 
  92     //
  93     // Data
  94     //
  95 
  96     /** The XMLSchemaLoader */
  97     private final XMLSchemaLoader fXMLSchemaLoader = new XMLSchemaLoader();
  98 
  99     /** User-specified ErrorHandler; can be null. */
 100     private ErrorHandler fErrorHandler;
 101 
 102     /** The LSResrouceResolver */
 103     private LSResourceResolver fLSResourceResolver;
 104 
 105     /** The DOMEntityResolverWrapper */
 106     private final DOMEntityResolverWrapper fDOMEntityResolverWrapper;
 107 
 108     /** The ErrorHandlerWrapper */
 109     private ErrorHandlerWrapper fErrorHandlerWrapper;
 110 
 111     /** The SecurityManager. */
 112     private SecurityManager fSecurityManager;
 113 



 114     /** The container for the real grammar pool. */
 115     private XMLGrammarPoolWrapper fXMLGrammarPoolWrapper;
 116 
 117     /**
 118      * Indicates whether implementation parts should use
 119      *   service loader (or similar).
 120      * Note the default value (false) is the safe option..
 121      */
 122     private final boolean fUseServicesMechanism;


 123     public XMLSchemaFactory() {
 124         this(true);
 125     }
 126     public static XMLSchemaFactory newXMLSchemaFactoryNoServiceLoader() {
 127         return new XMLSchemaFactory(false);
 128     }
 129     private XMLSchemaFactory(boolean useServicesMechanism) {
 130         fUseServicesMechanism = useServicesMechanism;
 131         fErrorHandlerWrapper = new ErrorHandlerWrapper(DraconianErrorHandler.getInstance());
 132         fDOMEntityResolverWrapper = new DOMEntityResolverWrapper();
 133         fXMLGrammarPoolWrapper = new XMLGrammarPoolWrapper();
 134         fXMLSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, true);
 135         fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper);
 136         fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper);
 137         fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper);
 138 
 139         // Enable secure processing feature by default
 140         fSecurityManager = new SecurityManager();
 141         fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
 142 
 143         //by default, the secure feature is set to true, otherwise the default would have been 'file'
 144         String accessExternal = SecuritySupport.getDefaultAccessProperty(
 145                 Constants.SP_ACCESS_EXTERNAL_DTD, Constants.EXTERNAL_ACCESS_DEFAULT);
 146         fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_DTD, accessExternal);
 147         accessExternal = SecuritySupport.getDefaultAccessProperty(
 148                 Constants.SP_ACCESS_EXTERNAL_SCHEMA, Constants.EXTERNAL_ACCESS_DEFAULT);
 149         fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_SCHEMA, accessExternal);
 150     }
 151 
 152     /**
 153      * <p>Is specified schema supported by this <code>SchemaFactory</code>?</p>
 154      *
 155      * @param schemaLanguage Specifies the schema language which the returned <code>SchemaFactory</code> will understand.
 156      *    <code>schemaLanguage</code> must specify a <a href="#schemaLanguage">valid</a> schema language.
 157      *
 158      * @return <code>true</code> if <code>SchemaFactory</code> supports <code>schemaLanguage</code>, else <code>false</code>.
 159      *
 160      * @throws NullPointerException If <code>schemaLanguage</code> is <code>null</code>.
 161      * @throws IllegalArgumentException If <code>schemaLanguage.length() == 0</code>
 162      *   or <code>schemaLanguage</code> does not specify a <a href="#schemaLanguage">valid</a> schema language.
 163      */
 164     public boolean isSchemaLanguageSupported(String schemaLanguage) {
 165         if (schemaLanguage == null) {
 166             throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 167                     "SchemaLanguageNull", null));
 168         }
 169         if (schemaLanguage.length() == 0) {


 265             throw se; // and we must throw it.
 266         }
 267 
 268         // Clear reference to grammar pool.
 269         fXMLGrammarPoolWrapper.setGrammarPool(null);
 270 
 271         // Select Schema implementation based on grammar count.
 272         final int grammarCount = pool.getGrammarCount();
 273         AbstractXMLSchema schema = null;
 274         if (grammarCount > 1) {
 275             schema = new XMLSchema(new ReadOnlyGrammarPool(pool));
 276         }
 277         else if (grammarCount == 1) {
 278             Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
 279             schema = new SimpleXMLSchema(grammars[0]);
 280         }
 281         else {
 282             schema = new EmptyXMLSchema();
 283         }
 284         propagateFeatures(schema);

 285         return schema;
 286     }
 287 
 288     public Schema newSchema() throws SAXException {
 289         // Use a Schema that uses the system id as the equality source.
 290         AbstractXMLSchema schema = new WeakReferenceXMLSchema();
 291         propagateFeatures(schema);
 292         propagateProperties(schema);
 293         return schema;
 294     }
 295 
 296     public boolean getFeature(String name)
 297         throws SAXNotRecognizedException, SAXNotSupportedException {
 298         if (name == null) {
 299             throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 300                     "FeatureNameNull", null));
 301         }
 302         if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
 303             return (fSecurityManager != null);
 304         }


 349                         SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 350                         "property-not-supported", new Object [] {identifier}));
 351             }
 352         }
 353     }
 354 
 355     public void setFeature(String name, boolean value)
 356         throws SAXNotRecognizedException, SAXNotSupportedException {
 357         if (name == null) {
 358             throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 359                     "FeatureNameNull", null));
 360         }
 361         if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
 362             if (System.getSecurityManager() != null && (!value)) {
 363                 throw new SAXNotSupportedException(
 364                         SAXMessageFormatter.formatMessage(null,
 365                         "jaxp-secureprocessing-feature", null));
 366             }
 367             if (value) {
 368                 fSecurityManager = new SecurityManager();
 369                 fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_DTD, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
 370                 fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_SCHEMA, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);





 371             } else {
 372                 fSecurityManager = null;
 373             }
 374 
 375             fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
 376             return;
 377         } else if (name.equals(Constants.ORACLE_FEATURE_SERVICE_MECHANISM)) {
 378             //in secure mode, let _useServicesMechanism be determined by the constructor
 379             if (System.getSecurityManager() != null)
 380                 return;
 381         }
 382         try {
 383             fXMLSchemaLoader.setFeature(name, value);
 384         }
 385         catch (XMLConfigurationException e) {
 386             String identifier = e.getIdentifier();
 387             if (e.getType() == Status.NOT_RECOGNIZED) {
 388                 throw new SAXNotRecognizedException(
 389                         SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 390                         "feature-not-recognized", new Object [] {identifier}));


 397         }
 398     }
 399 
 400     public void setProperty(String name, Object object)
 401         throws SAXNotRecognizedException, SAXNotSupportedException {
 402         if (name == null) {
 403             throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 404                     "ProperyNameNull", null));
 405         }
 406         if (name.equals(SECURITY_MANAGER)) {
 407             fSecurityManager = (SecurityManager) object;
 408             fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
 409             return;
 410         }
 411         else if (name.equals(XMLGRAMMAR_POOL)) {
 412             throw new SAXNotSupportedException(
 413                     SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 414                     "property-not-supported", new Object [] {name}));
 415         }
 416         try {





 417             fXMLSchemaLoader.setProperty(name, object);
 418         }

 419         catch (XMLConfigurationException e) {
 420             String identifier = e.getIdentifier();
 421             if (e.getType() == Status.NOT_RECOGNIZED) {
 422                 throw new SAXNotRecognizedException(
 423                         SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 424                         "property-not-recognized", new Object [] {identifier}));
 425             }
 426             else {
 427                 throw new SAXNotSupportedException(
 428                         SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 429                         "property-not-supported", new Object [] {identifier}));
 430             }
 431         }
 432     }
 433 
 434     private void propagateFeatures(AbstractXMLSchema schema) {
 435         schema.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, fSecurityManager != null);
 436         schema.setFeature(Constants.ORACLE_FEATURE_SERVICE_MECHANISM, fUseServicesMechanism);
 437         String[] features = fXMLSchemaLoader.getRecognizedFeatures();
 438         for (int i = 0; i < features.length; ++i) {




  28 import javax.xml.stream.XMLEventReader;
  29 import javax.xml.transform.Source;
  30 import javax.xml.transform.dom.DOMSource;
  31 import javax.xml.transform.sax.SAXSource;
  32 import javax.xml.transform.stax.StAXSource;
  33 import javax.xml.transform.stream.StreamSource;
  34 import javax.xml.validation.Schema;
  35 import javax.xml.validation.SchemaFactory;
  36 
  37 import com.sun.org.apache.xerces.internal.impl.Constants;
  38 import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader;
  39 import com.sun.org.apache.xerces.internal.util.DOMEntityResolverWrapper;
  40 import com.sun.org.apache.xerces.internal.util.DOMInputSource;
  41 import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
  42 import com.sun.org.apache.xerces.internal.util.SAXInputSource;
  43 import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
  44 import com.sun.org.apache.xerces.internal.util.SecurityManager;
  45 import com.sun.org.apache.xerces.internal.util.StAXInputSource;
  46 import com.sun.org.apache.xerces.internal.util.Status;
  47 import com.sun.org.apache.xerces.internal.util.XMLGrammarPoolImpl;
  48 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
  49 import com.sun.org.apache.xerces.internal.xni.XNIException;
  50 import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
  51 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
  52 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
  53 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
  54 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
  55 import org.w3c.dom.Node;
  56 import org.w3c.dom.ls.LSResourceResolver;
  57 import org.xml.sax.ErrorHandler;
  58 import org.xml.sax.InputSource;
  59 import org.xml.sax.SAXException;
  60 import org.xml.sax.SAXNotRecognizedException;
  61 import org.xml.sax.SAXNotSupportedException;
  62 import org.xml.sax.SAXParseException;
  63 
  64 /**
  65  * {@link SchemaFactory} for XML Schema.
  66  *
  67  * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
  68  * @version $Id: XMLSchemaFactory.java,v 1.11 2010-11-01 04:40:08 joehw Exp $
  69  */
  70 public final class XMLSchemaFactory extends SchemaFactory {
  71 
  72     // property identifiers
  73 
  74     /** Feature identifier: schema full checking. */
  75     private static final String SCHEMA_FULL_CHECKING =
  76         Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
  77 
  78     /** Property identifier: grammar pool. */
  79     private static final String XMLGRAMMAR_POOL =
  80         Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
  81 
  82     /** Property identifier: SecurityManager. */
  83     private static final String SECURITY_MANAGER =
  84         Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
  85 
  86     /** Property identifier: Security property manager. */
  87     private static final String XML_SECURITY_PROPERTY_MANAGER =
  88             Constants.XML_SECURITY_PROPERTY_MANAGER;
  89 


  90 
  91     //
  92     // Data
  93     //
  94 
  95     /** The XMLSchemaLoader */
  96     private final XMLSchemaLoader fXMLSchemaLoader = new XMLSchemaLoader();
  97 
  98     /** User-specified ErrorHandler; can be null. */
  99     private ErrorHandler fErrorHandler;
 100 
 101     /** The LSResrouceResolver */
 102     private LSResourceResolver fLSResourceResolver;
 103 
 104     /** The DOMEntityResolverWrapper */
 105     private final DOMEntityResolverWrapper fDOMEntityResolverWrapper;
 106 
 107     /** The ErrorHandlerWrapper */
 108     private ErrorHandlerWrapper fErrorHandlerWrapper;
 109 
 110     /** The SecurityManager. */
 111     private SecurityManager fSecurityManager;
 112 
 113     /** The Security property manager. */
 114     private XMLSecurityPropertyManager fSecurityPropertyMgr;
 115 
 116     /** The container for the real grammar pool. */
 117     private XMLGrammarPoolWrapper fXMLGrammarPoolWrapper;
 118 
 119     /**
 120      * Indicates whether implementation parts should use
 121      *   service loader (or similar).
 122      * Note the default value (false) is the safe option..
 123      */
 124     private final boolean fUseServicesMechanism;
 125     
 126     
 127     public XMLSchemaFactory() {
 128         this(true);
 129     }
 130     public static XMLSchemaFactory newXMLSchemaFactoryNoServiceLoader() {
 131         return new XMLSchemaFactory(false);
 132     }
 133     private XMLSchemaFactory(boolean useServicesMechanism) {
 134         fUseServicesMechanism = useServicesMechanism;
 135         fErrorHandlerWrapper = new ErrorHandlerWrapper(DraconianErrorHandler.getInstance());
 136         fDOMEntityResolverWrapper = new DOMEntityResolverWrapper();
 137         fXMLGrammarPoolWrapper = new XMLGrammarPoolWrapper();
 138         fXMLSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, true);
 139         fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper);
 140         fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper);
 141         fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper);
 142 
 143         // Enable secure processing feature by default
 144         fSecurityManager = new SecurityManager();
 145         fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
 146 
 147         fSecurityPropertyMgr = new XMLSecurityPropertyManager();
 148         fXMLSchemaLoader.setProperty(XML_SECURITY_PROPERTY_MANAGER,
 149                 fSecurityPropertyMgr);




 150     }
 151 
 152     /**
 153      * <p>Is specified schema supported by this <code>SchemaFactory</code>?</p>
 154      *
 155      * @param schemaLanguage Specifies the schema language which the returned <code>SchemaFactory</code> will understand.
 156      *    <code>schemaLanguage</code> must specify a <a href="#schemaLanguage">valid</a> schema language.
 157      *
 158      * @return <code>true</code> if <code>SchemaFactory</code> supports <code>schemaLanguage</code>, else <code>false</code>.
 159      *
 160      * @throws NullPointerException If <code>schemaLanguage</code> is <code>null</code>.
 161      * @throws IllegalArgumentException If <code>schemaLanguage.length() == 0</code>
 162      *   or <code>schemaLanguage</code> does not specify a <a href="#schemaLanguage">valid</a> schema language.
 163      */
 164     public boolean isSchemaLanguageSupported(String schemaLanguage) {
 165         if (schemaLanguage == null) {
 166             throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 167                     "SchemaLanguageNull", null));
 168         }
 169         if (schemaLanguage.length() == 0) {


 265             throw se; // and we must throw it.
 266         }
 267 
 268         // Clear reference to grammar pool.
 269         fXMLGrammarPoolWrapper.setGrammarPool(null);
 270 
 271         // Select Schema implementation based on grammar count.
 272         final int grammarCount = pool.getGrammarCount();
 273         AbstractXMLSchema schema = null;
 274         if (grammarCount > 1) {
 275             schema = new XMLSchema(new ReadOnlyGrammarPool(pool));
 276         }
 277         else if (grammarCount == 1) {
 278             Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
 279             schema = new SimpleXMLSchema(grammars[0]);
 280         }
 281         else {
 282             schema = new EmptyXMLSchema();
 283         }
 284         propagateFeatures(schema);
 285         propagateProperties(schema);
 286         return schema;
 287     }
 288 
 289     public Schema newSchema() throws SAXException {
 290         // Use a Schema that uses the system id as the equality source.
 291         AbstractXMLSchema schema = new WeakReferenceXMLSchema();
 292         propagateFeatures(schema);
 293         propagateProperties(schema);
 294         return schema;
 295     }
 296 
 297     public boolean getFeature(String name)
 298         throws SAXNotRecognizedException, SAXNotSupportedException {
 299         if (name == null) {
 300             throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 301                     "FeatureNameNull", null));
 302         }
 303         if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
 304             return (fSecurityManager != null);
 305         }


 350                         SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 351                         "property-not-supported", new Object [] {identifier}));
 352             }
 353         }
 354     }
 355 
 356     public void setFeature(String name, boolean value)
 357         throws SAXNotRecognizedException, SAXNotSupportedException {
 358         if (name == null) {
 359             throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 360                     "FeatureNameNull", null));
 361         }
 362         if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
 363             if (System.getSecurityManager() != null && (!value)) {
 364                 throw new SAXNotSupportedException(
 365                         SAXMessageFormatter.formatMessage(null,
 366                         "jaxp-secureprocessing-feature", null));
 367             }
 368             if (value) {
 369                 fSecurityManager = new SecurityManager();
 370 
 371                 if (Constants.IS_JDK8_OR_ABOVE) {
 372                     fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD, 
 373                             XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
 374                     fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA, 
 375                             XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
 376                 }
 377             } else {
 378                 fSecurityManager = null;
 379             }
 380 
 381             fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
 382             return;
 383         } else if (name.equals(Constants.ORACLE_FEATURE_SERVICE_MECHANISM)) {
 384             //in secure mode, let _useServicesMechanism be determined by the constructor
 385             if (System.getSecurityManager() != null)
 386                 return;
 387         }
 388         try {
 389             fXMLSchemaLoader.setFeature(name, value);
 390         }
 391         catch (XMLConfigurationException e) {
 392             String identifier = e.getIdentifier();
 393             if (e.getType() == Status.NOT_RECOGNIZED) {
 394                 throw new SAXNotRecognizedException(
 395                         SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 396                         "feature-not-recognized", new Object [] {identifier}));


 403         }
 404     }
 405 
 406     public void setProperty(String name, Object object)
 407         throws SAXNotRecognizedException, SAXNotSupportedException {
 408         if (name == null) {
 409             throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 410                     "ProperyNameNull", null));
 411         }
 412         if (name.equals(SECURITY_MANAGER)) {
 413             fSecurityManager = (SecurityManager) object;
 414             fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
 415             return;
 416         }
 417         else if (name.equals(XMLGRAMMAR_POOL)) {
 418             throw new SAXNotSupportedException(
 419                     SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 420                     "property-not-supported", new Object [] {name}));
 421         }
 422         try {
 423             int index = fSecurityPropertyMgr.getIndex(name);
 424             if (index > -1) {
 425                 fSecurityPropertyMgr.setValue(index, 
 426                         XMLSecurityPropertyManager.State.APIPROPERTY, (String)object);                    
 427             } else {
 428                 fXMLSchemaLoader.setProperty(name, object);
 429             }
 430         }
 431         catch (XMLConfigurationException e) {
 432             String identifier = e.getIdentifier();
 433             if (e.getType() == Status.NOT_RECOGNIZED) {
 434                 throw new SAXNotRecognizedException(
 435                         SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 436                         "property-not-recognized", new Object [] {identifier}));
 437             }
 438             else {
 439                 throw new SAXNotSupportedException(
 440                         SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
 441                         "property-not-supported", new Object [] {identifier}));
 442             }
 443         }
 444     }
 445 
 446     private void propagateFeatures(AbstractXMLSchema schema) {
 447         schema.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, fSecurityManager != null);
 448         schema.setFeature(Constants.ORACLE_FEATURE_SERVICE_MECHANISM, fUseServicesMechanism);
 449         String[] features = fXMLSchemaLoader.getRecognizedFeatures();
 450         for (int i = 0; i < features.length; ++i) {