ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1170410 - in /webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema: XmlSchemaCollection.java utils/CollectionFactory.java
Date Wed, 14 Sep 2011 01:37:57 GMT
Author: dkulp
Date: Wed Sep 14 01:37:57 2011
New Revision: 1170410

URL: http://svn.apache.org/viewvc?rev=1170410&view=rev
Log:
Wrapper calls to System.getPropery within AccessController to allow controlling the access
via a securitymanager.

Modified:
    webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
    webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java

Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java?rev=1170410&r1=1170409&r2=1170410&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
Wed Sep 14 01:37:57 2011
@@ -21,6 +21,8 @@ package org.apache.ws.commons.schema;
 
 import java.io.IOException;
 import java.io.Reader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
@@ -355,11 +357,10 @@ public final class XmlSchemaCollection {
         // extension registry class. if so we'll instantiate a new one
         // and set it as the extension registry
         // if there is an error, we'll just print out a message and move on.
-
-        if (System.getProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY) != null)
{
+        String extRegProp = getSystemProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY);
+        if (extRegProp != null) {
             try {
-                Class clazz = Class.forName(System
-                    .getProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY));
+                Class clazz = Class.forName(extRegProp);
                 this.extReg = (ExtensionRegistry)clazz.newInstance();
             } catch (ClassNotFoundException e) {
                 System.err.println("The specified extension registry class cannot be found!");
@@ -370,6 +371,18 @@ public final class XmlSchemaCollection {
             }
         }
     }
+    
+    private String getSystemProperty(final String s) {
+        try {
+            return AccessController.doPrivileged(new PrivilegedAction<String>() {
+                public String run() {
+                    return System.getProperty(s);
+                }
+            });
+        } catch (SecurityException ex) {
+            return null;
+        }
+    }
 
     private void setupBuiltinDatatypeHierarchy(XmlSchema xsd) {
 

Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java?rev=1170410&r1=1170409&r2=1170410&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java
Wed Sep 14 01:37:57 2011
@@ -19,6 +19,8 @@
 
 package org.apache.ws.commons.schema.utils;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -39,7 +41,15 @@ public final class CollectionFactory {
 
         @Override
         protected Boolean initialValue() {
-            return Boolean.parseBoolean(System.getProperty(PROTECT_READ_ONLY_COLLECTIONS_PROP));
+            try {
+                return AccessController.doPrivileged(new PrivilegedAction<Boolean>()
{
+                    public Boolean run() {
+                        return Boolean.parseBoolean(System.getProperty(PROTECT_READ_ONLY_COLLECTIONS_PROP));
+                    }
+                });
+            } catch (SecurityException ex) {
+                return false;
+            }
         }
     };
 



Mime
View raw message