27 import com.sun.org.apache.xerces.internal.util.EntityResolver2Wrapper; |
27 import com.sun.org.apache.xerces.internal.util.EntityResolver2Wrapper; |
28 import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper; |
28 import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper; |
29 import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter; |
29 import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter; |
30 import com.sun.org.apache.xerces.internal.util.Status; |
30 import com.sun.org.apache.xerces.internal.util.Status; |
31 import com.sun.org.apache.xerces.internal.util.SymbolTable; |
31 import com.sun.org.apache.xerces.internal.util.SymbolTable; |
|
32 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager; |
32 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager; |
33 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager; |
33 import com.sun.org.apache.xerces.internal.xni.XNIException; |
34 import com.sun.org.apache.xerces.internal.xni.XNIException; |
34 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; |
35 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; |
35 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; |
36 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; |
36 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; |
37 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; |
529 * requested property is known, but the requested |
530 * requested property is known, but the requested |
530 * value is not supported. |
531 * value is not supported. |
531 */ |
532 */ |
532 public void setProperty(String propertyId, Object value) |
533 public void setProperty(String propertyId, Object value) |
533 throws SAXNotRecognizedException, SAXNotSupportedException { |
534 throws SAXNotRecognizedException, SAXNotSupportedException { |
534 |
535 /** |
|
536 * It's possible for users to set a security manager through the interface. |
|
537 * If it's the old SecurityManager, convert it to the new XMLSecurityManager |
|
538 */ |
|
539 if (propertyId.equals(Constants.SECURITY_MANAGER)) { |
|
540 securityManager = XMLSecurityManager.convert(value, securityManager); |
|
541 setProperty0(Constants.SECURITY_MANAGER, securityManager); |
|
542 return; |
|
543 } |
|
544 if (propertyId.equals(Constants.XML_SECURITY_PROPERTY_MANAGER)) { |
|
545 if (value == null) { |
|
546 securityPropertyManager = new XMLSecurityPropertyManager(); |
|
547 } else { |
|
548 securityPropertyManager = (XMLSecurityPropertyManager)value; |
|
549 } |
|
550 setProperty0(Constants.XML_SECURITY_PROPERTY_MANAGER, securityPropertyManager); |
|
551 return; |
|
552 } |
|
553 |
|
554 if (securityManager == null) { |
|
555 securityManager = new XMLSecurityManager(true); |
|
556 setProperty0(Constants.SECURITY_MANAGER, securityManager); |
|
557 } |
|
558 |
|
559 if (securityPropertyManager == null) { |
|
560 securityPropertyManager = new XMLSecurityPropertyManager(); |
|
561 setProperty0(Constants.XML_SECURITY_PROPERTY_MANAGER, securityPropertyManager); |
|
562 } |
|
563 int index = securityPropertyManager.getIndex(propertyId); |
|
564 |
|
565 if (index > -1) { |
|
566 /** |
|
567 * this is a direct call to this parser, not a subclass since |
|
568 * internally the support of this property is done through |
|
569 * XMLSecurityPropertyManager |
|
570 */ |
|
571 securityPropertyManager.setValue(index, XMLSecurityPropertyManager.State.APIPROPERTY, (String)value); |
|
572 } else { |
|
573 //check if the property is managed by security manager |
|
574 if (!securityManager.setLimit(propertyId, XMLSecurityManager.State.APIPROPERTY, value)) { |
|
575 //fall back to the default configuration to handle the property |
|
576 setProperty0(propertyId, value); |
|
577 } |
|
578 } |
|
579 } |
|
580 |
|
581 public void setProperty0(String propertyId, Object value) |
|
582 throws SAXNotRecognizedException, SAXNotSupportedException { |
535 try { |
583 try { |
536 fConfiguration.setProperty(propertyId, value); |
584 fConfiguration.setProperty(propertyId, value); |
537 } |
585 } |
538 catch (XMLConfigurationException e) { |
586 catch (XMLConfigurationException e) { |
539 String identifier = e.getIdentifier(); |
587 String identifier = e.getIdentifier(); |