Use SecuritySupport when looking up org.xml.sax.parser system property.

git-svn-id: https://svn.apache.org/repos/asf/xml/commons/trunk@226253 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
mrglavas 2005-06-22 02:20:47 +00:00
parent e37ca1b076
commit fe0e541d42

View File

@ -1,19 +1,12 @@
// SAX parser factory. //SAX parser factory.
// http://www.saxproject.org //http://www.saxproject.org
// No warranty; no copyright -- use this as you will. //No warranty; no copyright -- use this as you will.
// $Id$ //$Id$
package org.xml.sax.helpers; package org.xml.sax.helpers;
import java.lang.ClassNotFoundException;
import java.lang.IllegalAccessException;
import java.lang.InstantiationException;
import java.lang.SecurityException;
import java.lang.ClassCastException;
import org.xml.sax.Parser; import org.xml.sax.Parser;
/** /**
* Java-specific class for dynamically loading SAX parsers. * Java-specific class for dynamically loading SAX parsers.
* *
@ -79,18 +72,19 @@ public class ParserFactory {
* @see org.xml.sax.Parser * @see org.xml.sax.Parser
*/ */
public static Parser makeParser () public static Parser makeParser ()
throws ClassNotFoundException, throws ClassNotFoundException,
IllegalAccessException, IllegalAccessException,
InstantiationException, InstantiationException,
NullPointerException, NullPointerException,
ClassCastException ClassCastException
{ {
String className = System.getProperty("org.xml.sax.parser"); SecuritySupport ss = SecuritySupport.getInstance();
if (className == null) { String className = ss.getSystemProperty("org.xml.sax.parser");
throw new NullPointerException("No value for sax.parser property"); if (className == null) {
} else { throw new NullPointerException("No value for sax.parser property");
return makeParser(className); } else {
} return makeParser(className);
}
} }
@ -116,13 +110,13 @@ public class ParserFactory {
* @see org.xml.sax.Parser * @see org.xml.sax.Parser
*/ */
public static Parser makeParser (String className) public static Parser makeParser (String className)
throws ClassNotFoundException, throws ClassNotFoundException,
IllegalAccessException, IllegalAccessException,
InstantiationException, InstantiationException,
ClassCastException ClassCastException
{ {
return (Parser) NewInstance.newInstance ( return (Parser) NewInstance.newInstance (
NewInstance.getClassLoader (), className); NewInstance.getClassLoader (), className);
} }
} }