Return-Path: Delivered-To: apmail-xml-commons-cvs-archive@www.apache.org Received: (qmail 35100 invoked from network); 23 Jul 2006 17:28:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 23 Jul 2006 17:28:16 -0000 Received: (qmail 67517 invoked by uid 500); 23 Jul 2006 17:28:16 -0000 Delivered-To: apmail-xml-commons-cvs-archive@xml.apache.org Received: (qmail 67495 invoked by uid 500); 23 Jul 2006 17:28:16 -0000 Mailing-List: contact commons-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list commons-cvs@xml.apache.org Received: (qmail 67482 invoked by uid 99); 23 Jul 2006 17:28:16 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Jul 2006 10:28:16 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Jul 2006 10:28:14 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id E527A1A981A; Sun, 23 Jul 2006 10:27:53 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r424770 - in /xml/commons/trunk/java/external/src/javax/xml: datatype/ parsers/ transform/ validation/ xpath/ Date: Sun, 23 Jul 2006 17:27:51 -0000 To: commons-cvs@xml.apache.org From: mrglavas@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060723172753.E527A1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: mrglavas Date: Sun Jul 23 10:27:51 2006 New Revision: 424770 URL: http://svn.apache.org/viewvc?rev=424770&view=rev Log: Several improvements to the SecuritySupport and FactoryFinder classes: - Make all SecuritySupport methods static. - Mark all of the SecuritySupport and FactoryFinder classes as final - Prevent instantiation of the SecuritySupport and FactoryFinder classes Modified: xml/commons/trunk/java/external/src/javax/xml/datatype/FactoryFinder.java xml/commons/trunk/java/external/src/javax/xml/datatype/SecuritySupport.java xml/commons/trunk/java/external/src/javax/xml/parsers/FactoryFinder.java xml/commons/trunk/java/external/src/javax/xml/parsers/SecuritySupport.java xml/commons/trunk/java/external/src/javax/xml/transform/FactoryFinder.java xml/commons/trunk/java/external/src/javax/xml/transform/SecuritySupport.java xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactory.java xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactoryFinder.java xml/commons/trunk/java/external/src/javax/xml/validation/SecuritySupport.java xml/commons/trunk/java/external/src/javax/xml/xpath/SecuritySupport.java xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactory.java xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactoryFinder.java Modified: xml/commons/trunk/java/external/src/javax/xml/datatype/FactoryFinder.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/datatype/FactoryFinder.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/datatype/FactoryFinder.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/datatype/FactoryFinder.java Sun Jul 23 10:27:51 2006 @@ -36,7 +36,7 @@ * @version $Revision$, $Date$ * @since 1.5 */ -class FactoryFinder { +final class FactoryFinder { /** *

Name of class to display in output messages.

@@ -59,11 +59,6 @@ private static boolean firstTime = true; /** - *

Take care of restrictions imposed by java security model

- */ - private static SecuritySupport ss = new SecuritySupport(); - - /** * Default columns per line. */ private static final int DEFAULT_LINE_LENGTH = 80; @@ -77,11 +72,13 @@ */ static { try { - debug = ss.getSystemProperty("jaxp.debug") != null; + debug = SecuritySupport.getSystemProperty("jaxp.debug") != null; } catch (Exception x) { ; // NOP, ignore exception } } + + private FactoryFinder() {} /** *

Output debugging messages.

@@ -113,7 +110,7 @@ // Figure out which ClassLoader to use for loading the provider // class. If there is a Context ClassLoader then use it. - classLoader = ss.getContextClassLoader(); + classLoader = SecuritySupport.getContextClassLoader(); if (debug) debugPrintln( "Using context class loader: " @@ -188,7 +185,7 @@ // Use the system property first try { - String systemProp = ss.getSystemProperty(factoryId); + String systemProp = SecuritySupport.getSystemProperty(factoryId); if (systemProp != null) { if (debug) debugPrintln("found " + systemProp + " in the system property " + factoryId); return newInstance(systemProp, classLoader); @@ -199,7 +196,7 @@ // try to read from $java.home/lib/jaxp.properties try { - String javah = ss.getSystemProperty("java.home"); + String javah = SecuritySupport.getSystemProperty("java.home"); String configFile = javah + File.separator + "lib" + File.separator + "jaxp.properties"; String factoryClassName = null; if (firstTime) { @@ -207,9 +204,9 @@ if (firstTime) { File f = new File(configFile); firstTime = false; - if (ss.doesFileExist(f)) { + if (SecuritySupport.doesFileExist(f)) { if (debug) debugPrintln("Read properties file " + f); - cacheProps.load(ss.getFileInputStream(f)); + cacheProps.load(SecuritySupport.getFileInputStream(f)); } } } @@ -254,20 +251,20 @@ InputStream is = null; // First try the Context ClassLoader - ClassLoader cl = ss.getContextClassLoader(); + ClassLoader cl = SecuritySupport.getContextClassLoader(); if (cl != null) { - is = ss.getResourceAsStream(cl, serviceId); + is = SecuritySupport.getResourceAsStream(cl, serviceId); // If no provider found then try the current ClassLoader if (is == null) { cl = FactoryFinder.class.getClassLoader(); - is = ss.getResourceAsStream(cl, serviceId); + is = SecuritySupport.getResourceAsStream(cl, serviceId); } } else { // No Context ClassLoader, try the current // ClassLoader cl = FactoryFinder.class.getClassLoader(); - is = ss.getResourceAsStream(cl, serviceId); + is = SecuritySupport.getResourceAsStream(cl, serviceId); } if (is == null) { Modified: xml/commons/trunk/java/external/src/javax/xml/datatype/SecuritySupport.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/datatype/SecuritySupport.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/datatype/SecuritySupport.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/datatype/SecuritySupport.java Sun Jul 23 10:27:51 2006 @@ -34,10 +34,11 @@ * * Security related methods that only work on J2SE 1.2 and newer. */ -class SecuritySupport { - +final class SecuritySupport { + + private SecuritySupport() {} - ClassLoader getContextClassLoader() { + static ClassLoader getContextClassLoader() { return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -50,7 +51,7 @@ }); } - String getSystemProperty(final String propName) { + static String getSystemProperty(final String propName) { return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -59,7 +60,7 @@ }); } - FileInputStream getFileInputStream(final File file) + static FileInputStream getFileInputStream(final File file) throws FileNotFoundException { try { @@ -74,7 +75,7 @@ } } - InputStream getResourceAsStream(final ClassLoader cl, + static InputStream getResourceAsStream(final ClassLoader cl, final String name) { return (InputStream) @@ -91,7 +92,7 @@ }); } - boolean doesFileExist(final File f) { + static boolean doesFileExist(final File f) { return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Modified: xml/commons/trunk/java/external/src/javax/xml/parsers/FactoryFinder.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/parsers/FactoryFinder.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/parsers/FactoryFinder.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/parsers/FactoryFinder.java Sun Jul 23 10:27:51 2006 @@ -36,12 +36,12 @@ * since it calls Thread#getContextClassLoader(). The code also runs both * as part of an unbundled jar file and when bundled as part of the JDK. */ -class FactoryFinder { +final class FactoryFinder { + /** Temp debug code - this will be removed after we test everything */ private static boolean debug = false; static Properties cacheProps= new Properties(); - static SecuritySupport ss = new SecuritySupport() ; static boolean firstTime = true; /** @@ -54,7 +54,7 @@ // Use try/catch block to support applets, which throws // SecurityException out of this code. try { - String val = ss.getSystemProperty("jaxp.debug"); + String val = SecuritySupport.getSystemProperty("jaxp.debug"); // Allow simply setting the prop to turn on debug debug = val != null && (! "false".equals(val)); } catch (SecurityException se) { @@ -62,6 +62,7 @@ } } + private FactoryFinder() {} private static void dPrint(String msg) { if (debug) { @@ -147,7 +148,7 @@ // Figure out which ClassLoader to use for loading the provider // class. If there is a Context ClassLoader then use it. - ClassLoader classLoader = ss.getContextClassLoader(); + ClassLoader classLoader = SecuritySupport.getContextClassLoader(); if (classLoader == null) { // if we have no Context ClassLoader @@ -159,7 +160,7 @@ // Use the system property first try { - String systemProp = ss.getSystemProperty(factoryId); + String systemProp = SecuritySupport.getSystemProperty(factoryId); if( systemProp!=null) { if (debug) dPrint("found system property, value=" + systemProp); return newInstance(systemProp, classLoader, true ); @@ -171,7 +172,7 @@ // try to read from $java.home/lib/jaxp.properties try { - String javah = ss.getSystemProperty("java.home"); + String javah = SecuritySupport.getSystemProperty("java.home"); String configFile = javah + File.separator + "lib" + File.separator + "jaxp.properties"; String factoryClassName = null; @@ -180,10 +181,10 @@ if(firstTime){ File f=new File( configFile ); firstTime = false; - if(ss.doesFileExist(f)){ + if(SecuritySupport.doesFileExist(f)){ if (debug) dPrint("Read properties file "+f); //cacheProps.load( new FileInputStream(f)); - cacheProps.load(ss.getFileInputStream(f)); + cacheProps.load(SecuritySupport.getFileInputStream(f)); } } } @@ -225,20 +226,20 @@ InputStream is = null; // First try the Context ClassLoader - ClassLoader cl = ss.getContextClassLoader(); + ClassLoader cl = SecuritySupport.getContextClassLoader(); if (cl != null) { - is = ss.getResourceAsStream(cl, serviceId); + is = SecuritySupport.getResourceAsStream(cl, serviceId); // If no provider found then try the current ClassLoader if (is == null) { cl = FactoryFinder.class.getClassLoader(); - is = ss.getResourceAsStream(cl, serviceId); + is = SecuritySupport.getResourceAsStream(cl, serviceId); } } else { // No Context ClassLoader, try the current // ClassLoader cl = FactoryFinder.class.getClassLoader(); - is = ss.getResourceAsStream(cl, serviceId); + is = SecuritySupport.getResourceAsStream(cl, serviceId); } if (is == null) { Modified: xml/commons/trunk/java/external/src/javax/xml/parsers/SecuritySupport.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/parsers/SecuritySupport.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/parsers/SecuritySupport.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/parsers/SecuritySupport.java Sun Jul 23 10:27:51 2006 @@ -34,10 +34,11 @@ * * Security related methods that only work on J2SE 1.2 and newer. */ -class SecuritySupport { - +final class SecuritySupport { + + private SecuritySupport() {} - ClassLoader getContextClassLoader() { + static ClassLoader getContextClassLoader() { return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -50,7 +51,7 @@ }); } - String getSystemProperty(final String propName) { + static String getSystemProperty(final String propName) { return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -59,7 +60,7 @@ }); } - FileInputStream getFileInputStream(final File file) + static FileInputStream getFileInputStream(final File file) throws FileNotFoundException { try { @@ -74,7 +75,7 @@ } } - InputStream getResourceAsStream(final ClassLoader cl, + static InputStream getResourceAsStream(final ClassLoader cl, final String name) { return (InputStream) @@ -91,7 +92,7 @@ }); } - boolean doesFileExist(final File f) { + static boolean doesFileExist(final File f) { return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Modified: xml/commons/trunk/java/external/src/javax/xml/transform/FactoryFinder.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/transform/FactoryFinder.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/transform/FactoryFinder.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/transform/FactoryFinder.java Sun Jul 23 10:27:51 2006 @@ -36,12 +36,12 @@ * since it calls Thread#getContextClassLoader(). The code also runs both * as part of an unbundled jar file and when bundled as part of the JDK. */ -class FactoryFinder { +final class FactoryFinder { + /** Temp debug code - this will be removed after we test everything */ private static boolean debug = false; static Properties cacheProps= new Properties(); - static SecuritySupport ss = new SecuritySupport() ; static boolean firstTime = true; /** @@ -54,7 +54,7 @@ // Use try/catch block to support applets, which throws // SecurityException out of this code. try { - String val = ss.getSystemProperty("jaxp.debug"); + String val = SecuritySupport.getSystemProperty("jaxp.debug"); // Allow simply setting the prop to turn on debug debug = val != null && (! "false".equals(val)); } catch (SecurityException se) { @@ -62,6 +62,7 @@ } } + private FactoryFinder() {} private static void dPrint(String msg) { if (debug) { @@ -147,7 +148,7 @@ // Figure out which ClassLoader to use for loading the provider // class. If there is a Context ClassLoader then use it. - ClassLoader classLoader = ss.getContextClassLoader(); + ClassLoader classLoader = SecuritySupport.getContextClassLoader(); if (classLoader == null) { // if we have no Context ClassLoader @@ -159,7 +160,7 @@ // Use the system property first try { - String systemProp = ss.getSystemProperty(factoryId); + String systemProp = SecuritySupport.getSystemProperty(factoryId); if( systemProp!=null) { if (debug) dPrint("found system property, value=" + systemProp); return newInstance(systemProp, classLoader, true ); @@ -171,7 +172,7 @@ // try to read from $java.home/lib/jaxp.properties try { - String javah = ss.getSystemProperty("java.home"); + String javah = SecuritySupport.getSystemProperty("java.home"); String configFile = javah + File.separator + "lib" + File.separator + "jaxp.properties"; String factoryClassName = null; @@ -180,10 +181,10 @@ if(firstTime){ File f=new File( configFile ); firstTime = false; - if(ss.doesFileExist(f)){ + if(SecuritySupport.doesFileExist(f)){ if (debug) dPrint("Read properties file "+f); //cacheProps.load( new FileInputStream(f)); - cacheProps.load(ss.getFileInputStream(f)); + cacheProps.load(SecuritySupport.getFileInputStream(f)); } } } @@ -225,20 +226,20 @@ InputStream is = null; // First try the Context ClassLoader - ClassLoader cl = ss.getContextClassLoader(); + ClassLoader cl = SecuritySupport.getContextClassLoader(); if (cl != null) { - is = ss.getResourceAsStream(cl, serviceId); + is = SecuritySupport.getResourceAsStream(cl, serviceId); // If no provider found then try the current ClassLoader if (is == null) { cl = FactoryFinder.class.getClassLoader(); - is = ss.getResourceAsStream(cl, serviceId); + is = SecuritySupport.getResourceAsStream(cl, serviceId); } } else { // No Context ClassLoader, try the current // ClassLoader cl = FactoryFinder.class.getClassLoader(); - is = ss.getResourceAsStream(cl, serviceId); + is = SecuritySupport.getResourceAsStream(cl, serviceId); } if (is == null) { Modified: xml/commons/trunk/java/external/src/javax/xml/transform/SecuritySupport.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/transform/SecuritySupport.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/transform/SecuritySupport.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/transform/SecuritySupport.java Sun Jul 23 10:27:51 2006 @@ -34,10 +34,11 @@ * * Security related methods that only work on J2SE 1.2 and newer. */ -class SecuritySupport { - +final class SecuritySupport { + + private SecuritySupport() {} - ClassLoader getContextClassLoader() { + static ClassLoader getContextClassLoader() { return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -50,7 +51,7 @@ }); } - String getSystemProperty(final String propName) { + static String getSystemProperty(final String propName) { return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -59,7 +60,7 @@ }); } - FileInputStream getFileInputStream(final File file) + static FileInputStream getFileInputStream(final File file) throws FileNotFoundException { try { @@ -74,7 +75,7 @@ } } - InputStream getResourceAsStream(final ClassLoader cl, + static InputStream getResourceAsStream(final ClassLoader cl, final String name) { return (InputStream) @@ -91,7 +92,7 @@ }); } - boolean doesFileExist(final File f) { + static boolean doesFileExist(final File f) { return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Modified: xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactory.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactory.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactory.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactory.java Sun Jul 23 10:27:51 2006 @@ -1,5 +1,5 @@ /* - * Copyright 2003-2004 The Apache Software Foundation. + * Copyright 2003-2004,2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,8 +101,6 @@ * @since 1.5 */ public abstract class SchemaFactory { - - private static SecuritySupport ss = new SecuritySupport(); /** *

Constructor for derived classes.

@@ -182,7 +180,7 @@ */ public static final SchemaFactory newInstance(String schemaLanguage) { ClassLoader cl; - cl = ss.getContextClassLoader(); + cl = SecuritySupport.getContextClassLoader(); if (cl == null) { //cl = ClassLoader.getSystemClassLoader(); Modified: xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactoryFinder.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactoryFinder.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactoryFinder.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactoryFinder.java Sun Jul 23 10:27:51 2006 @@ -36,14 +36,11 @@ * @version $Revision$, $Date$ * @since 1.5 */ -class SchemaFactoryFinder { +final class SchemaFactoryFinder { /** debug support code. */ private static boolean debug = false; - /** - *

Take care of restrictions imposed by java security model

- */ - private static SecuritySupport ss = new SecuritySupport(); + /** *

Cache properties for performance.

*/ @@ -62,7 +59,7 @@ static { // Use try/catch block to support applets try { - debug = ss.getSystemProperty("jaxp.debug") != null; + debug = SecuritySupport.getSystemProperty("jaxp.debug") != null; } catch (Exception _) { debug = false; } @@ -104,7 +101,7 @@ private void debugDisplayClassLoader() { try { - if( classLoader == ss.getContextClassLoader() ) { + if( classLoader == SecuritySupport.getContextClassLoader() ) { debugPrintln("using thread context class loader ("+classLoader+") for search"); return; } @@ -160,7 +157,7 @@ // system property look up try { if (debug) debugPrintln("Looking up system property '"+propertyName+"'" ); - String r = ss.getSystemProperty(propertyName); + String r = SecuritySupport.getSystemProperty(propertyName); if (r != null) { if (debug) debugPrintln("The value is '"+r+"'"); sf = createInstance(r); @@ -176,7 +173,7 @@ } } - String javah = ss.getSystemProperty( "java.home" ); + String javah = SecuritySupport.getSystemProperty( "java.home" ); String configFile = javah + File.separator + "lib" + File.separator + "jaxp.properties"; @@ -189,9 +186,9 @@ if(firstTime){ File f=new File( configFile ); firstTime = false; - if(ss.doesFileExist(f)){ + if(SecuritySupport.doesFileExist(f)){ if (debug) debugPrintln("Read properties file " + f); - cacheProps.load(ss.getFileInputStream(f)); + cacheProps.load(SecuritySupport.getFileInputStream(f)); } } } @@ -239,7 +236,7 @@ URL resource = (URL)sitr.next(); if (debug) debugPrintln("looking into " + resource); try { - sf = loadFromServicesFile(schemaLanguage,resource.toExternalForm(),ss.getURLInputStream(resource)); + sf = loadFromServicesFile(schemaLanguage,resource.toExternalForm(),SecuritySupport.getURLInputStream(resource)); if(sf!=null) return sf; } catch(IOException e) { if( debug ) { @@ -315,13 +312,13 @@ protected Object value() { ClassLoader classLoader = SchemaFactoryFinder.class.getClassLoader(); //return (ClassLoader.getSystemResource( SERVICE_ID )); - return ss.getResourceAsURL(classLoader, SERVICE_ID); + return SecuritySupport.getResourceAsURL(classLoader, SERVICE_ID); } }; } else { try { //final Enumeration e = classLoader.getResources(SERVICE_ID); - final Enumeration e = ss.getResources(classLoader, SERVICE_ID); + final Enumeration e = SecuritySupport.getResources(classLoader, SERVICE_ID); if(debug && !e.hasMoreElements()) { debugPrintln("no "+SERVICE_ID+" file was found"); } @@ -452,7 +449,7 @@ if( loader==null ) loader = ClassLoader.getSystemClassLoader(); //URL it = loader.getResource(classnameAsResource); - URL it = ss.getResourceAsURL(loader, classnameAsResource); + URL it = SecuritySupport.getResourceAsURL(loader, classnameAsResource); if (it != null) { return it.toString(); } else { Modified: xml/commons/trunk/java/external/src/javax/xml/validation/SecuritySupport.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/validation/SecuritySupport.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/validation/SecuritySupport.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/validation/SecuritySupport.java Sun Jul 23 10:27:51 2006 @@ -36,10 +36,11 @@ * * Security related methods that only work on J2SE 1.2 and newer. */ -class SecuritySupport { - +final class SecuritySupport { + + private SecuritySupport() {} - ClassLoader getContextClassLoader() { + static ClassLoader getContextClassLoader() { return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -52,7 +53,7 @@ }); } - String getSystemProperty(final String propName) { + static String getSystemProperty(final String propName) { return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -61,7 +62,7 @@ }); } - FileInputStream getFileInputStream(final File file) + static FileInputStream getFileInputStream(final File file) throws FileNotFoundException { try { @@ -76,7 +77,7 @@ } } - InputStream getURLInputStream(final URL url) + static InputStream getURLInputStream(final URL url) throws IOException { try { @@ -91,8 +92,8 @@ } } - URL getResourceAsURL(final ClassLoader cl, - final String name) + static URL getResourceAsURL(final ClassLoader cl, + final String name) { return (URL) AccessController.doPrivileged(new PrivilegedAction() { @@ -108,8 +109,8 @@ }); } - Enumeration getResources(final ClassLoader cl, - final String name) throws IOException + static Enumeration getResources(final ClassLoader cl, + final String name) throws IOException { try{ return (Enumeration) @@ -129,7 +130,7 @@ } } - InputStream getResourceAsStream(final ClassLoader cl, + static InputStream getResourceAsStream(final ClassLoader cl, final String name) { return (InputStream) @@ -146,7 +147,7 @@ }); } - boolean doesFileExist(final File f) { + static boolean doesFileExist(final File f) { return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Modified: xml/commons/trunk/java/external/src/javax/xml/xpath/SecuritySupport.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/xpath/SecuritySupport.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/xpath/SecuritySupport.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/xpath/SecuritySupport.java Sun Jul 23 10:27:51 2006 @@ -36,10 +36,11 @@ * * Security related methods that only work on J2SE 1.2 and newer. */ -class SecuritySupport { - +final class SecuritySupport { + + private SecuritySupport() {} - ClassLoader getContextClassLoader() { + static ClassLoader getContextClassLoader() { return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -52,7 +53,7 @@ }); } - String getSystemProperty(final String propName) { + static String getSystemProperty(final String propName) { return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -61,7 +62,7 @@ }); } - FileInputStream getFileInputStream(final File file) + static FileInputStream getFileInputStream(final File file) throws FileNotFoundException { try { @@ -76,7 +77,7 @@ } } - InputStream getURLInputStream(final URL url) + static InputStream getURLInputStream(final URL url) throws IOException { try { @@ -91,8 +92,8 @@ } } - URL getResourceAsURL(final ClassLoader cl, - final String name) + static URL getResourceAsURL(final ClassLoader cl, + final String name) { return (URL) AccessController.doPrivileged(new PrivilegedAction() { @@ -108,8 +109,8 @@ }); } - Enumeration getResources(final ClassLoader cl, - final String name) throws IOException + static Enumeration getResources(final ClassLoader cl, + final String name) throws IOException { try{ return (Enumeration) @@ -129,7 +130,7 @@ } } - InputStream getResourceAsStream(final ClassLoader cl, + static InputStream getResourceAsStream(final ClassLoader cl, final String name) { return (InputStream) @@ -146,7 +147,7 @@ }); } - boolean doesFileExist(final File f) { + static boolean doesFileExist(final File f) { return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Modified: xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactory.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactory.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactory.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactory.java Sun Jul 23 10:27:51 2006 @@ -1,5 +1,5 @@ /* - * Copyright 2003-2004 The Apache Software Foundation. + * Copyright 2003-2004,2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,11 +40,6 @@ *

Default Object Model URI.

*/ public static final String DEFAULT_OBJECT_MODEL_URI = "http://java.sun.com/jaxp/xpath/dom"; - - /** - *

Take care of restrictions imposed by java security model

- */ - private static SecuritySupport ss = new SecuritySupport() ; /** *

Protected constructor as {@link #newInstance()} or {@link #newInstance(String uri)} @@ -148,7 +143,7 @@ ); } - ClassLoader classLoader = ss.getContextClassLoader(); + ClassLoader classLoader = SecuritySupport.getContextClassLoader(); if (classLoader == null) { //use the current class loader Modified: xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactoryFinder.java URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactoryFinder.java?rev=424770&r1=424769&r2=424770&view=diff ============================================================================== --- xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactoryFinder.java (original) +++ xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactoryFinder.java Sun Jul 23 10:27:51 2006 @@ -38,9 +38,7 @@ * @version $Revision$, $Date$ * @since 1.5 */ -class XPathFactoryFinder { - - private static SecuritySupport ss = new SecuritySupport() ; +final class XPathFactoryFinder { /** debug support code. */ private static boolean debug = false; @@ -53,7 +51,7 @@ static { // Use try/catch block to support applets try { - debug = ss.getSystemProperty("jaxp.debug") != null; + debug = SecuritySupport.getSystemProperty("jaxp.debug") != null; } catch (Exception _) { debug = false; } @@ -105,7 +103,7 @@ private void debugDisplayClassLoader() { try { - if( classLoader == ss.getContextClassLoader() ) { + if( classLoader == SecuritySupport.getContextClassLoader() ) { debugPrintln("using thread context class loader ("+classLoader+") for search"); return; } @@ -161,7 +159,7 @@ // system property look up try { if (debug) debugPrintln("Looking up system property '"+propertyName+"'" ); - String r = ss.getSystemProperty(propertyName); + String r = SecuritySupport.getSystemProperty(propertyName); if(r!=null) { if (debug) debugPrintln("The value is '"+r+"'"); sf = createInstance(r); @@ -177,7 +175,7 @@ } } - String javah = ss.getSystemProperty( "java.home" ); + String javah = SecuritySupport.getSystemProperty( "java.home" ); String configFile = javah + File.separator + "lib" + File.separator + "jaxp.properties"; @@ -190,9 +188,9 @@ if(firstTime){ File f=new File( configFile ); firstTime = false; - if(ss.doesFileExist(f)){ + if(SecuritySupport.doesFileExist(f)){ if (debug) debugPrintln("Read properties file " + f); - cacheProps.load(ss.getFileInputStream(f)); + cacheProps.load(SecuritySupport.getFileInputStream(f)); } } } @@ -218,7 +216,7 @@ URL resource = (URL)sitr.next(); if (debug) debugPrintln("looking into " + resource); try { - sf = loadFromServicesFile(uri, resource.toExternalForm(), ss.getURLInputStream(resource)); + sf = loadFromServicesFile(uri, resource.toExternalForm(), SecuritySupport.getURLInputStream(resource)); if(sf!=null) return sf; } catch(IOException e) { if( debug ) { @@ -357,14 +355,14 @@ return new SingleIterator() { protected Object value() { ClassLoader classLoader = XPathFactoryFinder.class.getClassLoader(); - return ss.getResourceAsURL(classLoader, SERVICE_ID); + return SecuritySupport.getResourceAsURL(classLoader, SERVICE_ID); //return (ClassLoader.getSystemResource( SERVICE_ID )); } }; } else { try { //final Enumeration e = classLoader.getResources(SERVICE_ID); - final Enumeration e = ss.getResources(classLoader, SERVICE_ID); + final Enumeration e = SecuritySupport.getResources(classLoader, SERVICE_ID); if (debug && !e.hasMoreElements()) { debugPrintln("no "+SERVICE_ID+" file was found"); } @@ -417,7 +415,7 @@ if( loader==null ) loader = ClassLoader.getSystemClassLoader(); //URL it = loader.getResource(classnameAsResource); - URL it = ss.getResourceAsURL(loader, classnameAsResource); + URL it = SecuritySupport.getResourceAsURL(loader, classnameAsResource); if (it != null) { return it.toString(); } else {