You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-cvs@xml.apache.org by mr...@apache.org on 2008/06/22 03:57:59 UTC
svn commit: r670297 - in
/xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers:
NewInstance.java ParserFactory.java SecuritySupport.java
SecuritySupport12.java XMLReaderFactory.java
Author: mrglavas
Date: Sat Jun 21 18:57:58 2008
New Revision: 670297
URL: http://svn.apache.org/viewvc?rev=670297&view=rev
Log:
Rename: SecuritySupport12 -> SecuritySupport.
Added:
xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport.java (with props)
Removed:
xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport12.java
Modified:
xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/NewInstance.java
xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/ParserFactory.java
xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java
Modified: xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/NewInstance.java
URL: http://svn.apache.org/viewvc/xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/NewInstance.java?rev=670297&r1=670296&r2=670297&view=diff
==============================================================================
--- xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/NewInstance.java (original)
+++ xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/NewInstance.java Sat Jun 21 18:57:58 2008
@@ -92,7 +92,7 @@
{
// Figure out which ClassLoader to use for loading the provider
// class. If there is a Context ClassLoader then use it.
- ClassLoader cl = SecuritySupport12.getContextClassLoader();
+ ClassLoader cl = SecuritySupport.getContextClassLoader();
if (cl == null) {
// Assert: we are on JDK 1.1 or we have no Context ClassLoader
// so use the current ClassLoader
Modified: xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/ParserFactory.java
URL: http://svn.apache.org/viewvc/xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/ParserFactory.java?rev=670297&r1=670296&r2=670297&view=diff
==============================================================================
--- xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/ParserFactory.java (original)
+++ xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/ParserFactory.java Sat Jun 21 18:57:58 2008
@@ -78,7 +78,7 @@
NullPointerException,
ClassCastException
{
- String className = SecuritySupport12.getSystemProperty("org.xml.sax.parser");
+ String className = SecuritySupport.getSystemProperty("org.xml.sax.parser");
if (className == null) {
throw new NullPointerException("No value for sax.parser property");
} else {
Added: xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport.java
URL: http://svn.apache.org/viewvc/xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport.java?rev=670297&view=auto
==============================================================================
--- xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport.java (added)
+++ xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport.java Sat Jun 21 18:57:58 2008
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.xml.sax.helpers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * This class is duplicated for each JAXP subpackage so keep it in sync.
+ * It is package private and therefore is not exposed as part of the JAXP
+ * API.
+ *
+ * Security related methods that only work on J2SE 1.2 and newer.
+ */
+final class SecuritySupport {
+
+ private SecuritySupport() {}
+
+ static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) { }
+ return cl;
+ }
+ });
+ }
+
+ static String getSystemProperty(final String propName) {
+ return (String)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty(propName);
+ }
+ });
+ }
+
+ static FileInputStream getFileInputStream(final File file)
+ throws FileNotFoundException
+ {
+ try {
+ return (FileInputStream)
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws FileNotFoundException {
+ return new FileInputStream(file);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (FileNotFoundException)e.getException();
+ }
+ }
+
+ static InputStream getResourceAsStream(final ClassLoader cl,
+ final String name)
+ {
+ return (InputStream)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ InputStream ris;
+ if (cl == null) {
+ ris = ClassLoader.getSystemResourceAsStream(name);
+ } else {
+ ris = cl.getResourceAsStream(name);
+ }
+ return ris;
+ }
+ });
+ }
+}
Propchange: xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java
URL: http://svn.apache.org/viewvc/xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java?rev=670297&r1=670296&r2=670297&view=diff
==============================================================================
--- xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java (original)
+++ xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java Sat Jun 21 18:57:58 2008
@@ -114,7 +114,7 @@
ClassLoader loader = NewInstance.getClassLoader ();
// 1. try the JVM-instance-wide system property
- try { className = SecuritySupport12.getSystemProperty (property); }
+ try { className = SecuritySupport.getSystemProperty (property); }
catch (Exception e) { /* normally fails for applets */ }
// 2. if that fails, try META-INF/services/
@@ -125,20 +125,20 @@
className = null;
// First try the Context ClassLoader
- ClassLoader cl = SecuritySupport12.getContextClassLoader();
+ ClassLoader cl = SecuritySupport.getContextClassLoader();
if (cl != null) {
- is = SecuritySupport12.getResourceAsStream(cl, service);
+ is = SecuritySupport.getResourceAsStream(cl, service);
// If no provider found then try the current ClassLoader
if (is == null) {
cl = XMLReaderFactory.class.getClassLoader();
- is = SecuritySupport12.getResourceAsStream(cl, service);
+ is = SecuritySupport.getResourceAsStream(cl, service);
}
} else {
// No Context ClassLoader or JDK 1.1 so try the current
// ClassLoader
cl = XMLReaderFactory.class.getClassLoader();
- is = SecuritySupport12.getResourceAsStream(cl, service);
+ is = SecuritySupport.getResourceAsStream(cl, service);
}
if (is != null) {