harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r932762 - in /harmony/enhanced/java/branches/java6/classlib/modules/luni/src: main/java/java/io/File.java test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
Date Sat, 10 Apr 2010 16:47:16 GMT
Author: hindessm
Date: Sat Apr 10 16:47:15 2010
New Revision: 932762

URL: http://svn.apache.org/viewvc?rev=932762&view=rev
Log:
Applying patches from "[#HARMONY-6496] [java6][classlib][luni]
File.getTotalSpace(), getFreeSpace() and getUsableSpace() not throwing
SecurityException without read permission".

Modified:
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/File.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/File.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/File.java?rev=932762&r1=932761&r2=932762&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/File.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/io/File.java
Sat Apr 10 16:47:15 2010
@@ -746,6 +746,7 @@ public class File implements Serializabl
 		if (security != null) {
 			security.checkPermission(new RuntimePermission(
 					"getFileSystemAttributes")); //$NON-NLS-1$
+			security.checkRead(path);
 		}
 		return getTotalSpaceImpl(properPath(true));
 	}
@@ -767,6 +768,7 @@ public class File implements Serializabl
 		if (security != null) {
 			security.checkPermission(new RuntimePermission(
 					"getFileSystemAttributes")); //$NON-NLS-1$
+			security.checkRead(path);
 		}
 		return getUsableSpaceImpl(properPath(true));
 	}
@@ -783,6 +785,7 @@ public class File implements Serializabl
 		if (security != null) {
 			security.checkPermission(new RuntimePermission(
 					"getFileSystemAttributes")); //$NON-NLS-1$
+			security.checkRead(path);
 		}
 		return getFreeSpaceImpl(properPath(true));
 	}

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java?rev=932762&r1=932761&r2=932762&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
Sat Apr 10 16:47:15 2010
@@ -2536,6 +2536,31 @@ public class FileTest extends TestCase {
             file.getFreeSpace();
             file.getUsableSpace();
             
+            // now only grant getFileSystemAttributes
+            // Regression for HARMONY-6496
+            customPolicy.permissions = new Permissions();
+            customPolicy.permissions.add(new RuntimePermission("getFileSystemAttributes"));
+            try {
+                file.getTotalSpace();
+                fail("Expected security exception");
+            } catch (SecurityException e) {
+                // expected
+            }
+            
+            try {
+                file.getFreeSpace();
+                fail("Expected security exception");
+            } catch (SecurityException e) {
+                // expected
+            }
+            
+            try {
+                file.getUsableSpace();
+                fail("Expected security exception");
+            } catch (SecurityException e) {
+                // expected
+            }
+            
         } finally {
             // restore security settings
             System.setSecurityManager(oldManager);



Mime
View raw message