jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
changeset 18890 25bdeca3173b
parent 17645 d2f0e76ff056
child 20967 d3f1925927e5
equal deleted inserted replaced
18675:711eb4aa87de 18890:25bdeca3173b
    29 import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
    29 import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
    30 import com.sun.org.apache.xerces.internal.util.*;
    30 import com.sun.org.apache.xerces.internal.util.*;
    31 import com.sun.org.apache.xerces.internal.util.SecurityManager;
    31 import com.sun.org.apache.xerces.internal.util.SecurityManager;
    32 import com.sun.org.apache.xerces.internal.util.URI;
    32 import com.sun.org.apache.xerces.internal.util.URI;
    33 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
    33 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
       
    34 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
    34 import com.sun.org.apache.xerces.internal.xni.Augmentations;
    35 import com.sun.org.apache.xerces.internal.xni.Augmentations;
    35 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
    36 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
    36 import com.sun.org.apache.xerces.internal.xni.XNIException;
    37 import com.sun.org.apache.xerces.internal.xni.XNIException;
    37 import com.sun.org.apache.xerces.internal.xni.parser.*;
    38 import com.sun.org.apache.xerces.internal.xni.parser.*;
    38 import com.sun.xml.internal.stream.Entity;
    39 import com.sun.xml.internal.stream.Entity;
   164         Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
   165         Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
   165 
   166 
   166     protected static final String PARSER_SETTINGS =
   167     protected static final String PARSER_SETTINGS =
   167         Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
   168         Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
   168 
   169 
   169     /** property identifier: access external dtd. */
   170     /** Property identifier: Security property manager. */
   170     protected static final String ACCESS_EXTERNAL_DTD = XMLConstants.ACCESS_EXTERNAL_DTD;
   171     private static final String XML_SECURITY_PROPERTY_MANAGER =
       
   172             Constants.XML_SECURITY_PROPERTY_MANAGER;
   171 
   173 
   172     /** access external dtd: file protocol */
   174     /** access external dtd: file protocol */
   173     static final String EXTERNAL_ACCESS_DEFAULT = Constants.EXTERNAL_ACCESS_DEFAULT;
   175     static final String EXTERNAL_ACCESS_DEFAULT = Constants.EXTERNAL_ACCESS_DEFAULT;
   174 
   176 
   175 
   177 
   201                 ERROR_REPORTER,
   203                 ERROR_REPORTER,
   202                 ENTITY_RESOLVER,
   204                 ENTITY_RESOLVER,
   203                 VALIDATION_MANAGER,
   205                 VALIDATION_MANAGER,
   204                 BUFFER_SIZE,
   206                 BUFFER_SIZE,
   205                 SECURITY_MANAGER,
   207                 SECURITY_MANAGER,
   206                 ACCESS_EXTERNAL_DTD
   208                 XML_SECURITY_PROPERTY_MANAGER
   207     };
   209     };
   208 
   210 
   209     /** Property defaults. */
   211     /** Property defaults. */
   210     private static final Object[] PROPERTY_DEFAULTS = {
   212     private static final Object[] PROPERTY_DEFAULTS = {
   211                 null,
   213                 null,
   212                 null,
   214                 null,
   213                 null,
   215                 null,
   214                 null,
   216                 null,
   215                 new Integer(DEFAULT_BUFFER_SIZE),
   217                 new Integer(DEFAULT_BUFFER_SIZE),
   216                 null,
   218                 null,
   217                 EXTERNAL_ACCESS_DEFAULT
   219                 null
   218     };
   220     };
   219 
   221 
   220     private static final String XMLEntity = "[xml]".intern();
   222     private static final String XMLEntity = "[xml]".intern();
   221     private static final String DTDEntity = "[dtd]".intern();
   223     private static final String DTDEntity = "[dtd]".intern();
   222 
   224 
  1419 
  1421 
  1420         // Zephyr feature ignore-external-dtd is the opposite of Xerces' load-external-dtd
  1422         // Zephyr feature ignore-external-dtd is the opposite of Xerces' load-external-dtd
  1421         fLoadExternalDTD = !((Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.IGNORE_EXTERNAL_DTD)).booleanValue();
  1423         fLoadExternalDTD = !((Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.IGNORE_EXTERNAL_DTD)).booleanValue();
  1422 
  1424 
  1423         // JAXP 1.5 feature
  1425         // JAXP 1.5 feature
  1424         fAccessExternalDTD = (String) propertyManager.getProperty(ACCESS_EXTERNAL_DTD);
  1426         XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager) propertyManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
       
  1427         fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
  1425 
  1428 
  1426         // initialize state
  1429         // initialize state
  1427         //fStandalone = false;
  1430         //fStandalone = false;
  1428         fEntities.clear();
  1431         fEntities.clear();
  1429         fEntityStack.removeAllElements();
  1432         fEntityStack.removeAllElements();
  1483         fStaxEntityResolver = (StaxEntityResolverWrapper)componentManager.getProperty(STAX_ENTITY_RESOLVER, null);
  1486         fStaxEntityResolver = (StaxEntityResolverWrapper)componentManager.getProperty(STAX_ENTITY_RESOLVER, null);
  1484         fValidationManager = (ValidationManager)componentManager.getProperty(VALIDATION_MANAGER, null);
  1487         fValidationManager = (ValidationManager)componentManager.getProperty(VALIDATION_MANAGER, null);
  1485         fSecurityManager = (SecurityManager)componentManager.getProperty(SECURITY_MANAGER, null);
  1488         fSecurityManager = (SecurityManager)componentManager.getProperty(SECURITY_MANAGER, null);
  1486 
  1489 
  1487         // JAXP 1.5 feature
  1490         // JAXP 1.5 feature
  1488         fAccessExternalDTD = (String) componentManager.getProperty(ACCESS_EXTERNAL_DTD, EXTERNAL_ACCESS_DEFAULT);
  1491         XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager) componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER, null);
       
  1492         if (spm == null) {
       
  1493             spm = new XMLSecurityPropertyManager();
       
  1494         }
       
  1495         fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
  1489 
  1496 
  1490         //reset general state
  1497         //reset general state
  1491         reset();
  1498         reset();
  1492 
  1499 
  1493         fEntityScanner.reset(componentManager);
  1500         fEntityScanner.reset(componentManager);
  1639                 fEntityExpansionLimit = (fSecurityManager != null)?fSecurityManager.getEntityExpansionLimit():0;
  1646                 fEntityExpansionLimit = (fSecurityManager != null)?fSecurityManager.getEntityExpansionLimit():0;
  1640             }
  1647             }
  1641         }
  1648         }
  1642 
  1649 
  1643         //JAXP 1.5 properties
  1650         //JAXP 1.5 properties
  1644         if (propertyId.startsWith(Constants.JAXPAPI_PROPERTY_PREFIX)) {
  1651         if (propertyId.equals(XML_SECURITY_PROPERTY_MANAGER))
  1645             if (propertyId.equals(ACCESS_EXTERNAL_DTD))
  1652         {
  1646             {
  1653             XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)value;
  1647                 fAccessExternalDTD = (String)value;
  1654             fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
  1648             }
       
  1649         }
  1655         }
  1650     }
  1656     }
  1651 
  1657 
  1652     /**
  1658     /**
  1653      * Returns a list of property identifiers that are recognized by
  1659      * Returns a list of property identifiers that are recognized by