You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2015/11/08 16:05:59 UTC
svn commit: r1713233 - in
/commons/proper/collections/branches/COLLECTIONS_3_2_X/src:
changes/changes.xml
java/org/apache/commons/collections/ExtendedProperties.java
test/org/apache/commons/collections/TestExtendedProperties.java
Author: tn
Date: Sun Nov 8 15:05:59 2015
New Revision: 1713233
URL: http://svn.apache.org/viewvc?rev=1713233&view=rev
Log:
[COLLECTIONS-538] Use AccessController to read system properties in ExtendedProperties, use File.separator in case of a security exception.
Modified:
commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml
commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/ExtendedProperties.java
commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/TestExtendedProperties.java
Modified: commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml?rev=1713233&r1=1713232&r2=1713233&view=diff
==============================================================================
--- commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml (original)
+++ commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml Sun Nov 8 15:05:59 2015
@@ -23,6 +23,12 @@
<release version="3.2.2" date="20XX-XX-XX" description="This is a bugfix release.">
+ <action issue="COLLECTIONS-538" dev="tn" type="fix" due-to="Trejkaz">
+ "ExtendedProperties" will now use a privileged action to access the
+ "file.separator" system property. In case the class does not have
+ permission to read system properties, the "File#separator" field will
+ be used instead.
+ </action>
<action issue="COLLECTIONS-350" dev="bayard" type="fix" due-to="Michael Akerman">
Removed debug output in "MapUtils#getNumber(Map)".
</action>
Modified: commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/ExtendedProperties.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/ExtendedProperties.java?rev=1713233&r1=1713232&r2=1713233&view=diff
==============================================================================
--- commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/ExtendedProperties.java (original)
+++ commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/ExtendedProperties.java Sun Nov 8 15:05:59 2015
@@ -26,6 +26,7 @@ import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
+import java.security.AccessController;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -165,10 +166,22 @@ public class ExtendedProperties extends
/**
* File separator.
*/
- protected String fileSeparator = System.getProperty("file.separator");
+ protected String fileSeparator;
+ {
+ try {
+ fileSeparator = (String) AccessController.doPrivileged(
+ new java.security.PrivilegedAction() {
+ public Object run() {
+ return System.getProperty("file.separator");
+ }
+ });
+ } catch (SecurityException ex) {
+ fileSeparator = File.separator;
+ }
+ }
/**
- * Has this configuration been intialized.
+ * Has this configuration been initialized.
*/
protected boolean isInitialized = false;
Modified: commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/TestExtendedProperties.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/TestExtendedProperties.java?rev=1713233&r1=1713232&r2=1713233&view=diff
==============================================================================
--- commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/TestExtendedProperties.java (original)
+++ commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/TestExtendedProperties.java Sun Nov 8 15:05:59 2015
@@ -19,6 +19,7 @@ package org.apache.commons.collections;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.security.Permission;
import java.util.Properties;
import junit.framework.Test;
@@ -314,4 +315,29 @@ public class TestExtendedProperties exte
assertEquals("class", extended.getString("resource.loader"));
}
+ public void testActiveSecurityManager() {
+ SecurityManager manager = new SecurityManager() {
+
+ public void checkPropertyAccess(String key) {
+ throw new SecurityException();
+ }
+
+ public void checkPermission(Permission perm) {
+ }
+
+ };
+
+ System.setSecurityManager(manager);
+
+ try {
+ ExtendedProperties properties = new ExtendedProperties();
+ assertNotNull(properties);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("failed to instantiate ExtendedProperties");
+ } finally {
+ System.setSecurityManager(null);
+ }
+ }
+
}